/* 코성형 열람실: a register printout on a form printed in one teal ink. DESIGN.md records the direction. */
:root {
  /* Sanzo Wada, A Dictionary of Colour Combinations #330, roles by palette.py (light scheme) */
  --ground: #bce4e5;      /* Nile Blue: the sheet */
  --ink: #004c4f;         /* Green Blue, darkened: all text, frames, the masthead band (7.16:1 on ground) */
  --head: #9db2ce;        /* Salvia Blue: header rows and section bands (ink on it 4.52:1, bold only) */
  --slip: #c1c494;        /* Olive Buff: record box, excerpts, footer (ink on it 5.4:1) */
  --accent: #5f6338;      /* Olive Buff, darkened: link underlines (4.62:1 on ground) */
  --rule: #5e989a;        /* inner cell rules, never text */
  --band-rule: #428184;   /* rules inside the masthead band */

  --font-display: "NanumSquare Neo", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  --font-text: "Noto Serif KR", "Nanum Myeongjo", AppleMyungjo, Batang, serif;
  --font-ui: "IBM Plex Mono", "NanumSquare Neo", "Apple SD Gothic Neo", "Malgun Gothic", monospace;

  --sheet: 78rem;
  --edge: clamp(1rem, 4.2vw, 2.5rem);
  --gutter: 13rem;
  --gap: 3rem;
  --measure: 72ch;
  --frame: 2px solid var(--ink);
  --cell: 1px solid var(--rule);

  --base: clamp(1rem, 0.96rem + 0.2vw, 1.0625rem);
  --lead: clamp(1.0625rem, 1rem + 0.35vw, 1.1875rem);
  --label: 0.8125rem;
  --cell-size: 0.9375rem;
  --h2: clamp(1.1875rem, 1.1rem + 0.4vw, 1.3125rem);
  --h1: clamp(1.625rem, 1.3rem + 1.4vw, 2.25rem);
  --h1-home: clamp(2.125rem, 1.6rem + 2.4vw, 3.25rem);
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--ground); -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: 1.25rem; }
body {
  margin: 0; min-height: 100vh; color: var(--ink); background: var(--ground);
  font: 400 var(--base)/1.85 var(--font-text);
  word-break: keep-all; overflow-wrap: break-word; font-kerning: normal;
  /* <main> is first in the document; the masthead is drawn above it. */
  display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr auto;
  grid-template-areas: "mast" "main" "foot";
}
main { grid-area: main; min-width: 0; }
.mast { grid-area: mast; }
.foot { grid-area: foot; }

a { color: var(--ink); text-decoration-line: underline; text-decoration-color: var(--accent); text-decoration-thickness: 0.09em; text-underline-offset: 0.2em; }
a:hover { background: var(--slip); text-decoration-thickness: 0.14em; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.num { font-family: var(--font-ui); font-size: 0.92em; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; word-spacing: -0.3em; }

/* Masthead: the printed head of the form. */
.mast { background: var(--ink); color: var(--ground); font-family: var(--font-display); padding-inline: max(var(--edge), (100% - var(--sheet)) / 2); }
.mast a { color: var(--ground); text-decoration: none; }
.mast a:hover { background: var(--band-rule); }
.mast :focus-visible { outline-color: var(--ground); }
.mast-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.4rem 1.5rem; padding-block: 0.85rem 0.8rem; }
.sign { font-weight: 700; font-size: 1.1875rem; line-height: 1.3; letter-spacing: -0.02em; padding-block: 0.625rem; margin-block: -0.625rem; }
.mast-links { list-style: none; margin: 0 0 0 auto; padding: 0; display: flex; flex-wrap: wrap; gap: 0.2rem 1.4rem; font-size: 0.875rem; line-height: 1.5; }
.mast-links a { display: inline-block; padding: 0.8rem 0.6rem; margin: -0.8rem -0.6rem; text-decoration: underline; text-decoration-color: var(--band-rule); text-underline-offset: 0.25em; }
.mast a[aria-current] { text-decoration-color: var(--ground); }
.mast-topics ul {
  list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  border-top: 1px solid var(--band-rule); border-left: 1px solid var(--band-rule);
}
.mast-topics li { border-right: 1px solid var(--band-rule); border-bottom: 1px solid var(--band-rule); margin-bottom: -1px; }
.mast-topics a { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; padding: 0.5rem 0.75rem 0.55rem; font-size: 0.875rem; line-height: 1.4; }
.mast-topics a[aria-current] { background: var(--ground); color: var(--ink); }
.t-count { font-family: var(--font-ui); font-size: 0.8125rem; }

/* The sheet: one label column, one reading column, an open right margin that only tables use. */
main {
  padding: clamp(1.75rem, 4.5vw, 3.25rem) max(var(--edge), (100% - var(--sheet)) / 2) 4rem;
  display: grid; grid-template-columns: [gutter text] minmax(0, 1fr) [g-end t-end wide-end];
  align-content: start;
}
main > * { grid-column: gutter / wide-end; min-width: 0; }

h1, h2, h3 { font-family: var(--font-display); font-weight: 700; color: var(--ink); text-wrap: balance; }
h1 { font-size: var(--h1); line-height: 1.3; letter-spacing: -0.025em; margin: 0 0 1rem; max-width: 30em; }
.summary { font-size: var(--lead); line-height: 1.75; margin: 0 0 1.75rem; max-width: var(--measure); text-wrap: pretty; }

/* Post and page */
.entry { display: grid; grid-template-columns: [gutter text] minmax(0, 1fr) [g-end t-end wide-end]; align-content: start; }
.entry > * { grid-column: text / t-end; min-width: 0; }
.entry > h1 { grid-column: text / wide-end; }
.side { margin-bottom: 2.5rem; }

.record { margin: 0; background: var(--slip); border: var(--frame); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); font-family: var(--font-display); }
.record > div { padding: 0.55rem 0.75rem 0.6rem; border-top: var(--cell); border-left: var(--cell); }
.record > div:nth-child(-n+2) { border-top: 0; }
.record > div:nth-child(odd) { border-left: 0; }
.record dt { font-size: var(--label); font-weight: 700; line-height: 1.4; }
.record dd { margin: 0.15rem 0 0; font-size: var(--cell-size); line-height: 1.5; }
.record a:hover { background: var(--ground); }
.record dd a { display: inline-block; min-width: 2.75rem; padding-block: 0.7rem; margin-block: -0.7rem; }
.record-short { grid-template-columns: minmax(0, 1fr); max-width: 16rem; }

.toc { margin-top: 1.25rem; font-family: var(--font-display); }
.toc-head { margin: 0 0 0.35rem; font-size: var(--label); font-weight: 700; line-height: 1.4; }
.toc ol { list-style: none; margin: 0; padding: 0; border-top: var(--frame); border-bottom: var(--cell); }
.toc li + li { border-top: var(--cell); }
.toc a { display: block; padding: 0.75rem 0; font-size: 0.875rem; line-height: 1.5; text-decoration: none; }

/* The body shares the article's columns, so the measure is resolved once, in the text face, and tables may run wide. */
.body { display: grid; grid-template-columns: subgrid; align-content: start; }
.body > * { grid-column: text / t-end; min-width: 0; margin-block: 0; }
.body > table { grid-column: text / wide-end; }
.body > * + * { margin-top: 1.15em; }
.body p { text-wrap: pretty; }
.body h2 { font-size: var(--h2); line-height: 1.45; letter-spacing: -0.015em; background: var(--head); padding: 0.5rem 0.8rem 0.55rem; margin-top: 2.75rem; }
.body h2 + * { margin-top: 1.1rem; }
.body h3 { font-size: 1.0625rem; line-height: 1.5; margin-top: 2rem; }
.body h3 + * { margin-top: 0.5rem; }
.body ul, .body ol { padding-left: 1.35em; }
.body li + li { margin-top: 0.4em; }
.body li::marker { font-family: var(--font-ui); }
.body strong { font-weight: 700; }
.body blockquote { margin-inline: 0; padding: 0.9rem 1.1rem; background: var(--slip); }
.body blockquote > * { margin: 0; }
.body blockquote > * + * { margin-top: 0.8em; }
.body hr { border: 0; border-top: var(--frame); margin-block: 2.5rem; }
.body img { max-width: 100%; height: auto; }
.body code { font-family: var(--font-ui); font-size: 0.9em; }

/* Tables: every cell ruled, a heavy frame, a shaded head row; they scroll inside their own frame. */
.body table, .register {
  border-collapse: collapse; border: var(--frame); font-family: var(--font-display); font-size: var(--cell-size); line-height: 1.6;
}
.body table { display: block; width: max-content; max-width: 100%; overflow-x: auto; }
.body th, .body td, .register th, .register td { border: var(--cell); padding: 0.55rem 0.75rem 0.6rem; text-align: left; vertical-align: top; }
.body th, .body td { min-width: 7.5rem; max-width: 22rem; }
.body thead th, .register thead th { background: var(--head); font-size: var(--label); font-weight: 700; line-height: 1.4; border-bottom: var(--frame); }
.body tbody td:first-child { font-weight: 700; }
.sheet { overflow-x: auto; max-width: 100%; }
.register { width: 100%; }

/* Fixed sections of the form: answers, sources, related. Headings carry the register's corner brackets. */
.answers, .refs, .related { margin-top: 3.25rem; }
.answers h2, .refs h2, .related h2, .listing > h2, .classes > h2 {
  font-size: 1rem; line-height: 1.4; letter-spacing: 0; margin: 0 0 0.75rem;
}
.answers h2::before, .refs h2::before, .related h2::before, .listing > h2::before, .classes > h2::before { content: "【 " / ""; }
.answers h2::after, .refs h2::after, .related h2::after, .listing > h2::after, .classes > h2::after { content: " 】" / ""; }

.answers details { border-bottom: var(--cell); }
.answers details:first-of-type { border-top: var(--frame); }
.answers summary { cursor: pointer; padding: 0.7rem 0; font-family: var(--font-display); font-weight: 700; line-height: 1.55; }
.answers summary::marker { color: var(--ink); }
.answers details p { margin: 0 0 0.9rem; }

.refs .register td { font-size: 0.875rem; }
.refs .c-no { width: 3.25rem; text-align: right; }
.refs .c-date { width: 9.5rem; }
.refs td.c-date { white-space: nowrap; }
.refs .pub { display: block; font-weight: 700; }
.refs .register a { word-break: normal; }

.related ul { list-style: none; margin: 0; padding: 0; border-top: var(--frame); font-family: var(--font-display); }
.related li { border-bottom: var(--cell); }
.related a { display: block; padding: 0.6rem 0; line-height: 1.55; text-decoration: none; }

/* The end of the record. */
.entry::after {
  content: "이하여백" / ""; grid-column: text / t-end; display: block; margin-top: 3.5rem; padding-top: 0.6rem;
  border-top: var(--frame); text-align: center; font: 400 var(--label)/1.4 var(--font-display); letter-spacing: 0.5em;
}

/* Home, archive and topic lists */
.opening { margin-bottom: 2.5rem; }
.opening > :last-child { margin-bottom: 0; }
.opening h1 { margin-bottom: 0.9rem; }
.front-note { max-width: var(--measure); margin: 0; }
.front-note > a { display: inline-block; padding-block: 0.6rem; }
.home-title { font-size: var(--h1-home); }

.listing, .classes { margin-bottom: 3.25rem; }
.rows { list-style: none; margin: 0; padding: 0; border-top: var(--frame); border-bottom: var(--frame); }
.rows li { display: grid; grid-template-columns: minmax(0, 1fr); padding: 0.9rem 0 1rem; }
.rows li + li { border-top: var(--cell); }
.row-title { order: 2; margin: 0; font-size: 1.125rem; line-height: 1.45; letter-spacing: -0.015em; max-width: 34em; }
.row-title a { text-decoration: none; }
.row-title a:hover { text-decoration: underline; text-decoration-color: var(--accent); }
.row-lead { order: 3; margin: 0.35rem 0 0; font-size: 0.9375rem; line-height: 1.75; max-width: var(--measure); }
.row-meta { order: 1; margin: 0 0 0.3rem; font-family: var(--font-display); font-size: var(--label); line-height: 1.5; display: flex; flex-wrap: wrap; gap: 0 1rem; }
.row-class { font-weight: 700; display: inline-block; min-width: 2.75rem; padding-block: 0.8rem; margin-block: -0.8rem; }
.register-classes th[scope="row"] { font-weight: 700; white-space: nowrap; padding: 0; }
.register-classes th[scope="row"] a { display: block; padding: 0.7rem 0.75rem; }
.register-classes .c-count { width: 5.5rem; text-align: right; }
.register-classes td { font-family: var(--font-text); font-size: 0.9375rem; line-height: 1.7; }
.register-classes td.c-count { font-family: var(--font-ui); }

/* Footer: an olive buff slip across the bottom. */
.foot { background: var(--slip); font-family: var(--font-display); font-size: 0.875rem; line-height: 1.6; padding: 1.4rem max(var(--edge), (100% - var(--sheet)) / 2) 2.25rem; }
.foot-note { margin: 0 0 0.6rem; max-width: var(--measure); }
.foot-links { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 1rem 1.4rem; }
.foot a:hover { background: var(--ground); }
.foot-links a { display: inline-block; padding: 0.8rem 0.6rem; margin: -0.8rem -0.6rem; }

/* Wide screens: the label column opens on the left and the record box and contents stay beside the text. */
@media (min-width: 64rem) {
  main, .entry {
    grid-template-columns: [gutter] var(--gutter) [g-end] var(--gap) [text] minmax(0, var(--measure)) [t-end] minmax(0, 1fr) [wide-end];
  }
  main > .opening { grid-column: text / wide-end; }
  .entry { grid-template-rows: repeat(7, auto); }
  .entry > h1 { grid-row: 1; }
  .entry > .summary { grid-row: 2; }
  .side { grid-column: gutter / g-end; grid-row: 1 / -1; align-self: start; position: sticky; top: 1.25rem; max-height: calc(100vh - 2.5rem); overflow-y: auto; margin: 0.35rem 0 0; }
  .entry > .body { grid-column: text / wide-end; grid-row: 3; }
  .entry > .answers { grid-row: 4; }
  .entry > .refs { grid-column: text / wide-end; grid-row: 5; }
  .entry > .related { grid-row: 6; }
  .entry::after { grid-row: 7; }
  .record { grid-template-columns: minmax(0, 1fr); }
  .record > div { border-left: 0; }
  .record > div:nth-child(2) { border-top: var(--cell); }
  .record-short { max-width: none; }

  .listing, .classes { display: grid; grid-template-columns: subgrid; }
  .listing > h2, .classes > h2 { grid-column: gutter / g-end; margin-top: 0.85rem; }
  .listing > .rows, .classes > .sheet { grid-column: text / wide-end; }
  .rows li { grid-template-columns: 9.5rem minmax(0, 1fr); column-gap: 1.5rem; }
  .row-meta { grid-column: 1; grid-row: 1 / span 2; flex-direction: column; margin: 0.2rem 0 0; }
  .row-title { grid-column: 2; grid-row: 1; }
  .row-lead { grid-column: 2; grid-row: 2; }
}

@media (max-width: 40rem) {
  .mast-line { padding-block: 0.75rem 0.7rem; }
  .mast-links { margin-left: 0; gap: 0.2rem 1.1rem; }
  .mast-topics ul { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .mast-topics a { flex-direction: column; gap: 0; padding: 0.4rem 0.55rem 0.45rem; font-size: 0.8125rem; }
  .refs .c-no { width: 2.25rem; padding-inline: 0.4rem 0.5rem; }
  .refs .c-date { width: 6.25rem; }
  .refs td.c-date { white-space: normal; }
  .register th, .register td { padding-inline: 0.55rem; }
  .register-classes .c-count { width: 3.25rem; }
  .register-classes td { line-height: 1.65; }
}

@media print {
  .mast, .foot, .toc, .related { display: none; }
  body { display: block; background: #fff; }
  .side { position: static; }
}
