/* 천자문 서예실 (calligraphy) v1 — 2026-10-30. Nami prototype (docs/prototypes/calligraphy) scoped to .room. */
/* ---------- tokens ---------- */
.room {
  font: 400 1.0625rem/1.75 var(--sans); color: var(--ink);
  --hanji: #F6F1E7;        /* page: 한지 */
  --hanji-deep: #EDE5D6;   /* 서안(desk) well behind the sheet */
  --sheet: #F2ECDF;        /* placeholder paper, close to engine paper */
  --ink: #17140F;          /* kit ink, verbatim */
  --ink-soft: #4A4236;     /* body text 8.78:1 on hanji */
  --ink-faint: #6B6152;    /* meta text 5.40:1 (kit mute #7C7364 = 4.15, fails AA) */
  --rule: #D9CEBB;
  --inju: #B8322A;         /* kit seal red, verbatim. 5.29:1 on hanji */
  --inju-wash: #F3DCD6;
  --ghost: #DED4C2;        /* faint model glyph on the sheet */
  --grid: rgba(184, 50, 42, .30); /* kit 米字格 grid, verbatim */

  --serif: "Noto Serif KR", "AppleMyungjo", "Batang", "Nanum Myeongjo", serif;
  --sans: "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;

  --r-sheet: 2px;   /* paper is paper */
  --r-ctl: 10px;    /* buttons, inputs */
  --r-chip: 6px;

  --s1: .25rem; --s2: .5rem; --s3: .75rem; --s4: 1rem; --s6: 1.5rem; --s8: 2rem; --s12: 3rem; --s16: 4rem;
}

.room, .room * { box-sizing: border-box; }
.room a { color: inherit; }
.room :focus-visible { outline: 3px solid var(--inju); outline-offset: 3px; border-radius: 4px; }
.room .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }


/* ---------- room layout ---------- */
.room {
  max-width: 76rem; margin: 0 auto; padding: var(--s6) var(--s6) var(--s16);
  display: grid; grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "crumb" "head" "board" "read" "after";
  row-gap: var(--s8);
}
.room .crumb { grid-area: crumb; font-size: .9375rem; color: var(--ink-faint); }
.room .crumb ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s2); }
.room .crumb li + li::before { content: "/"; margin-right: var(--s2); color: var(--rule); }
.room .crumb a { text-decoration: none; }
.room .crumb a:hover { text-decoration: underline; }

@media (min-width: 64rem) {
  .room {
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    grid-template-areas: "crumb crumb" "board head" "board read" "after after";
    column-gap: var(--s16); row-gap: var(--s8);
  }
  .room .board-col { position: sticky; top: var(--s6); align-self: start; }
}

/* ---------- head ---------- */
.room .head { grid-area: head; }
.room .head h1 { margin: 0; display: flex; align-items: baseline; gap: var(--s4); flex-wrap: wrap; }
.room .h1-han { font: 900 3.5rem/1 var(--serif); }
.room .h1-ko { font: 600 1.625rem/1.3 var(--serif); }
.room .head__lead { margin: var(--s4) 0 0; max-width: 34em; color: var(--ink-soft); font-size: 1.125rem; }
.room .head__today { display: inline-flex; align-items: center; gap: var(--s2); margin-top: var(--s4); font-size: .9375rem; color: var(--inju); font-weight: 700; text-decoration: none; }
.room .head__today::before { content: ""; width: .5rem; height: .5rem; background: var(--inju); border-radius: 1px; }

/* ---------- board column ---------- */
.room .board-col { grid-area: board; }
.room .desk { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s4); align-items: start; }

/* 체본: the phrase as a vertical model column */
.room .chebon { list-style: none; margin: 0; padding: var(--s2) 0; display: flex; flex-direction: column; gap: var(--s1); border-right: 1px solid var(--rule); padding-right: var(--s3); }
.room .chebon a {
  display: grid; place-items: center; width: 3rem; height: 3rem; padding: 0; position: relative;
  font: 600 1.75rem/1 var(--serif); color: var(--ink-faint);
  background: none; border: 0; border-radius: var(--r-chip); cursor: pointer; text-decoration: none;
}
.room .chebon a[aria-current="true"] { color: var(--ink); background: var(--hanji-deep); }
.room .chebon a[aria-current="true"]::before { content: ""; position: absolute; left: -.6rem; top: 25%; bottom: 25%; width: 3px; background: var(--inju); border-radius: 2px; }
.room .chebon a[aria-disabled="true"] { cursor: not-allowed; color: #A79D8C; }
.room .chebon a.is-done::after { content: ""; position: absolute; right: .2rem; bottom: .2rem; width: .45rem; height: .45rem; background: var(--inju); border-radius: 1px; }
.room .chebon__seal { display: grid; place-items: center; width: 3rem; margin-top: var(--s2); font: 600 .75rem/1.3 var(--sans); color: var(--ink-faint); text-align: center; }

/* the sheet */
.room .sheet-wrap { --size: min(100%, calc(100svh - 18rem)); width: var(--size); max-width: 40rem; }
.room .sheet {
  position: relative; width: 100%; aspect-ratio: 1 / 1;
  background: var(--sheet); border-radius: var(--r-sheet);
  box-shadow: 0 0 0 1px #E2D8C6, 0 1px 0 #E2D8C6, 0 14px 30px -18px rgba(60, 45, 20, .35);
  overflow: hidden; overscroll-behavior: contain;
}
.room .sheet__grid, .room .sheet__ghost, .room .sheet__demo, .room .sheet__mount { position: absolute; inset: 0; width: 100%; height: 100%; }
.room .sheet__ghost { display: grid; place-items: center; }
.room .sheet__ghost span { font-family: var(--serif); font-weight: 400; font-size: 72cqw; line-height: 1; color: var(--ghost); }
.room .sheet { container-type: inline-size; }
.room .sheet__cta { position: absolute; inset: auto 0 9%; display: grid; justify-items: center; gap: var(--s2); padding: 0 var(--s4); }
.room .sheet__mount { display: none; }
.room .sheet[data-state="ready"] .sheet__mount, .room .sheet[data-state="complete"] .sheet__mount { display: block; }
.room .sheet[data-state="ready"] .sheet__ghost, .room .sheet[data-state="complete"] .sheet__ghost, .room .sheet[data-state="ready"] .sheet__grid, .room .sheet[data-state="complete"] .sheet__grid, .room .sheet[data-state="ready"] .sheet__cta, .room .sheet[data-state="complete"] .sheet__cta, .room .sheet[data-state="fallback"] .sheet__ghost, .room .sheet[data-state="fallback"] .sheet__cta { display: none; }
.room .sheet__demo { pointer-events: none; display: none; }
.room .sheet[data-state="fallback"] .sheet__demo, .room .sheet__demo.is-on { display: block; }

.room .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 2.75rem; padding: 0 var(--s4); border-radius: var(--r-ctl);
  font: 700 1rem/1 var(--sans); cursor: pointer; text-decoration: none;
  border: 1.5px solid var(--ink); background: transparent; color: var(--ink);
}
.room .btn:hover { background: var(--hanji-deep); }
.room .btn[disabled], .room .btn[aria-disabled="true"] { opacity: 1; color: #8E8473; border-color: #C9BEAB; cursor: not-allowed; background: transparent; }
.room .btn--ink { background: var(--ink); color: var(--hanji); }
.room .btn--ink:hover { background: #2C261D; }
.room .btn--lg { min-height: 3.25rem; padding: 0 var(--s6); font-size: 1.125rem; }
.room .sheet__hint { margin: 0; font-size: .9375rem; color: var(--ink-faint); background: rgba(242, 236, 223, .9); padding: 0 var(--s2); border-radius: 4px; }
.room .sheet[data-state="loading"] .btn--lg { cursor: progress; }

.room .status { min-height: 1.75em; margin: var(--s4) 0 0; font-weight: 700; font-size: 1.0625rem; }
.room .status.is-bad { color: var(--inju); }

.room .tools { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s3); }
.room .tools .btn { font-size: .9375rem; }
.room .tools .btn[aria-pressed="true"] { background: var(--ink); color: var(--hanji); }

.room .strokes { list-style: none; margin: var(--s4) 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); font-size: .9375rem; color: var(--ink-soft); }
.room .strokes li { display: inline-flex; align-items: baseline; gap: var(--s1); }
.room .strokes b { font: 700 .875rem/1 var(--sans); color: var(--inju); }
.room .strokes li.is-done { color: var(--ink-faint); text-decoration: line-through; text-decoration-color: var(--rule); }

.room .done { margin-top: var(--s6); padding: var(--s4) 0 0; border-top: 1px solid var(--rule); }
.room .done__score { margin: 0 0 var(--s3); font: 600 1.25rem/1.4 var(--serif); }
.room .done__score em { font-style: normal; color: var(--inju); }
.room .done__row { display: flex; flex-wrap: wrap; gap: var(--s2); }

.room .walk { display: flex; justify-content: space-between; gap: var(--s4); margin-top: var(--s6); font-size: .9375rem; }
.room .walk a, .room .walk span { display: flex; flex-direction: column; gap: 2px; text-decoration: none; color: var(--ink-faint); min-width: 0; }
.room .walk a:hover .walk__c { text-decoration: underline; }
.room .walk__c { color: var(--ink); font-weight: 700; font-size: 1rem; }
.room .walk__c span { font: 600 1.25rem/1 var(--serif); margin-right: var(--s1); }
.room .walk .is-next { text-align: right; align-items: flex-end; }

/* ---------- reading column ---------- */
.room .read { grid-area: read; font-family: var(--serif); }
.room .read section { max-width: 34em; }
.room .read section + section { margin-top: var(--s12); }
.room .read h2 { font: 600 1.375rem/1.4 var(--serif); margin: 0 0 var(--s3); }
.room .read p { margin: 0; font-size: 1.125rem; line-height: 1.9; color: var(--ink-soft); }
.room .read p + p { margin-top: var(--s3); }
.room .read .formula { font: 600 2rem/1.2 var(--serif); color: var(--ink); letter-spacing: .06em; margin-bottom: var(--s3); }
.room .phrase { display: flex; gap: var(--s3); align-items: flex-start; margin-bottom: var(--s4); }
.room .phrase a, .room .phrase span { font: 600 2.25rem/1 var(--serif); text-decoration: none; color: var(--ink-faint); padding-bottom: var(--s2); border-bottom: 2px solid transparent; }
.room .phrase .is-here { color: var(--ink); border-bottom-color: var(--inju); }
.room .phrase a:hover { color: var(--ink); }
.room .note, .room .read .note { font: 400 .875rem/1.6 var(--sans); color: var(--ink-faint); margin-top: var(--s2); }
.room .words { list-style: none; margin: 0; padding: 0; }
.room .words li { padding: var(--s3) 0; border-top: 1px solid var(--rule); }
.room .words li:last-child { border-bottom: 1px solid var(--rule); }
.room .words b { font: 600 1.25rem/1.4 var(--serif); margin-right: var(--s2); }
.room .words i { font-style: normal; font-family: var(--sans); font-size: .9375rem; color: var(--ink-faint); }
.room .read .words p { font-size: 1rem; line-height: 1.75; margin-top: var(--s1); }
.room .verse { margin: var(--s4) 0; padding-left: var(--s4); border-left: 3px solid var(--inju-wash); font-size: 1.125rem; line-height: 1.9; color: var(--ink); }
.room .verse cite { display: block; margin-top: var(--s2); font: 400 .9375rem/1.5 var(--sans); color: var(--ink-faint); font-style: normal; }
.room .read .ask { font-weight: 600; color: var(--ink); }
.room .note-form { margin-top: var(--s4); font-family: var(--sans); }
.room .note-form label { display: block; font-weight: 700; font-size: 1rem; margin-bottom: var(--s2); }
.room .note-form__row { display: flex; gap: var(--s2); flex-wrap: wrap; }
.room .note-form input {
  flex: 1 1 14rem; min-height: 2.75rem; padding: 0 var(--s3); font: 400 1.0625rem/1 var(--serif);
  color: var(--ink); background: #FFFDF8; border: 1.5px solid #C9BEAB; border-radius: var(--r-ctl);
}
.room .note-form input:focus-visible { border-color: var(--ink); }
.room .note-form__msg { min-height: 1.5em; margin: var(--s2) 0 0; font-size: .9375rem; color: var(--ink-faint); }
.room .deeper { display: inline-block; margin-top: var(--s6); font: 700 1rem/1.5 var(--sans); color: var(--ink); }

/* ---------- after: ad + 서첩 ---------- */
.room .after { grid-area: after; display: grid; gap: var(--s12); padding-top: var(--s8); border-top: 1px solid var(--rule); }
.room .ad-demo { min-height: 280px; display: grid; place-items: center; border: 1.5px dashed #C9BEAB; border-radius: var(--r-ctl); color: var(--ink-faint); font-size: .9375rem; text-align: center; padding: var(--s4); }
.room .chup h2 { font: 600 1.375rem/1.4 var(--serif); margin: 0 0 var(--s2); }
.room .chup > p { margin: 0 0 var(--s4); color: var(--ink-soft); }
.room .chup__grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: var(--s2); max-width: 40rem; }
.room .chup__gu { display: grid; gap: 2px; }
.room .chup__gu a, .room .chup__gu span {
  display: grid; place-items: center; aspect-ratio: 1; font: 400 1.25rem/1 var(--serif);
  text-decoration: none; color: var(--ink-faint); background: #FBF8F1; box-shadow: inset 0 0 0 1px var(--rule);
  border-radius: 2px;
}
.room .chup__gu .is-written { background: var(--ink); color: var(--hanji); box-shadow: none; }
.room .chup__gu .is-here { box-shadow: inset 0 0 0 2px var(--inju); color: var(--ink); }
.room .chup__legend { display: flex; gap: var(--s4); flex-wrap: wrap; margin-top: var(--s3); font-size: .875rem; color: var(--ink-faint); }
.room .chup__legend span::before { content: ""; display: inline-block; width: .75rem; height: .75rem; margin-right: var(--s1); vertical-align: -1px; box-shadow: inset 0 0 0 1px var(--rule); background: #FBF8F1; }
.room .chup__legend .k-w::before { background: var(--ink); box-shadow: none; }
.room .chup__legend .k-h::before { box-shadow: inset 0 0 0 2px var(--inju); }

/* ---------- demo / fallback SVG strokes ---------- */
.room .demo-stroke { fill: none; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 0; }
.room .demo-stroke.is-pre { stroke-dashoffset: 1; }
.room .demo-stroke.is-run { transition: stroke-dashoffset .75s cubic-bezier(.45, 0, .25, 1); }
.room .demo-num { font: 700 4.2px/1 var(--sans); fill: var(--inju); }

/* ---------- mobile ---------- */
@media (max-width: 63.99rem) {
  .room { padding: var(--s4) var(--s6) var(--s12); row-gap: var(--s6); }
  .room .h1-han { font-size: 2.75rem; }
  .room .h1-ko { font-size: 1.375rem; }
  .room .desk { grid-template-columns: minmax(0, 1fr); }
  .room .chebon { flex-direction: row; border-right: 0; padding: 0; justify-content: center; }
  .room .chebon a[aria-current="true"]::before { left: 25%; right: 25%; top: auto; bottom: -.35rem; width: auto; height: 3px; }
  .room .chebon__seal { display: none; }
  .room .sheet-wrap { --size: 100%; margin: 0 auto; }
  .room .tools .btn { flex: 1 1 calc(50% - var(--s2)); }
}
@media (prefers-reduced-motion: reduce) {
  .room .demo-stroke.is-run { transition: none; }
}
@media print {
  .room .tools, .room .sheet__cta, .room .after, .room .note-form, .room .walk { display: none; }
}
