/* 누구세요: 파란 잉크로 인쇄한 조회서에 검은 펜으로 답을 적고, 붉은 인주로 지장을 찍는다. */

:root {
  --paper: #eef1f6;
  --sheet: #fbfcfe;
  --ink: #14182b;
  --form: #2a44ad;
  --form-soft: #c5cfee;
  --muted: #566080;
  --seal: #c22d19;
  --pass: #1b7553;
  --warn: #8f5a00;

  --display: 'Hahmlet Variable', 'Noto Serif KR', 'Apple SD Gothic Neo', serif;
  --body: 'IBM Plex Sans KR', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;

  --gutter: clamp(16px, 4vw, 40px);
  --measure: 1180px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0e1224;
    --sheet: #161b33;
    --ink: #eceffa;
    --form: #a3b4ff;
    --form-soft: #2f3963;
    --muted: #9aa4c6;
    --seal: #ff6b56;
    --pass: #63d3a6;
    --warn: #f1b650;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 24px;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 1rem;
  line-height: 1.65;
  word-break: keep-all;
  overflow-wrap: break-word;
}

h1,
h2,
h3,
p,
ol,
ul,
dl,
dd {
  margin: 0;
}

ol,
ul {
  padding: 0;
  list-style: none;
}

a {
  color: var(--form);
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
  border-radius: 2px;
}

.skip {
  position: absolute;
  left: var(--gutter);
  top: -100px;
  padding: 8px 14px;
  background: var(--ink);
  color: var(--sheet);
  z-index: 10;
}

.skip:focus {
  top: 12px;
}

/* ── 머리 ── */

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 24px;
  max-width: var(--measure);
  margin: 0 auto;
  padding: 20px var(--gutter);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--seal);
  font-family: var(--display);
  font-size: 1.3125rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.brand span {
  color: var(--ink);
}

.tally {
  margin-right: auto;
  color: var(--muted);
  font-size: 0.9375rem;
}

.tally strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.top-actions {
  display: flex;
  gap: 8px;
}

.btn {
  padding: 8px 14px;
  border: 1.5px solid var(--form);
  border-radius: 6px;
  background: transparent;
  color: var(--form);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.3;
  cursor: pointer;
}

.btn:hover {
  background: color-mix(in srgb, var(--form) 10%, transparent);
}

.btn-solid {
  background: var(--form);
  color: var(--sheet);
}

.btn-solid:hover {
  background: color-mix(in srgb, var(--form) 86%, var(--ink));
}

.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--form);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* ── 본문 틀 ── */

main {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

/* ── 첫 화면: 문장과 지장 ── */

.statement {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: clamp(32px, 6vw, 88px);
  align-items: start;
  padding: clamp(24px, 5vw, 64px) 0 clamp(48px, 7vw, 96px);
}

.statement h1 {
  font-family: var(--display);
  font-size: clamp(2.5rem, 7vw, 4.5rem);
  font-weight: 800;
  line-height: 1.12;
  letter-spacing: -0.025em;
}

.story {
  margin-top: clamp(24px, 4vw, 44px);
  color: var(--form);
  font-family: var(--display);
  font-size: clamp(1.1875rem, 2.2vw, 1.625rem);
  font-weight: 500;
  line-height: 2;
}

.story p + p {
  margin-top: 0.7em;
}

.blank {
  padding: 0 0.15em 0.05em;
  border-bottom: 1.5px solid var(--form);
  color: var(--ink);
  font-weight: 700;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}

.blank:empty {
  display: inline-block;
  width: 4.5em;
  height: 1.25em;
  vertical-align: -0.2em;
  border-bottom-style: dotted;
}

.blank.is-filled {
  animation: write 320ms ease-out both;
}

.blank.is-missing {
  color: var(--muted);
  font-weight: 500;
  border-bottom-style: dotted;
}

@keyframes write {
  from {
    background: color-mix(in srgb, var(--form) 22%, transparent);
  }
  to {
    background: transparent;
  }
}

.story-foot {
  max-width: 34em;
  margin-top: clamp(24px, 3vw, 36px);
  color: var(--muted);
}

.seal-card {
  position: sticky;
  top: 24px;
  padding: 20px 22px 22px;
  border: 1px solid var(--form-soft);
  background: var(--sheet);
}

.seal-stage {
  position: relative;
  aspect-ratio: 1 / 1.08;
  margin: -4px -6px 14px;
  overflow: hidden;
}

.guilloche,
.seal-print {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.guilloche {
  color: var(--form);
  opacity: 0.3;
}

.guilloche svg {
  width: 112%;
  height: auto;
  flex: none;
}

.seal-print {
  color: var(--seal);
  mix-blend-mode: multiply;
  animation: press 520ms cubic-bezier(0.2, 0.9, 0.25, 1) both;
}

.seal-print svg {
  height: 96%;
  width: auto;
}

@keyframes press {
  from {
    opacity: 0.25;
    transform: scale(1.14) rotate(-9deg);
  }
  to {
    opacity: 0.94;
    transform: scale(1) rotate(-4deg);
  }
}

.seal-card h2 {
  color: var(--form);
  font-size: 0.9375rem;
  font-weight: 600;
}

.seal-id {
  margin-top: 2px;
  font-family: var(--mono);
  font-size: 1.3125rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  word-spacing: 0.15em;
}

.seal-note {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.9375rem;
  line-height: 1.6;
}

.seal-visit {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dotted var(--form-soft);
  font-size: 0.9375rem;
  line-height: 1.6;
}

.seal-visit:empty {
  display: none;
}

/* ── 구역 공통 ── */

.checks,
.ledger {
  padding: clamp(40px, 6vw, 72px) 0;
  border-top: 4px double var(--form);
}

.section-head h2 {
  font-family: var(--display);
  font-size: clamp(1.625rem, 3.4vw, 2.375rem);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.015em;
}

.section-lede {
  max-width: 40em;
  margin-top: 10px;
  color: var(--muted);
}

/* ── 앞뒤 확인 ── */

.check-list {
  margin-top: clamp(20px, 3vw, 32px);
  border-top: 1px solid var(--form-soft);
}

.check {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 8px 20px;
  align-items: start;
  padding: 18px 0;
  border-bottom: 1px solid var(--form-soft);
}

.stamp {
  justify-self: start;
  margin-top: 2px;
  padding: 1px 9px;
  border: 2px solid currentColor;
  border-radius: 4px;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
  transform: rotate(-3deg);
}

.is-fail .stamp {
  color: var(--seal);
  border-style: double;
  border-width: 4px;
  padding: 0 8px;
}

.is-warn .stamp {
  color: var(--warn);
}

.is-pass .stamp {
  color: var(--pass);
}

.is-none .stamp {
  color: var(--muted);
  border-style: dashed;
  border-width: 1.5px;
}

.check-body {
  max-width: 46em;
}

.check-body h3 {
  font-size: 1.0625rem;
  font-weight: 600;
  line-height: 1.45;
}

.check-body p {
  color: var(--muted);
}

.is-fail .check-body p,
.is-warn .check-body p {
  color: var(--ink);
}

.check-body details {
  margin-top: 6px;
}

.check-body summary {
  width: fit-content;
  color: var(--form);
  font-weight: 600;
  cursor: pointer;
}

.check-body details p {
  margin-top: 4px;
  padding-left: 14px;
  border-left: 2px solid var(--form-soft);
}

/* ── 읽은 값 목록 ── */

.ledger-body {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: clamp(24px, 5vw, 64px);
  margin-top: clamp(24px, 4vw, 40px);
}

.ledger-nav ul {
  position: sticky;
  top: 24px;
  display: grid;
  gap: 2px;
}

.ledger-nav a {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px dotted var(--form-soft);
  color: var(--ink);
  text-decoration: none;
}

.ledger-nav a:hover {
  color: var(--form);
}

.count {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.group + .group {
  margin-top: clamp(36px, 5vw, 56px);
}

.group-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--form);
}

.group-head h3 {
  font-family: var(--display);
  font-size: 1.3125rem;
  font-weight: 700;
}

.group-head p {
  color: var(--muted);
  font-size: 0.9375rem;
}

.row {
  display: grid;
  grid-template-columns: minmax(8rem, 13rem) minmax(0, 1fr) minmax(0, 15rem);
  gap: 4px 20px;
  padding: 10px 0;
  border-bottom: 1px dotted var(--form-soft);
}

.row dt {
  color: var(--form);
  overflow-wrap: anywhere;
}

.row-value {
  font-weight: 500;
  overflow-wrap: anywhere;
}

.row-value small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 400;
}

.row-source {
  text-align: right;
}

.row-source code {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.8125rem;
  overflow-wrap: anywhere;
}

.row.is-missing .row-value span,
.row.is-missing.is-wide dt,
.row.is-loading dt {
  color: var(--muted);
  font-weight: 400;
}

.row.is-wide,
.row.is-loading {
  grid-template-columns: 1fr;
}

/* ── 발 ── */

.foot {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(24px, 5vw, 64px);
  max-width: var(--measure);
  margin: 0 auto;
  padding: clamp(32px, 5vw, 56px) var(--gutter) 72px;
  color: var(--muted);
  font-size: 0.9375rem;
}

.foot::before {
  content: '';
  grid-column: 1 / -1;
  border-top: 4px double var(--form);
}

.foot h2 {
  margin-bottom: 8px;
  color: var(--ink);
  font-family: var(--display);
  font-size: 1.125rem;
  font-weight: 700;
}

.foot p + p {
  margin-top: 8px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  max-width: min(92vw, 30rem);
  padding: 12px 18px;
  border-radius: 6px;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.9375rem;
  opacity: 0;
  transform: translate(-50%, 12px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}

.toast.is-shown {
  opacity: 1;
  transform: translate(-50%, 0);
}

.noscript {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 24px var(--gutter);
  color: var(--seal);
}

/* ── 좁은 화면 ── */

@media (max-width: 900px) {
  .statement {
    grid-template-columns: 1fr;
  }

  .seal-card {
    position: static;
    display: grid;
    grid-template-columns: 132px minmax(0, 1fr);
    column-gap: 18px;
    align-items: start;
  }

  .seal-stage {
    grid-row: 1 / span 4;
    margin: 0;
  }

  .ledger-body {
    grid-template-columns: 1fr;
  }

  .ledger-nav ul {
    position: static;
    display: flex;
    flex-wrap: wrap;
    gap: 6px 8px;
  }

  .ledger-nav a {
    padding: 5px 12px;
    border: 1px solid var(--form-soft);
    border-radius: 999px;
    background: var(--sheet);
  }
}

@media (max-width: 640px) {
  .tally {
    order: 3;
    flex-basis: 100%;
  }

  .check {
    grid-template-columns: 1fr;
  }

  .row {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .row-source {
    text-align: left;
  }

  .foot {
    grid-template-columns: 1fr;
  }
}

@media (prefers-color-scheme: dark) {
  .seal-print {
    mix-blend-mode: normal;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .blank.is-filled,
  .seal-print {
    animation: none;
  }

  .seal-print {
    opacity: 0.94;
    transform: rotate(-4deg);
  }

  .toast {
    transition: none;
  }
}
