/* 디자인 오픈북 — phase 4 "field guide" (도감).
   Paper ground, ink type, one vermilion accent. Sections are separated by rules and space, never by boxes.
   The previews are the specimens: big plates first, words underneath. */
:root {
  --bg: #f3efe6;        /* paper */
  --plate: #fbf9f3;     /* specimen ground inside a preview */
  --surface: #fbf9f3;
  --tint: #e8e2d4;
  --ink: #1d1b17;
  --muted: #5c564c;
  --line: #d4ccbb;
  --accent: #b5391a;    /* vermilion, the only accent */
  --accent-ink: #ffffff;
  --sans: 'Pretendard Variable', Pretendard, -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Malgun Gothic', system-ui, sans-serif;
  --serif: 'Newsreader', 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, 'D2Coding', monospace;
  --gutter: max(16px, env(safe-area-inset-left));
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1814;
    --plate: #23201b;
    --surface: #23201b;
    --tint: #2d2923;
    --ink: #ece6da;
    --muted: #a9a193;
    --line: #3d382f;
    --accent: #f0885f;
    --accent-ink: #1a1814;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scrollbar-color: var(--line) var(--bg); }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 16px/1.65 var(--sans); overflow-wrap: break-word;
  font-variant-numeric: tabular-nums;
}
::selection { background: color-mix(in srgb, var(--accent) 26%, transparent); color: var(--ink); }
input { caret-color: var(--accent); }
a { color: inherit; text-underline-offset: .22em; text-decoration-thickness: 1px; }
.wrap { max-width: 1200px; margin: 0 auto; padding-left: var(--gutter); padding-right: max(16px, env(safe-area-inset-right)); }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 8px; top: -60px; background: var(--ink); color: var(--bg); padding: 8px 12px; z-index: 20; }
.skip:focus { top: 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ── masthead ── */
.top { padding: 28px 0 0; }
.topline { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 20px; }
h1 { margin: 0; font-size: clamp(1.75rem, 1.15rem + 2.2vw, 2.75rem); line-height: 1.12; font-weight: 800; letter-spacing: -.025em; text-wrap: balance; }
.tagline { margin: 8px 0 18px; color: var(--muted); font-size: 1.0625rem; max-width: 34em; }
.search { max-width: 440px; }
.search input {
  width: 100%; font: inherit; color: var(--ink); background: transparent;
  border: 0; border-bottom: 1px solid var(--ink); border-radius: 0; padding: 8px 0; -webkit-appearance: none; appearance: none;
}
.search input::placeholder { color: var(--muted); opacity: 1; }
.search input:focus-visible { outline: none; border-bottom: 2px solid var(--accent); padding-bottom: 7px; }

.langs ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 14px; }
.langs a { display: block; padding: 8px 0; min-height: 36px; font: 500 14px/20px var(--sans); color: var(--muted); text-decoration: none; }
.langs a:hover { color: var(--ink); }
.langs a[aria-current="page"] { color: var(--ink); font-weight: 700; text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 6px; }

/* ── category index (sticky) ── */
.tabbar { position: sticky; top: 0; z-index: 10; background: var(--bg); border-bottom: 1px solid var(--line); margin-top: 18px; }
.tabs { display: flex; gap: 24px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; font: 600 15px/1 var(--sans); color: var(--muted); background: none; border: 0; border-radius: 0;
  padding: 14px 0 12px; cursor: pointer; white-space: nowrap; text-align: left; box-shadow: inset 0 -2px 0 transparent;
}
.tab .n { font-weight: 400; margin-left: 3px; }
.tab:hover { color: var(--ink); }
.tab[aria-pressed="true"] { color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); }

/* ── list page ── */
main { padding-top: 10px; padding-bottom: 56px; }
.count { margin: 0; font-size: 14px; color: var(--muted); }
.count.quiet { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.empty { padding: 56px 0; color: var(--muted); }
.empty p { margin: 0; max-width: 28em; font-size: 1.0625rem; }
.group[hidden], .card[hidden], .empty[hidden], .plates li[hidden] { display: none; }

.group { margin-top: 34px; }
.group-head { border-top: 2px solid var(--ink); padding-top: 12px; margin-bottom: 6px; }
.group-head h2 { margin: 0; font-size: clamp(1.5rem, 1.1rem + 1.5vw, 2.25rem); line-height: 1.2; font-weight: 800; letter-spacing: -.02em; }
.group-head p { margin: 4px 0 0; color: var(--muted); max-width: 46em; }
.tally { white-space: nowrap; color: var(--ink); font-weight: 600; }
.tally::before { content: '· '; color: var(--muted); font-weight: 400; }

.card { min-width: 0; scroll-margin-top: 64px; }
.group > .card { margin-top: 26px; }
.entry-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 16px; margin-bottom: 12px; }
.card-title { margin: 0; font-size: 1.1875rem; line-height: 1.35; font-weight: 700; letter-spacing: -.01em; }
.card-title a { text-decoration: none; }
.card-title a:hover { text-decoration: underline; text-decoration-color: var(--accent); }
.more { font-size: 14px; color: var(--muted); text-decoration: underline; text-decoration-color: var(--line); }
.more:hover { color: var(--accent); text-decoration-color: currentColor; }
.more::after { content: ' →'; }

.plates { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(208px, 1fr)); gap: 24px 18px; }
.plate { display: block; text-decoration: none; color: var(--ink); }
.plate .pv { width: 100%; pointer-events: none; transition: border-color .15s; }
.plate-name { display: block; margin-top: 9px; font-weight: 600; font-size: 15px; line-height: 1.35; }
.latin { display: block; font-family: var(--serif); font-style: italic; font-weight: 400; color: var(--muted); font-size: 15.5px; line-height: 1.3; letter-spacing: 0; }
.plate:hover .pv { border-color: var(--ink); }
.plate:hover .plate-name { text-decoration: underline; text-decoration-color: var(--accent); text-decoration-thickness: 2px; }
.plate:focus-visible { outline-offset: 4px; }

/* cards without previews: ruled text entries */
.card.textonly { border-top: 1px solid var(--line); padding-top: 14px; max-width: 46em; }
.card.textonly .answer { margin: 4px 0 0; color: var(--muted); }
@media (min-width: 760px) {
  .group[data-cat="aiwork"] { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 40px; }
  .group[data-cat="aiwork"] > .group-head { grid-column: 1 / -1; }
}

/* ── card page ── */
.top.slim { padding: 14px 0; border-bottom: 1px solid var(--line); }
.top.slim .topline { align-items: center; }
.brand { font-weight: 800; font-size: 1.0625rem; letter-spacing: -.01em; color: var(--ink); text-decoration: none; }
.brand:hover { color: var(--accent); }
.page { max-width: 1200px; }
.crumbs ol { list-style: none; margin: 6px 0 18px; padding: 0; display: flex; flex-wrap: wrap; gap: 4px; font-size: 14px; color: var(--muted); }
.crumbs li + li::before { content: '/'; margin-right: 4px; color: var(--line); }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--accent); }

.card.solo .card-title { font-size: clamp(1.75rem, 1.2rem + 2.2vw, 2.75rem); line-height: 1.15; font-weight: 800; letter-spacing: -.025em; margin: 0 0 16px; text-wrap: balance; max-width: 20em; }
.answer { margin: 0 0 10px; font-size: 1.125rem; line-height: 1.6; max-width: 38em; }
.answer .q { display: block; font-weight: 700; margin-bottom: 2px; }
.lede { margin: 0; color: var(--muted); max-width: 40em; }

.card.solo section { margin-top: 44px; }
.card.solo section > h2, .sec-head h2 { margin: 0; font-size: 1.3125rem; line-height: 1.3; font-weight: 800; letter-spacing: -.015em; }
.card.solo section > h2, .sec-head { border-top: 2px solid var(--ink); padding-top: 12px; }
.sec-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 16px; }
.hint { margin: 0; font-size: 14px; color: var(--muted); }

.terms { list-style: none; margin: 0; padding: 0; }
.term { display: grid; grid-template-columns: minmax(0, 360px) minmax(0, 1fr); gap: 4px 28px; align-items: start; padding: 22px 0; border-bottom: 1px solid var(--line); scroll-margin-top: 16px; }
.term.nopv { grid-template-columns: minmax(0, 1fr); }
.term .pv { width: 100%; }
.term-name { margin: 0; font-size: 1.25rem; line-height: 1.3; font-weight: 700; letter-spacing: -.01em; }
.term .latin { font-size: 1.125rem; margin-top: 2px; }
.term-def { margin: 10px 0 0; max-width: 34em; }
.term:target { background: var(--tint); margin: 0 -14px; padding-left: 14px; padding-right: 14px; }
.term:target .term-name { color: var(--accent); }

.how { margin: 14px 0 0; padding-left: 1.15em; max-width: 42em; }
.how li { padding-left: 4px; }
.how li + li { margin-top: 8px; }
.how li::marker { color: var(--muted); }

.prompt { margin-top: 20px; min-width: 0; }
.prompt-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.prompt-label { margin: 0; font-size: 1rem; font-weight: 700; }
.copy {
  flex: none; font: 600 14px/1 var(--sans); color: var(--accent); background: transparent;
  border: 1px solid currentColor; border-radius: 2px; padding: 9px 16px; min-height: 38px; cursor: pointer;
  transition: background-color .15s, color .15s;
}
.copy:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.copy:active { transform: translateY(1px); }
.prompt-text {
  margin: 0; padding: 16px 18px; background: var(--tint); color: var(--ink);
  font: 400 13.5px/1.75 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere; user-select: text;
}

.refs { margin: 36px 0 0; font-size: 14px; color: var(--muted); }
.refs a { color: var(--muted); }
.refs a:hover { color: var(--accent); }

.pager { display: grid; grid-template-columns: minmax(0, 1fr); margin-top: 44px; border-top: 1px solid var(--ink); }
@media (min-width: 560px) { .pager { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 32px; } .pager .next { text-align: right; } }
.pager a { display: block; padding: 14px 0; color: var(--ink); text-decoration: none; font-weight: 700; }
.pager a + a { border-top: 1px solid var(--line); }
@media (min-width: 560px) { .pager a + a { border-top: 0; } }
.pager a:hover { color: var(--accent); }
.pager span { display: block; font-size: 13px; font-weight: 400; color: var(--muted); margin-bottom: 2px; }
.back { margin: 10px 0 0; }
.back a { color: var(--accent); }

.foot { border-top: 1px solid var(--line); padding: 22px 0 36px; color: var(--muted); font-size: 14px; }
.foot p { margin: 0; max-width: 42em; }

/* ── language chooser + 404 ── */
:lang(ja) body, body:lang(ja) {
  --sans: 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', 'Yu Gothic UI', Meiryo, system-ui, sans-serif;
  font-family: var(--sans);
}
.chooser main { padding-top: 14vh; max-width: 600px; }
.chooser h1 { margin-bottom: 22px; }
.pick { list-style: none; margin: 0; padding: 0; border-bottom: 1px solid var(--line); }
.pick li { border-top: 1px solid var(--line); }
.pick a { display: block; padding: 16px 0; color: var(--ink); text-decoration: none; }
.pick strong { display: block; font-size: 1.25rem; font-weight: 800; }
.pick span { color: var(--muted); font-size: 15px; }
.pick a:hover strong { color: var(--accent); }

/* ── small screens ── */
@media (max-width: 719px) {
  .top { padding-top: 16px; }
  .tagline { margin: 6px 0 12px; font-size: 15px; }
  .tabbar { margin-top: 12px; }
  .tabs { gap: 20px; }
  .group { margin-top: 26px; }
  .term { grid-template-columns: minmax(0, 1fr); padding: 18px 0; }
  .term .pv { margin-bottom: 10px; }
}
@media (max-width: 559px) {
  .plates { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 12px; }
  .plate-name { font-size: 14px; }
  .latin { font-size: 14.5px; }
  .entry-head { margin-bottom: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}
