/* Design direction: dancheong, the painted woodwork of Korean palaces and temples.
   Colours are Seoul's official colour set (seoul_color_10 sheet, Hex Code Web):
   dancheong red 941e34, Namsan green 455f54, Seoul sky 6789ca, ginkgo yellow e5b560, kkotdam ochre bc6f25, palace brown 594743.
   Patterns in ../img are drawn for this site: a lotus band and corner rings in the manner of dancheong, and a chilbo (seven treasures) ground, drawn large and faint so it stays quiet.
   Type: Noto Serif KR for reading, Chosun Gungseo (palace brush style) for the Hangul itself. */
@font-face {
  font-family: "Chosun Gungseo";
  /* the file exactly as the Chosun Ilbo distributes it (fontdown.chosun.com/100/ChosunGs.zip), not converted or subset */
  src: url("../fonts/ChosunGs.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}
:root {
  --paper: #efe7d3;      /* sambe ivory, lightened */
  --sheet: #fbf7ec;
  --ink: #2b2623;
  --soft: #594743;       /* palace brown */
  --rule: #c9bb98;
  --seal: #941e34;       /* dancheong red */
  --seal-line: #cf9aa3;
  --green: #455f54;      /* Namsan green */
  --blue: #6789ca;
  --yellow: #e5b560;
  --amber: #8a4b12;
  --focus: #23479a;
  --cell: clamp(52px, 11vw, 84px);
  --band: 48px;
  --serif: "Noto Serif KR", "Nanum Myeongjo", Georgia, serif;
  --gung: "Chosun Gungseo", "Nanum Myeongjo", "Noto Serif KR", serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; color: var(--ink); font: 400 16.5px/1.65 var(--serif); background: var(--paper) url(../img/chilbo.svg) 0 0 / 150px 150px; border-top: var(--band) solid transparent; position: relative; }
body::before { content: ""; position: absolute; left: 0; right: 0; top: calc(-1 * var(--band)); height: var(--band); background: var(--green) url(../img/dancheong-band.svg) center / 200px 48px repeat-x; }
main { max-width: 1120px; margin: 0 auto; padding: 0 16px 72px; }
.top { max-width: 1120px; margin: 0 auto; padding: 18px 16px 0; }
.brand { color: var(--ink); text-decoration: none; font-weight: 700; display: inline-flex; align-items: center; gap: 10px; background: var(--paper); padding: 2px 10px 2px 0; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; background: var(--seal); color: var(--sheet); border-radius: 50%; font: 400 18px/1 var(--gung); }

.bench { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 440px); gap: 48px; align-items: start; padding-top: 30px; }
/* the reading column sits on plain paper so the ground pattern never runs under text */
.desk, .prose { background: var(--paper); box-shadow: 0 0 0 16px var(--paper); }
h1 { font-size: clamp(30px, 4.4vw, 46px); line-height: 1.18; font-weight: 700; letter-spacing: -0.015em; margin: 0 0 10px; max-width: 18ch; }
.lead { color: var(--soft); margin: 0 0 28px; max-width: 44ch; font-size: 17.5px; }
h2 { font-size: 23px; font-weight: 700; margin: 44px 0 10px 12px; padding-left: 12px; border-left: 6px solid var(--seal); box-shadow: -6px 0 0 var(--yellow), -12px 0 0 var(--blue); }
h3 { font-size: 17.5px; font-weight: 700; margin: 22px 0 2px; }

label { display: block; font-weight: 700; font-size: 14.5px; margin-bottom: 6px; }
.hint { color: var(--soft); font-size: 14px; margin: 6px 0 0; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
input[type=text] { flex: 1 1 220px; min-width: 0; font: inherit; font-size: 18px; padding: 12px 14px; border: 1.5px solid var(--ink); border-radius: 4px; background: var(--sheet); color: var(--ink); }
input[lang=ko] { font-family: var(--gung); font-size: 21px; }
input[type=text]::placeholder { color: #8f8474; }
button { font: inherit; cursor: pointer; border-radius: 4px; border: 1.5px solid var(--rule); background: var(--sheet); color: var(--ink); padding: 9px 13px; }
button:hover { border-color: var(--ink); }
button.primary { background: var(--seal); border-color: var(--seal); color: #fff; font-weight: 700; padding: 12px 18px; }
button.primary:hover { background: #7c1529; border-color: #7c1529; }
button.wide { width: 100%; margin-top: 18px; font-size: 17.5px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.example-note { margin: 22px 0 0; color: var(--soft); font-size: 14.5px; }
.example-note[hidden] { display: none; }

/* manuscript paper: one syllable per square */
.sheet { margin: 14px 0 0; display: flex; flex-wrap: wrap; gap: 14px 22px; }
.sheet .word { display: flex; }
.sheet .cell { width: var(--cell); border: 1.5px solid var(--seal-line); margin-left: -1.5px; background: var(--sheet); }
.sheet .cell:first-child { margin-left: 0; }
.sheet .glyph { height: var(--cell); display: grid; place-items: center; font: 400 calc(var(--cell) * 0.66)/1 var(--gung); }
.sheet .sound { border-top: 1.5px solid var(--seal-line); min-height: 22px; padding: 2px 2px; text-align: center; font: 500 10.5px/1.6 system-ui, sans-serif; color: var(--soft); letter-spacing: 0.02em; overflow: hidden; white-space: nowrap; }

.words { display: grid; gap: 0; margin: 18px 0 22px; border-top: 3px double var(--ink); }
.wordrow { padding: 12px 0; border-bottom: 1px solid var(--rule); }
.wordrow .head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.wordrow .en { font-weight: 700; }
.wordrow .ko { font: 400 23px/1.2 var(--gung); }
.tier { font-size: 13.5px; font-weight: 700; }
.tier.official { color: var(--green); }
.tier.custom, .tier.sound { color: var(--soft); }
.tier.guess { color: var(--amber); }
.wordrow .why { color: var(--soft); font-size: 14.5px; margin: 2px 0 0; max-width: 60ch; }
.alts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; font-size: 14.5px; color: var(--soft); }
.alts button { padding: 4px 12px; font: 400 19px/1.3 var(--gung); }
[aria-pressed=true] { border-color: var(--ink); background: var(--ink); color: #fff; }

.edit input { width: 100%; max-width: 340px; flex: none; }

/* right column */
.maker { position: sticky; top: 16px; }
.stage { background: var(--sheet); background-clip: padding-box; border: 34px solid transparent; border-image: url(../img/frame-a.svg) 34 / 34px; aspect-ratio: 1 / 1; position: relative; padding: 0; overflow: hidden; }
/* the picture always fits inside the frame, whatever its proportions */
canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
.stage.press canvas { animation: press 260ms cubic-bezier(.2, .9, .3, 1); }
@keyframes press { from { transform: scale(1.12) rotate(-3deg); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .stage.press canvas { animation: none; } }

.controls { margin-top: 14px; background: var(--paper); box-shadow: 0 0 0 10px var(--paper); }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.tabs button { flex: 1 1 auto; padding: 8px 10px; font-size: 15px; }
.tabs + .tabs { margin-top: 8px; }
.tabs button[aria-pressed=true] { background: var(--green); border-color: var(--green); }
.fonts { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; margin-top: 12px; }
.fonts button { font-size: 22px; line-height: 1; padding: 10px 0; height: 46px; overflow: hidden; }
.fonts button:disabled { opacity: 0.32; cursor: not-allowed; text-decoration: line-through; border-color: var(--rule); }
.motifs { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 6px; margin-top: 12px; }
.motifs[hidden] { display: none; }
.motifs button { padding: 2px; aspect-ratio: 1 / 1; background: #fff; }
.motifs button[aria-pressed=true] { background: #fff; border-color: var(--seal); box-shadow: 0 0 0 1.5px var(--seal); }
.motifs canvas { position: static; width: 100%; height: 100%; }
.lastrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.swatches { display: flex; gap: 8px; }
.swatches button { width: 32px; height: 32px; padding: 0; border-radius: 50%; border: 2px solid var(--sheet); box-shadow: 0 0 0 1.5px var(--rule); }
.swatches button[aria-pressed=true] { box-shadow: 0 0 0 2.5px var(--ink); border-color: var(--sheet); }
.check { font-weight: 400; display: flex; gap: 8px; align-items: center; margin: 0; }
.check[hidden] { display: none; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 18px; }

.prose { max-width: 66ch; margin-top: 64px; }
.prose p, .prose dd { color: #3a332f; }
.prose [lang=ko] { font-family: var(--gung); font-size: 1.12em; }
.prose dt { font-weight: 700; margin-top: 14px; }
.prose dd { margin: 2px 0 0; }
.foot { background: var(--green); color: #f3ecdc; font-size: 13.5px; margin-top: 8px; border-top: 6px solid var(--ink); box-shadow: inset 0 5px 0 var(--yellow); }
.foot p { max-width: 1120px; margin: 0 auto; padding: 28px 16px 36px; }
.foot a { color: inherit; }

@media (max-width: 880px) {
  :root { --band: 36px; }
  body::before { background-size: 150px 36px; }
  .bench { grid-template-columns: 1fr; gap: 28px; padding-top: 20px; }
  .maker { position: static; }
  h1 { max-width: none; }
  .row button { flex: 1 1 100%; }
  .stage { max-width: 440px; margin: 0 auto; width: 100%; }
  .desk, .prose { box-shadow: 0 0 0 8px var(--paper); }
}
