/* 집행관 — 별자리 테마
   레이아웃: 밤하늘 위에 별 하나하나가 화를 이루는 성도(星圖). 읽기 화면은 좁은 한 단.
   기본은 밤, 설정에서 낮으로 바꿀 수 있다. */
:root {
  --bg: #080b1c;
  --glow-a: #1a2263;
  --glow-b: #141a4a;
  --fg: #e8eaf7;
  --fg-dim: #b0b6da;
  --muted: #838bb8;
  --accent: #f1d58c;
  --accent-ink: #1b1630;
  --link: #9db4ff;
  --line: rgba(143, 160, 255, 0.34);
  --rule: rgba(143, 160, 255, 0.2);
  --panel: rgba(14, 19, 49, 0.92);
  --star: #f6e3ae;
  --serif: "Noto Serif KR", "Nanum Myeongjo", "Batang", serif;
  --display: "Cormorant Garamond", "Noto Serif KR", serif;
  --fs: 1.125rem;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f3f5fc;
  --glow-a: #dfe5fb;
  --glow-b: #e9ecf9;
  --fg: #1b1e3a;
  --fg-dim: #444a78;
  --muted: #666c98;
  --accent: #7a5200;
  --accent-ink: #fff8e6;
  --link: #3a4fb8;
  --line: rgba(73, 87, 170, 0.4);
  --rule: rgba(73, 87, 170, 0.22);
  --panel: rgba(255, 255, 255, 0.96);
  --star: #b8841a;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1100px 640px at 78% -8%, var(--glow-a), transparent 62%),
    radial-gradient(900px 560px at -6% 104%, var(--glow-b), transparent 58%),
    var(--bg);
  background-attachment: fixed;
  color: var(--fg);
  font-family: var(--serif);
  line-height: 1.85;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  word-break: keep-all;
  overflow-wrap: break-word;
}
#sky { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; }
:root[data-theme="light"] #sky { display: none; }

a { color: var(--link); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }
button { font: inherit; color: inherit; }
::selection { background: rgba(241, 213, 140, 0.35); }

/* 별 모양 (네 꼭짓점) */
.star-i, .sec-star, .ep-star {
  display: inline-block;
  background: var(--star);
  clip-path: polygon(50% 0, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0 50%, 40% 40%);
}
.star-i { width: 14px; height: 14px; }

/* ------------------------------------------------------------ 버튼 */
.btn {
  display: inline-block;
  padding: 0.7em 1.5em;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--fg);
  background: transparent;
  text-decoration: none;
  font-size: 1rem;
  line-height: 1.4;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.btn:hover { border-color: var(--accent); background: rgba(241, 213, 140, 0.08); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); background: var(--accent); }
.tool {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 8px;
  padding: 0.3em 0.75em;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--fg-dim);
}
.tool:hover, .tool[aria-expanded="true"] { color: var(--fg); border-color: var(--accent); }

/* ------------------------------------------------------------ 첫 화면 */
.home { max-width: 40rem; margin: 0 auto; padding-block: 0 4rem; }
.hero { text-align: center; padding-top: clamp(3.5rem, 12vh, 7rem); padding-bottom: 3rem; }
.hero-fig { width: min(78vw, 22rem); height: auto; display: block; margin: 0 auto -1.4rem; overflow: visible; }
.fig-lines polyline { fill: none; stroke: var(--line); stroke-width: 1; stroke-linejoin: round; }
.fig-stars path, .fig-stars circle { fill: var(--star); }
.fig-stars { filter: drop-shadow(0 0 5px rgba(246, 227, 174, 0.55)); }
:root[data-theme="light"] .fig-stars { filter: none; }
.hero h1 {
  margin: 0;
  font-size: clamp(3.4rem, 17vw, 6.4rem);
  font-weight: 700;
  letter-spacing: 0.32em;
  padding-left: 0.32em; /* 글자 사이 간격이 한쪽으로 쏠리지 않게 */
  line-height: 1.15;
  text-shadow: 0 0 36px rgba(157, 180, 255, 0.35);
}
:root[data-theme="light"] .hero h1 { text-shadow: none; }
.epigraph { margin: 1.4rem 0 2.2rem; color: var(--fg-dim); font-size: 1.05rem; text-wrap: balance; }
.cta { display: flex; gap: 0.8rem; justify-content: center; flex-wrap: wrap; }

.index { display: grid; gap: 3rem; }
.season h2 {
  display: flex; align-items: baseline; gap: 0.8rem; flex-wrap: wrap;
  margin: 0 0 1.2rem; font-size: 1rem; font-weight: 600;
  letter-spacing: 0.06em; color: var(--accent);
}
.season-n { font-family: var(--serif); }
.badge {
  font-size: 0.78rem; font-weight: 400; letter-spacing: 0;
  border: 1px solid var(--line); border-radius: 999px; padding: 0.05em 0.7em; color: var(--muted);
}
.ep-list { list-style: none; margin: 0; padding: 0; position: relative; }
.ep-list::before {
  content: ""; position: absolute; left: 13px; top: 18px; bottom: 18px; width: 1px;
  background: linear-gradient(var(--line), var(--line)); opacity: 0.9;
}
.ep a {
  position: relative; display: grid; grid-template-columns: 28px 1fr auto; align-items: center;
  column-gap: 0.9rem; padding: 0.7rem 0.6rem 0.7rem 0; color: var(--fg); text-decoration: none; border-radius: 10px;
}
.ep a:hover .ep-t { color: var(--accent); }
.ep a:hover .ep-star { transform: scale(1.35) rotate(18deg); filter: drop-shadow(0 0 6px var(--star)); }
.ep-star { width: 18px; height: 18px; margin-left: 4px; transition: transform 0.25s, filter 0.25s; position: relative; }
.ep:nth-child(3n + 2) .ep-star { width: 14px; height: 14px; margin-left: 6px; }
.ep:nth-child(3n) .ep-star { width: 11px; height: 11px; margin-left: 7.5px; opacity: 0.85; }
.ep-t { font-size: 1.12rem; font-weight: 600; transition: color 0.2s; }
.ep-m { font-size: 0.82rem; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.ep-done { position: absolute; right: -1.4rem; color: var(--accent); font-size: 0.85rem; }
.ep.is-read .ep-t { color: var(--fg-dim); font-weight: 400; }
.foot { margin-top: 4rem; padding-top: 1.4rem; border-top: 1px solid var(--rule); display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; color: var(--muted); font-size: 0.85rem; }
.foot p { margin: 0; }

/* ------------------------------------------------------------ 읽기 화면 */
.bar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 0.8rem;
  margin-left: calc(-1 * max(16px, env(safe-area-inset-left, 0px)));
  margin-right: calc(-1 * max(16px, env(safe-area-inset-right, 0px)));
  padding: calc(0.55rem + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) 0.55rem max(16px, env(safe-area-inset-left, 0px));
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
}
.bar-home { display: inline-flex; align-items: center; gap: 0.55rem; color: var(--fg); text-decoration: none; font-weight: 700; letter-spacing: 0.18em; }
.bar-ep { color: var(--muted); font-size: 0.9rem; margin-right: auto; }
.bar-name { font-size: 0.95rem; }
.progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: transparent; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); box-shadow: 0 0 8px var(--accent); }

.settings {
  position: fixed; z-index: 30; right: max(12px, env(safe-area-inset-right, 0px));
  top: calc(3.4rem + env(safe-area-inset-top, 0px));
  width: min(18rem, calc(100vw - 24px));
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 0.9rem 1rem; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}
.settings .row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.4rem 0; font-size: 0.92rem; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button { background: transparent; border: 0; padding: 0.3em 0.8em; cursor: pointer; color: var(--fg-dim); border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button:hover { color: var(--fg); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

.reader { max-width: 36rem; margin: 0 auto; padding-bottom: 3rem; }
.ep-head { text-align: center; padding: clamp(2.5rem, 8vh, 4.5rem) 0 2.4rem; }
.eyebrow { margin: 0 0 0.6rem; color: var(--accent); font-size: 0.85rem; letter-spacing: 0.1em; }
.ep-head h1 { margin: 0; font-size: clamp(2.2rem, 9vw, 3.2rem); font-weight: 700; letter-spacing: 0.08em; line-height: 1.25; text-wrap: balance; }
.meta { margin: 0.7rem 0 0; color: var(--muted); font-size: 0.85rem; }
.ep-head::after { content: ""; display: block; width: 1px; height: 3rem; margin: 1.6rem auto 0; background: linear-gradient(var(--line), transparent); }

.text { font-size: var(--fs); line-height: 2; }
.text p { margin: 0; }
.text p.gap { margin-top: 1.1em; }
.text .ul { text-decoration: underline; text-underline-offset: 0.22em; text-decoration-thickness: 1px; }
.sec { padding-top: 0.4rem; }
.sec + .sec { margin-top: 3rem; }
.sec-h {
  display: flex; align-items: center; flex-wrap: wrap; gap: 0.35rem 0.8rem;
  margin: 0 0 1.6rem; padding: 0.9rem 0 0.9rem; font-weight: 400; font-size: 1rem;
  border-top: 1px solid var(--rule);
}
.sec-star { width: 12px; height: 12px; flex: none; filter: drop-shadow(0 0 5px var(--star)); }
.sec-n { font-family: var(--display); font-size: 1.9rem; font-weight: 600; line-height: 1; color: var(--accent); font-variant-numeric: lining-nums; }
.sec-t { color: var(--fg-dim); font-size: 0.92rem; flex: 1 1 12rem; min-width: 0; }
.brk { display: flex; justify-content: center; margin: 2.4rem 0; }
.brk i {
  width: 11px; height: 11px; background: var(--star); opacity: 0.8;
  clip-path: polygon(50% 0, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0 50%, 40% 40%);
}
.end-mark { margin-top: 3rem !important; text-align: center; font-family: var(--display); font-style: italic; letter-spacing: 0.2em; color: var(--muted); }

.ep-nav { display: grid; grid-template-columns: 1fr auto 1fr; gap: 1rem; align-items: stretch; margin-top: 4.5rem; padding-top: 1.6rem; border-top: 1px solid var(--rule); }
.nav-cell { display: flex; flex-direction: column; gap: 0.2rem; padding: 0.8rem 1rem; border: 1px solid var(--rule); border-radius: 12px; text-decoration: none; color: var(--fg); min-width: 0; }
.nav-cell:hover { border-color: var(--accent); }
.nav-next { text-align: right; }
.nav-cell.is-empty { border-color: transparent; }
.nav-k { font-size: 0.8rem; color: var(--muted); }
.nav-t { font-weight: 600; }
.nav-mid { display: grid; place-items: center; width: 3rem; text-decoration: none; }
.nav-mid .star-i { width: 18px; height: 18px; filter: drop-shadow(0 0 6px var(--star)); }

.toast {
  position: fixed; z-index: 40; left: 50%; transform: translateX(-50%);
  bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
  width: min(26rem, calc(100vw - 32px));
  display: flex; align-items: center; gap: 0.6rem; justify-content: space-between;
  background: var(--panel); border: 1px solid var(--accent); border-radius: 14px;
  padding: 0.7rem 0.9rem; font-size: 0.92rem; box-shadow: 0 10px 34px rgba(0, 0, 0, 0.4);
}
.toast[hidden] { display: none; }
.toast button { background: transparent; border: 1px solid var(--line); border-radius: 8px; padding: 0.25em 0.7em; cursor: pointer; }
.toast button.go { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }

.notfound .hero h1 { font-size: clamp(2rem, 9vw, 3rem); letter-spacing: 0.12em; }

@media (max-width: 480px) {
  .ep a { grid-template-columns: 28px 1fr; }
  .ep-m { grid-column: 2; text-align: left; margin-top: -0.2rem; }
  .ep-done { right: 0.2rem; top: 0.9rem; }
  .ep-nav { grid-template-columns: 1fr 1fr; }
  .nav-mid { display: none; }
  .text { line-height: 1.95; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
