/* 뷰티 예습: a study handout in one violet ink, filed in a violet binder with divider tabs on its right edge.
   Colours: Sanzo Wada, A Dictionary of Colour Combinations, no. 170, lightness moves only (see DESIGN.md). */
:root {
  --desk: #59256a;        /* Red Violet: the binder board around the sheet, the footer band */
  --ink: #59256a;         /* Red Violet: all text on the sheet, 10.37:1 */
  --sheet: #fdf5ff;       /* Red Violet at L97.5: the reading surface */
  --dim: #7a448b;         /* Red Violet at L38: dates, labels, standfirsts in lists, 6.5:1 */
  --pen: #b73f74;         /* Rosolanc Purple: links on the sheet (4.95:1), divider tabs, 문/답 marks, revisions */
  --marker: #fcb315;      /* Orange Yellow: the open tab, footer links (6.11:1 on the desk) */
  --highlight: #ffd08a;   /* Orange Yellow at L86: highlighter band under bold text, ink on it 7.72:1 */
  --head: #ffe4c1;        /* Orange Yellow at L92: table header rows, ink on it 9.02:1 */
  --rule: #b57bc6;        /* Red Violet at L60: table grid, cut line, leaders; never text */
  --rule-faint: #e3a6f3;  /* Red Violet at L76: separators between list rows */

  --font-display: "Gowun Batang", "AppleMyungjo", "Nanum Myeongjo", "Noto Serif KR", "Batang", serif;
  --font-text: "Gowun Batang", "AppleMyungjo", "Nanum Myeongjo", "Noto Serif KR", "Batang", serif;
  --font-ui: "Wanted Sans", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;

  --sheet-w: 52rem;
  --tabs: 3.5rem;
  --edge: clamp(1.25rem, 5vw, 3.5rem);
  --measure: 40rem;       /* 66ch of Gowun Batang at 18px, 38 Hangul syllables a line; in rem so labels and lists share the body's width */

  --base: 1.125rem;
  --lead: clamp(1.1875rem, 1.1rem + 0.4vw, 1.3rem);
  --h1: clamp(1.875rem, 1.45rem + 1.8vw, 2.6rem);
  --h1-front: clamp(2.75rem, 1.9rem + 3.6vw, 4.25rem);
  --h2: clamp(1.3125rem, 1.2rem + 0.45vw, 1.5rem);
  --label: 0.8125rem;
  --cell: 0.9375rem;
  --key: 0.875rem;
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--desk); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 1.5rem; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--desk);
  color: var(--ink);
  font: 400 var(--base)/1.85 var(--font-text);
  word-break: keep-all;
  overflow-wrap: anywhere;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 1fr auto auto;
  grid-template-areas: "mast" "main" "tabs" "foot";
}
a { color: var(--pen); text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--pen); outline-offset: 2px; }

/* ---- the sheet: masthead and main share one pale field ---- */
.mast {
  grid-area: mast;
  background: var(--sheet);
  display: flex;
  align-items: center;
  gap: 0 1.25rem;
  flex-wrap: wrap;
  padding: 0.35rem var(--edge) 0.3rem;
  border-bottom: 4px double var(--ink);
}
.mast .name { display: block; padding: 0.65rem 0; font: 700 1.3125rem/1.2 var(--font-display); letter-spacing: -0.02em; color: var(--ink); text-decoration: none; }
.mast .pages { margin-left: auto; margin-right: -0.6rem; display: flex; font: 400 0.875rem/1.4 var(--font-ui); }
.mast .pages a { display: block; min-width: 2.75rem; text-align: center; padding: 0.8rem 0.6rem; color: var(--ink); text-decoration: none; }
.mast .pages a:hover, .mast .pages a[aria-current] { text-decoration: underline; text-decoration-color: var(--pen); }

main {
  grid-area: main;
  background: var(--sheet);
  min-width: 0;
  padding: 2.25rem var(--edge) 3.5rem;
}

/* ---- headline, standfirst, record line ---- */
h1, h2, h3 { text-wrap: balance; }
h1 { font: 700 var(--h1)/1.3 var(--font-display); letter-spacing: -0.02em; margin: 0 0 1rem; }
.summary { font: 400 var(--lead)/1.7 var(--font-text); max-width: var(--measure); margin: 0 0 1.5rem; text-wrap: pretty; }

.record {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0.15rem 1rem;
  margin: 0 0 2.25rem;
  padding: 0.7rem 0;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  max-width: var(--measure);
  font: 400 var(--label)/1.5 var(--font-ui);
  font-variant-numeric: tabular-nums;
}
.record div { display: contents; }
.record dt { color: var(--dim); }
.record dd { margin: 0; font-weight: 700; }
.record dd a { color: var(--ink); }
.record .revised dd { color: var(--pen); }
.record dd a { display: inline-block; min-width: 2.75rem; padding: 0.9rem 0.6rem; margin: -0.9rem -0.6rem; }

.toc { max-width: var(--measure); margin: 0 0 2.5rem; font: 400 var(--key)/1.55 var(--font-ui); }
.toc p { margin: 0 0 0.35rem; font-weight: 700; }
.toc ol { margin: 0; padding-left: 1.4em; }
.toc li { padding: 0.12rem 0; }
.toc li::marker { color: var(--dim); font-variant-numeric: tabular-nums; }
.toc a { color: var(--ink); text-decoration-color: var(--rule); }
.toc li { padding: 0; }
.toc a { display: inline-block; min-width: 2.75rem; padding: 0.7rem 0; }

/* ---- article body ---- */
.body { max-width: var(--measure); }
.body :where(p, ul, ol, table, blockquote, pre, dl, figure) { margin-top: 0; margin-bottom: 0; }
.body > * + * { margin-top: 1.1em; }
.body p { text-wrap: pretty; }
.body h2 { font: 700 var(--h2)/1.4 var(--font-display); letter-spacing: -0.01em; margin: 0; }
.body h3 { font: 700 1rem/1.5 var(--font-ui); color: var(--pen); margin: 0; }
.body > * + h2 { margin-top: 2.6em; }
.body > * + h3 { margin-top: 2.1em; }
.body > h2 + *, .body > h3 + * { margin-top: 0.55em; }
.body ul, .body ol { padding-left: 1.3em; }
.body li + li { margin-top: 0.3em; }
.body li::marker { color: var(--pen); }
.body p strong, .body li strong {
  font-weight: 700;
  box-shadow: inset 0 -0.55em 0 var(--highlight);
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.body strong a { color: var(--ink); }
.body blockquote { margin-inline: 0; padding-left: 1.1rem; border-left: 2px solid var(--pen); }
.body > * + table, .body > table + * { margin-top: 1.6em; }
.body blockquote p + p { margin-top: 0.8em; }
.body hr { border: 0; border-top: 1px solid var(--rule); margin: 2.4em 0; }
.body code { font-family: var(--font-ui); font-size: 0.9em; }

/* Tables: a full grid in the handout's ink, a pale yellow header row; a wide table scrolls inside itself. */
.body table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  font: 400 var(--cell)/1.55 var(--font-ui);
  font-variant-numeric: tabular-nums;
}
.body th, .body td { border: 1px solid var(--rule); padding: 0.55rem 0.75rem; text-align: left; vertical-align: top; min-width: 6.5rem; }
.body thead th { background: var(--head); font-weight: 700; border-color: var(--ink); }
.body tbody th { font-weight: 700; }
.body td[align="right"], .body th[align="right"] { text-align: right; }
.body td[align="center"], .body th[align="center"] { text-align: center; }

/* ---- short answers, answer key, related ---- */
.answers, .key, .related { max-width: var(--measure); }
.answers h2, .key h2, .related h2, .recent h2 {
  display: inline-block;
  margin: 0 0 1rem;
  padding: 0.2rem 0.6rem;
  background: var(--ink);
  color: var(--sheet);
  font: 700 0.875rem/1.4 var(--font-ui);
}
.answers { margin-top: 3.25rem; }
.answers details { border-top: 1px solid var(--rule-faint); padding: 0.75rem 0; }
.answers details:last-child { border-bottom: 1px solid var(--rule-faint); }
.answers summary { cursor: pointer; font-weight: 700; list-style: none; display: flex; gap: 0.7rem; align-items: baseline; }
.answers summary::-webkit-details-marker { display: none; }
.answers summary:hover { color: var(--pen); }
.answers details p { margin: 0.6rem 0 0.2rem; display: flex; gap: 0.7rem; align-items: baseline; }
.answers .mark {
  flex: none;
  display: inline-block;
  width: 1.6rem;
  text-align: center;
  border: 1px solid var(--pen);
  color: var(--pen);
  font: 700 var(--label)/1.45 var(--font-ui);
}
.answers details[open] summary .mark { background: var(--pen); color: var(--sheet); }

.key { margin-top: 3.5rem; padding-top: 1.75rem; border-top: 1px dashed var(--rule); }
.key ol { margin: 0; padding-left: 1.7em; font: 400 var(--key)/1.6 var(--font-ui); font-variant-numeric: tabular-nums; }
.key li { break-inside: avoid; padding-bottom: 0.65rem; }
.key li::marker { color: var(--pen); font-weight: 700; }
.key b { font-weight: 700; }
.key .read { display: block; color: var(--dim); }

.related { margin-top: 2.75rem; }
.related ul { list-style: none; margin: 0; padding: 0; }
.related li { border-top: 1px solid var(--rule-faint); padding: 0.55rem 0; }
.related a { color: var(--ink); text-decoration: none; font-weight: 700; }
.related a:hover { color: var(--pen); text-decoration: underline; }

/* ---- front page and lists: the contents page of a study guide ---- */
.opening { margin-bottom: 2.5rem; }
.front h1 { font-size: var(--h1-front); line-height: 1.12; letter-spacing: -0.03em; margin-bottom: 1.25rem; }
.front .summary { max-width: 30em; }
.front .note { margin: 0; max-width: var(--measure); color: var(--dim); font-size: 1rem; line-height: 1.8; }
.back { margin: 0; font: 700 1rem/1.5 var(--font-ui); }

.recent { margin-bottom: 3rem; }
.contents { list-style: none; margin: 0; padding: 0; }
.contents li { padding: 1rem 0 1.1rem; border-top: 1px solid var(--rule-faint); }
.contents li:first-child { border-top-color: var(--ink); }
.contents .line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.15rem 0.6rem; margin: 0; }
.contents .line a { font: 700 1.1875rem/1.45 var(--font-display); letter-spacing: -0.01em; color: var(--ink); text-decoration: none; }
.contents .line a:hover { color: var(--pen); text-decoration: underline; text-decoration-thickness: 1px; }
.contents .leader { display: none; }
.contents time { order: -1; flex-basis: 100%; font: 400 var(--label)/1.4 var(--font-ui); color: var(--dim); font-variant-numeric: tabular-nums; }
.contents .lead { margin: 0.35rem 0 0; max-width: var(--measure); color: var(--dim); font-size: 1rem; line-height: 1.75; }
.contents .topic { font: 700 var(--label)/1 var(--font-ui); color: var(--pen); margin-right: 0.35rem; }

.shelves:empty { display: none; }
.shelves { display: grid; gap: 2.25rem 2.5rem; }
.shelf h2 { font: 700 1.25rem/1.4 var(--font-display); margin: 0 0 0.5rem; padding-bottom: 0.4rem; border-bottom: 1px solid var(--ink); }
.shelf h2 a { color: var(--ink); text-decoration: none; }
.shelf h2 a:hover { color: var(--pen); }
.shelf ul { list-style: none; margin: 0; padding: 0; }
.shelf li { padding: 0.45rem 0; border-bottom: 1px solid var(--rule-faint); line-height: 1.6; }
.shelf li a { color: var(--ink); text-decoration: none; }
.shelf li a:hover { color: var(--pen); text-decoration: underline; }

/* ---- divider tabs: on a phone they hang from the bottom edge of the sheet ---- */
.tabs { grid-area: tabs; padding: 0 var(--edge); }
.tabs ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.3rem 0.3rem; }
.tabs a {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 2.75rem;
  padding: 0.5rem 0.85rem;
  background: var(--pen);
  color: var(--sheet);
  border-radius: 0 0 4px 4px;
  font: 700 0.875rem/1.2 var(--font-ui);
  text-decoration: none;
}
.tabs a:hover { text-decoration: underline; }
.tabs a.open { background: var(--marker); color: var(--ink); }
.tabs .count { font-weight: 400; font-variant-numeric: tabular-nums; }
.tabs :focus-visible, .foot :focus-visible { outline-color: var(--marker); }

.foot { grid-area: foot; padding: 2.25rem var(--edge) 2.75rem; color: var(--sheet); font: 400 0.875rem/1.7 var(--font-ui); }
.foot p { margin: 0; max-width: 44rem; }
.foot .links { margin: 0.3rem 0 0 -0.6rem; display: flex; flex-wrap: wrap; }
.foot .links a { display: inline-block; min-width: 2.75rem; text-align: center; padding: 0.7rem 0.6rem; }
.foot a { color: var(--marker); }

/* ---- wide screens: one sheet on the desk, the tabs sticking out of its right edge ---- */
@media (min-width: 60rem) {
  body {
    grid-template-columns: minmax(1.5rem, 1fr) minmax(0, var(--sheet-w)) var(--tabs) minmax(1.5rem, 1fr);
    grid-template-rows: auto 1fr auto;
    grid-template-areas:
      ". mast tabs ."
      ". main tabs ."
      ". foot foot .";
    padding-top: 2.5rem;
  }
  .mast { padding-top: 0.9rem; padding-bottom: 0.5rem; }
  main { padding-top: 3rem; padding-bottom: 4.5rem; }
  .tabs { padding: 2.25rem 0 0; }
  .tabs ul { flex-direction: column; flex-wrap: nowrap; gap: 0.35rem; align-items: flex-start; }
  .tabs a {
    writing-mode: vertical-rl;
    width: 2.6rem;
    min-height: 0;
    padding: 0.75rem 0 0.8rem;
    gap: 0.35rem;
    border-radius: 0 4px 4px 0;
    font-size: 0.8125rem;
  }
  .tabs a:hover { width: 2.9rem; }
  .tabs a.open { width: 3.25rem; }
  .tabs .count { text-combine-upright: all; -webkit-text-combine: horizontal; }
  .foot { padding: 2.25rem var(--edge) 3rem; }
  .contents .line { flex-wrap: nowrap; }
  .contents .leader { display: block; flex: 1 1 1.5rem; min-width: 1.5rem; border-bottom: 2px dotted var(--rule); align-self: flex-end; margin-bottom: 0.55em; }
  .contents time { order: 0; flex: none; flex-basis: auto; white-space: nowrap; }
  .shelves { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .key ol { columns: 2; column-gap: 2.5rem; }
  .record { display: flex; flex-wrap: wrap; gap: 0; }
  .record div { display: flex; gap: 0.45rem; align-items: baseline; padding: 0 1rem; border-left: 1px solid var(--rule); }
  .record div:first-child { padding-left: 0; border-left: 0; }
  .toc ol { columns: 2; column-gap: 2rem; }
  .toc a { padding: 0.12rem 0; }
  .toc li { break-inside: avoid; }
}
@media (min-width: 60rem) and (min-height: 50rem) {
  .tabs ul { position: sticky; top: 1.5rem; }
}

@media print {
  html, body { background: #fff; }
  body { display: block; padding: 0; }
  .tabs, .mast .pages, .related, .foot .links { display: none; }
  main, .mast { background: #fff; }
  .key ol { columns: 1; }
}
