/* Kilnhollow — linocut print identity: glaze blue-grey, terracotta, ochre, slate, ink. Bitter + Karla (self-hosted, OFL). */
@font-face { font-family: "Bitter"; src: url("../fonts/bitter-latin.woff2") format("woff2"); font-weight: 400 800; font-style: normal; font-display: swap; }
@font-face { font-family: "Karla"; src: url("../fonts/karla-latin.woff2") format("woff2"); font-weight: 400 800; font-style: normal; font-display: swap; }

:root {
  --glaze: #d9e6ee;
  --paper: #faf7f1;
  --terra: #b8532f;
  --terra-d: #8e3a1d;
  --ochre: #d9a43c;
  --slate: #5d7282;
  --moss: #6d8f55;
  --ink: #2a2320;
  --soft: #4a403b;
  --wall: #d9e6ee;
  --accent: #b8532f;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
html[data-palette="ochre"] { --wall: #f1e2bd; --accent: #b8532f; --tintc: rgba(217,164,60,.28); }
html[data-palette="slate"] { --wall: #d9e6ee; --accent: #3f5566; --tintc: rgba(93,114,130,.30); }
html[data-palette="birch"] { --wall: #ede8df; --accent: #6d5a3c; --tintc: rgba(250,247,241,.30); }

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  font-family: "Karla", system-ui, sans-serif; font-size: 16px; color: var(--ink);
  background: var(--ink);
  background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.05) 0 2px, transparent 2px 14px);
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
img { display: block; max-width: 100%; }

:focus { outline: 3px solid var(--ink); outline-offset: 3px; }
h1[tabindex="-1"]:focus-visible, h2[tabindex="-1"]:focus-visible { outline: 3px dashed var(--terra); outline-offset: 4px; }
h1[tabindex="-1"]:focus:not(:focus-visible), h2[tabindex="-1"]:focus:not(:focus-visible) { outline: none; }

#app { height: 100%; max-width: 460px; margin: 0 auto; position: relative; background: var(--wall); overflow: hidden; }
.screen { position: absolute; inset: 0; display: none; flex-direction: column; background: var(--wall); overflow: hidden; }
.screen.active { display: flex; }
.screen.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; }

h1, h2, .bar-title { font-family: "Bitter", Georgia, serif; font-weight: 800; letter-spacing: -0.01em; }
h1 { font-size: 44px; line-height: 1.02; }
h2 { font-size: 28px; line-height: 1.12; }
.kicker { font-size: 14px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--terra-d); }
.lede { font-size: 18px; line-height: 1.5; color: var(--soft); margin: 10px 0 18px; }
.story { font-size: 17px; line-height: 1.6; color: var(--soft); margin: 8px 0 16px; }
.note { font-size: 15px; line-height: 1.5; color: var(--soft); margin: 10px 0; }

/* Print frame for every picture: ink border + hard offset shadow */
.print { margin: calc(14px + var(--safe-t)) 18px 0; border: 3px solid var(--ink); box-shadow: 6px 6px 0 var(--ink); background: var(--paper); flex: 0 0 auto; position: relative; overflow: hidden; }
.bar + .print { margin-top: 10px; }
.print img { width: 100%; height: 100%; object-fit: cover; }
.print-tall { height: 44vh; min-height: 240px; max-height: 440px; }
.print-mid { height: 30vh; min-height: 180px; max-height: 300px; }
.tint { position: absolute; inset: 0; background: var(--tintc, transparent); mix-blend-mode: multiply; pointer-events: none; }

.page { padding: 18px 22px calc(22px + var(--safe-b)); display: flex; flex-direction: column; }
.title-page h1 { margin-top: 6px; }
.brand { display: flex; align-items: center; gap: 10px; }
.mark { width: 44px; height: 44px; }

.btn { min-height: 52px; padding: 12px 18px; font-size: 18px; font-weight: 800; border: 3px solid var(--ink); background: var(--paper); box-shadow: 4px 4px 0 var(--ink); margin: 6px 0; transition: transform .06s; }
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.line { background: var(--paper); }
.btn.back { min-height: 44px; padding: 6px 12px; font-size: 16px; box-shadow: 3px 3px 0 var(--ink); margin: 0; }
.row2 { display: flex; gap: 12px; }
.row2 .btn { flex: 1 1 0; min-width: 0; font-size: 16px; }
.link-btn { min-height: 44px; padding: 8px 4px; font-size: 16px; font-weight: 800; text-decoration: underline; text-underline-offset: 3px; }
.foot { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 14px; padding-top: 10px; border-top: 3px solid var(--ink); font-size: 15px; color: var(--soft); }
.panel { background: var(--paper); border: 3px solid var(--ink); box-shadow: 5px 5px 0 var(--ink); padding: 16px; margin: 12px 0; }
.panel p { font-size: 16px; line-height: 1.5; margin-top: 6px; }
.panel strong { font-family: "Bitter", Georgia, serif; font-size: 18px; }
.confirm .row2 { margin-top: 10px; }
.text-link { display: inline-flex; align-items: center; min-height: 44px; font-size: 17px; font-weight: 700; color: var(--terra-d); }

.bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: calc(10px + var(--safe-t)) 14px 10px; background: var(--paper); border-bottom: 3px solid var(--ink); flex: 0 0 auto; }
.bar-title { font-size: 19px; }
.bar-gap { width: 70px; }
.bar-mid { display: flex; flex-direction: column; align-items: center; }
.bar-sub { font-size: 15px; font-weight: 700; color: var(--soft); }

/* Story page with a drop cap */
.story-text p { font-size: 18px; line-height: 1.6; color: var(--soft); margin: 10px 0; }
.story-text p:first-child::first-letter { float: left; font-family: "Bitter", Georgia, serif; font-weight: 800; font-size: 62px; line-height: .86; padding: 6px 10px 0 0; color: var(--terra); }
.story-text p.aside { font-size: 16px; font-weight: 700; color: var(--ink); border-left: 5px solid var(--ochre); padding-left: 12px; }
#stepTitle { margin-top: 4px; }

/* Bench */
.energy { display: flex; align-items: center; gap: 4px; min-width: 70px; justify-content: flex-end; font-weight: 800; font-size: 18px; }
.energy svg { width: 24px; height: 24px; }
.orders { display: flex; gap: 8px; padding: 10px 12px 4px; flex: 0 0 auto; }
.order { flex: 1 1 0; min-width: 0; min-height: 92px; background: var(--paper); border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--ink); padding: 6px 6px 4px; text-align: left; display: flex; flex-direction: column; gap: 2px; }
.order.ready { background: #fff3d6; box-shadow: 3px 3px 0 var(--terra); border-color: var(--terra-d); }
.order .who { font-weight: 800; font-size: 15px; line-height: 1.1; overflow-wrap: anywhere; }
.order .ask { font-size: 14px; line-height: 1.2; color: var(--soft); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.order .need { display: flex; gap: 3px; margin-top: auto; }
.order .need span { width: 30px; height: 30px; border: 2px solid var(--ink); background: #fff; opacity: .55; display: grid; place-items: center; }
.order .need span.have { opacity: 1; background: #e6f0d6; }
.order .need svg { width: 24px; height: 24px; }
.order .ready-tag { font-size: 14px; font-weight: 800; color: var(--terra-d); }
.board-wrap { flex: 1 1 auto; display: flex; align-items: center; justify-content: center; padding: 6px 12px; min-height: 0; }
.board { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; width: min(100%, 52vh, 430px); background: var(--ink); border: 3px solid var(--ink); box-shadow: 5px 5px 0 var(--slate); padding: 4px; }
.cell { aspect-ratio: 1 / 1.06; background: var(--paper); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; position: relative; min-width: 0; padding: 2px 1px; }
.cell .ic { display: block; width: 66%; aspect-ratio: 1; }
.cell .ic svg { display: block; width: 100%; height: 100%; }
.cell .lvl { font-size: 14px; font-weight: 700; line-height: 1.05; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.cell.empty { background: #efe9dd; }
.cell.gen { background: #e3ecf2; }
.cell.gen .lvl { font-weight: 800; }
.cell.sel { background: #fff3d6; box-shadow: inset 0 0 0 4px var(--terra); }
.cell.pair { box-shadow: inset 0 0 0 4px var(--moss); }
.cell.pulse { animation: pulse .35s ease-out; }
@keyframes pulse { 0% { transform: scale(.84); } 100% { transform: scale(1); } }
.cell:focus { outline: 3px solid var(--ochre); outline-offset: 0; box-shadow: 0 0 0 6px var(--ink); z-index: 3; }
.cell.sel:focus { box-shadow: inset 0 0 0 4px var(--terra), 0 0 0 6px var(--ink); }
.dock { padding: 4px 14px calc(10px + var(--safe-b)); flex: 0 0 auto; }
.hint.flash { animation: flash .9s ease-out; }
@keyframes flash { 0% { background: #fff3d6; box-shadow: 0 0 0 3px var(--ochre); } 100% { background: transparent; box-shadow: 0 0 0 3px transparent; } }
.hint { padding: 4px 6px; font-size: 16px; line-height: 1.35; min-height: 44px; color: var(--soft); }

/* Showroom palettes */
.palettes { display: flex; flex-direction: column; gap: 10px; }
.palette { display: flex; align-items: center; gap: 14px; min-height: 64px; padding: 10px 12px; text-align: left; background: var(--paper); border: 3px solid var(--ink); box-shadow: 4px 4px 0 var(--ink); }
.palette[aria-checked="true"] { box-shadow: 4px 4px 0 var(--terra); border-color: var(--terra-d); background: #fff3d6; }
.palette .sw { width: 44px; height: 44px; border: 3px solid var(--ink); flex: 0 0 auto; }
.palette .pt { display: flex; flex-direction: column; }
.palette .pn { font-family: "Bitter", Georgia, serif; font-weight: 800; font-size: 18px; }
.palette .pc { font-size: 15px; color: var(--soft); }
.palette .on { margin-left: auto; font-size: 14px; font-weight: 800; color: var(--terra-d); }

/* Gate */
.q { display: block; font-family: "Bitter", Georgia, serif; font-weight: 800; font-size: 22px; margin-bottom: 10px; }
.q-row { display: flex; gap: 10px; }
.q-row input { flex: 1 1 auto; min-width: 0; min-height: 52px; font-size: 22px; padding: 8px 12px; border: 3px solid var(--ink); background: #fff; }
.q-go { margin: 0; }

.toast { position: absolute; left: 50%; top: calc(64px + var(--safe-t)); transform: translateX(-50%); z-index: 20; background: var(--ink); color: var(--paper); font-weight: 800; font-size: 16px; padding: 10px 16px; border: 3px solid var(--paper); box-shadow: 4px 4px 0 var(--terra); max-width: 86%; text-align: center; pointer-events: none; }

/* Desktop: print on the left, page on the right */
@media (min-width: 900px) {
  #app { max-width: 1080px; margin: 24px auto; height: calc(100% - 48px); border: 3px solid var(--ink); box-shadow: 10px 10px 0 var(--terra); }
  #title.active, #step.active, #ending.active, #showroom.active { display: grid; grid-template-columns: 1.1fr 1fr; grid-template-rows: auto 1fr; align-content: start; }
  #title .print, #ending .print { grid-row: 1 / span 2; height: auto; max-height: none; margin: 28px; align-self: stretch; }
  #step .bar, #showroom .bar { grid-column: 1 / span 2; }
  #step .print, #showroom .print { height: auto; max-height: none; margin: 28px; align-self: stretch; }
  .page { padding: 32px 36px; max-width: 520px; }
  h1 { font-size: 56px; }
  #bench.active { display: grid; grid-template-columns: 1fr 380px; grid-template-rows: auto 1fr auto; }
  #bench .bar { grid-column: 1 / span 2; }
  #bench .board-wrap { grid-row: 2 / span 2; }
  #bench .board { width: min(100%, 72vh, 560px); }
  #bench .orders { grid-column: 2; flex-direction: column; padding: 16px 16px 0; }
  #bench .order { flex: 0 0 auto; min-height: 84px; }
  #bench .dock { grid-column: 2; padding: 12px 16px 20px; }
}
