/* Cymatic Plate: a leaf of Chladni's figure table. Laid paper, sepia copperplate ink, a brass plate. */
@font-face { font-family: "IM Fell English"; src: url("fonts/im-fell-english.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url("fonts/atkinson-400.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Atkinson Hyperlegible"; src: url("fonts/atkinson-700.ttf") format("truetype"); font-weight: 700; font-display: swap; }

:root {
  --paper: #E8DFC8;
  --ink: #3B2A1E;
  --cream: #F3ECDA;
  --madder: #B3312A;
  --pl-font: "Atkinson Hyperlegible", system-ui, sans-serif;
  --pl-topbar-bg: #E8DFC8;
  --pl-topbar-text: #3B2A1E;
  --pl-control-text: #3B2A1E;
  --pl-control-bg: #F3ECDA;
  --pl-control-border: #3B2A1E;
  --pl-focus: #B3312A;
  --pl-overlay: rgb(59 42 30 / .55);
  --pl-card-bg: #F3ECDA;
  --pl-card-text: #3B2A1E;
  --pl-card-muted: #3B2A1E;
  --pl-card-border: #3B2A1E;
  --pl-primary: #3B2A1E;
  --pl-primary-text: #F3ECDA;
  --pl-shadow: rgb(59 42 30 / .35);
  --pl-share-bg: #F3ECDA;
  --pl-radius-control: 2px;
  --pl-radius-card: 2px;
  --pl-radius-picture: 0;
  font-family: var(--pl-font);
  color: var(--ink);
  background: var(--paper);
}

body {
  color: var(--ink);
  background:
    repeating-linear-gradient(90deg, rgb(59 42 30 / .06) 0 1px, transparent 1px 28px),
    repeating-linear-gradient(0deg, rgb(255 250 235 / .10) 0 1px, transparent 1px 3px),
    var(--paper);
}

/* top bar on the same paper, a sepia hairline under it */
[data-pl="topbar"] { box-shadow: 0 1px 0 rgb(59 42 30 / .55); background: var(--paper); }
[data-pl="back"] { font-weight: 700; }

/* buttons: cream with a sepia frame and an inner rule; pressed drops the rule */
button {
  border: 1.5px solid var(--ink);
  border-radius: 2px;
  background: var(--cream);
  color: var(--ink);
  box-shadow: inset 0 0 0 2px var(--cream), inset 0 0 0 3px rgb(59 42 30 / .5);
  font-family: var(--pl-font);
  font-weight: 700;
}
button:active { box-shadow: none; transform: translateY(1px); }
button:focus-visible, a:focus-visible { outline-color: var(--madder); }
.pl-topbar__actions button { box-shadow: none; }
.primary-button { background: var(--ink); border-color: var(--ink); color: var(--cream); box-shadow: inset 0 0 0 2px var(--ink), inset 0 0 0 3px rgb(243 236 218 / .55); }
.primary-button:active { box-shadow: none; }
#reset-button.spent { outline: 2px solid var(--ink); outline-offset: 3px; }

.shell { padding-top: calc(62px + env(safe-area-inset-top)); }
#play-screen { padding-top: 4px; }
.level-row { align-items: baseline; padding: 0 4px 6px; }
.level-name { font-family: "IM Fell English", Georgia, serif; font-weight: 400; font-size: 21px; letter-spacing: .01em; }
.move-count { color: rgb(59 42 30 / .75); }
.instruction:empty { display: none; }

/* the pressed plate-mark round the board */
.board-shell {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: inset 0 0 0 1px rgb(59 42 30 / .30), inset 2px 2px 0 rgb(59 42 30 / .10), inset -2px -2px 0 rgb(255 250 235 / .45);
  padding: 6px;
}
#board { position: relative; }

/* the shell's emoji hand and confetti are replaced by drawn ones */
#hand-demo, #hand-demo span, #success-effect { display: none !important; }

.message { min-height: 1.4em; margin: 8px 5px 2px; color: var(--ink); text-align: center; }
.message.refused { color: var(--madder); }
.controls { padding-top: 4px; }

/* result: a small book leaf */
.result-card {
  position: relative;
  border: 1.5px solid var(--ink);
  border-radius: 0;
  background: var(--cream);
  box-shadow: inset 0 0 0 4px var(--cream), inset 0 0 0 5px rgb(59 42 30 / .45), 0 6px 18px rgb(59 42 30 / .2);
  animation: leaf-in .45s ease-out var(--solve-delay, .75s) both;
}
@keyframes leaf-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes leaf-show { from { opacity: 0; } to { opacity: 1; } }
/* reduced motion: no travel; the card still waits for the plate's 3/4 frame, then appears */
.reduced-motion .result-card { animation: leaf-show .01s linear var(--solve-delay, 0s) both; }
@media (prefers-reduced-motion: reduce) { .result-card { animation: leaf-show .01s linear var(--solve-delay, 0s) both; } }
.result-title { font-family: "IM Fell English", Georgia, serif; font-weight: 400; color: var(--ink); font-size: 26px; }
.result-marks { font-variant-numeric: tabular-nums; }
.share-line { color: rgb(59 42 30 / .8); }
.leaf-figs { display: flex; justify-content: center; margin: 0 0 14px; }
.leaf-figs canvas { display: block; max-width: 100%; height: auto; }
#play-screen:has(#result-screen:not([hidden])) .controls,
#play-screen:has(#result-screen:not([hidden])) .message { display: none; }

/* levels: a shelf of plates, each standing on its foot; a solved plate keeps its figure in sand */
.map-heading h1 { font-family: "IM Fell English", Georgia, serif; font-weight: 400; letter-spacing: 0; }
.eyebrow { color: rgb(59 42 30 / .7); }
.level-tile { border-radius: 0; text-align: left; }
.level-tile strong { font-family: "IM Fell English", Georgia, serif; font-weight: 400; font-size: 15px; line-height: 1.2; }
.level-tile small { color: rgb(59 42 30 / .75); }
.level-tile.complete { border-color: var(--ink); background: #EDE3C9; }
.level-map:has(.shelf) { column-gap: 0; row-gap: 20px; }
.level-tile.shelf, .level-tile.shelf.complete { display: flex; flex-direction: column; align-items: center; min-height: 0; padding: 0 0 6px; border: 0; background: transparent; box-shadow: none; text-align: center; }
.level-tile.shelf:active { transform: none; }
.level-tile.shelf:active canvas { transform: translateY(2px); }
.shelf-slot { position: relative; display: block; width: 100%; padding-bottom: 9px; isolation: isolate; }
.shelf-slot canvas { position: relative; display: block; width: min(100%, 140px); height: auto; aspect-ratio: 120 / 108; margin: 0 auto; }
/* the plank: a lit top face the foot stands on, a darker front edge, an ink rule under it */
.shelf-slot::before {
  content: ""; position: absolute; z-index: -1; left: 0; right: 0; bottom: 0; height: 21px;
  background: linear-gradient(#D9C79F 0 11px, #8C6C3E 11px 19px, var(--ink) 19px 20px, rgb(59 42 30 / .18) 20px 21px);
}
.level-tile.shelf strong { margin-top: 6px; padding: 0 4px; font-size: 14px; }
.level-tile.shelf small { padding: 0 4px; }
.level-tile.shelf:disabled { opacity: 1; }
.level-tile.shelf:disabled canvas { opacity: .38; }
.level-tile.shelf:disabled strong, .level-tile.shelf:disabled small { opacity: .5; }

/* the rules card wears the leaf too */
[data-pl="howto-card"] { box-shadow: inset 0 0 0 4px var(--cream), inset 0 0 0 5px rgb(59 42 30 / .45), 0 18px 54px var(--pl-shadow); }
[data-pl="howto-card"] h2 { font-family: "IM Fell English", Georgia, serif; font-weight: 400; font-size: 27px; }
[data-pl="howto-lines"] { font-weight: 400; font-size: 15px; }
[data-pl="howto-card"] { padding: 18px 14px; }
[data-pl="howto-pictures"] { gap: 6px; }
[data-pl="howto-pictures"] canvas { background: var(--paper); width: min(calc((100vw - 74px) / 3), 140px); min-width: 80px; }
/* the opening scene: one picture the full width of the card */
[data-pl="howto-pictures"] canvas.opening { width: min(calc(100vw - 62px), 400px); max-width: 100%; height: auto; aspect-ratio: 330 / 240; }
@media (max-width: 340px) {
  [data-pl="howto-card"] { padding: 16px 14px; }
  [data-pl="howto-pictures"] { gap: 4px; }
}
.move-count { display: none; }
/* the first-visit card sits low so the plate shows above it */
[data-pl="howto-layer"] { place-items: end center; }

/* the win: the board steps back so the card fits on the screen; the share line is for sharing only */
.board-shell { margin: 0 auto; transition: width .3s ease .55s; }
.reduced-motion .board-shell { transition: none; }
@media (prefers-reduced-motion: reduce) { .board-shell { transition: none; } }
.share-line { display: none; }
.result-card { padding: 14px 12px 12px; }
.result-marks[hidden] { display: none; }
.result-actions button[hidden] { display: none; }

/* Why? a closed fold under the board */
.why { margin: 4px 6px 0; color: var(--ink); font-size: 13px; line-height: 1.45; }
.why summary { display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px; cursor: pointer; font-family: "IM Fell English", Georgia, serif; font-size: 17px; }
.why p { margin: 0 4px 8px; }
.why summary::-webkit-details-marker { display: none; }
.why summary::before { content: "+"; display: inline-block; width: 1em; font-family: var(--pl-font); }
.why[open] summary::before { content: "\2212"; }
#play-screen:has(#result-screen:not([hidden])) .why { margin-top: 0; }

/* How to play shows its word from 360 px: the three controls tighten to fit the right half of the bar */
@media (min-width: 360px) and (max-width: 430px) {
  .pl-topbar__inner { padding: 0 8px; }
  .pl-topbar__actions { gap: 2px; }
  .pl-topbar__actions button { padding: 6px 3px; font-size: 12.5px; letter-spacing: -.005em; }
}

/* the game's own logo and title, top-left (house rule 22) */
[data-pl="back"][data-brand] { display: inline-flex; align-items: center; gap: 8px; font-family: 'IM Fell English', Georgia, serif; font-size: 18px; font-weight: 400; background: none; border: 0; box-shadow: none; cursor: pointer; padding: 6px 8px 6px 4px; }
[data-pl="back"][data-brand] .pl-brand-logo { flex: none; }
@media (max-width: 359px) { [data-pl="back"][data-brand] .pl-brand-title { font-size: 15px; } .pl-brand-logo { width: 20px; height: 20px; } }

/* Accessible play sizes (taste/ACCESSIBLE_PLAY.md): body and buttons 20, HUD 24, title 28, fine print 14. */
.instruction { font-size: 20px; line-height: 1.45; }
.level-name { font-size: 28px; line-height: 1.2; }
.endless-bar { font-size: 20px; }
.endless-bar strong { font-size: 24px; }
.controls button { font-size: 20px; min-height: 44px; }
.why { font-size: 14px; }
.endless-bar[hidden], .load-bar[hidden] { display: none; }
.load-cue { min-height: 0; }
.controls { gap: 6px; }
.controls button { min-width: 0; padding-inline: 10px; }

/* one screen (P1FS14): one row of every-move controls; Reset and Why? live behind More */
.controls { display: grid; grid-template-columns: auto 1fr auto; gap: 6px; }
#listen-button { grid-column: 1; } #ring-button, #reset-button { grid-column: 2; } #undo-button { grid-column: 3; }
#listen-button, #undo-button, #ring-button, #reset-button { grid-row: 1; }
.controls button { min-width: 0; padding-left: 8px; padding-right: 8px; white-space: nowrap; }
.controls button[hidden], #ring-button[hidden] { display: none; }
.more-sheet { position: fixed; inset: auto 0 0 0; z-index: 40; max-height: 62dvh; overflow-y: auto; overscroll-behavior: contain; padding: 10px 14px calc(14px + env(safe-area-inset-bottom)); border-top: 2px solid var(--ink); background: var(--cream, #F4ECD8); box-shadow: 0 -10px 30px rgb(59 42 30 / .22); }
.more-sheet[hidden] { display: none; }
.more-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
#app.shell { padding-bottom: calc(6px + env(safe-area-inset-bottom)); }
#play-screen .instruction { margin-top: 6px; margin-bottom: 6px; }
#play-screen .controls { padding: 4px 0 4px; }
.status-row { display: flex; align-items: center; gap: 6px; min-height: 44px; }
.status-row .message { flex: 1; margin: 0; }
#more-button { flex: none; border: 1px solid var(--ink); background: transparent; color: var(--ink); font-weight: 750; font-size: 15px; }
#play-screen:has(#result-screen:not([hidden])) .status-row { display: none; }
/* the board takes what is left: width follows the screen height (cells stay above the 44 px floor) */
#play-screen .board-shell { width: min(100%, calc((100dvh - 265px) * .837)); }
