/* Fraunces, latin subset, self-hosted so the itch embed needs no network.
   Axes: opsz 9–144, wght 400–800, SOFT 0–100, WONK 0–1. */
@font-face {
  font-family: 'Fraunces';
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url('../fonts/fraunces-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
                 U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
                 U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* Fraunces carries the voice; the plumbing stays in system sans so small
     labels and the how-to-play copy do not get heavy. */
  --display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --ui: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ink: #1b1a23;
  --paper: #f6f4ee;
  --muted: #6f6b7d;
  --line: #d9d4c8;
  --tile: #fffdf7;
  --gold: #e8c547;
  --blue: #6aa9d8;
  --good: #3f8f5f;
  --bad: #b2453c;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #f1eee6; --paper: #15141b; --muted: #9a94ab; --line: #322f3d;
    --tile: #211f2b; --good: #6fc48d; --bad: #e08078;
  }
}
:root[data-theme="dark"] {
  --ink: #f1eee6; --paper: #15141b; --muted: #9a94ab; --line: #322f3d;
  --tile: #211f2b; --good: #6fc48d; --bad: #e08078;
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 16px/1.5 var(--ui);
  -webkit-text-size-adjust: 100%;
}
.stage { max-width: 44rem; margin: 0 auto; padding: 2rem 16px 4rem; }

/* ---- the wordmark: "long" is a chunk, caught mid-drop onto "hand" ---- */
.masthead { text-align: center; margin-bottom: 2rem; }
.wordmark {
  margin: 0; display: flex; align-items: center; justify-content: center;
  font-family: var(--display); font-size: clamp(2.2rem, 9vw, 3.2rem); line-height: 1;
  font-variation-settings: 'opsz' 144, 'wght' 700, 'SOFT' 55, 'WONK' 1;
}
.wordmark .mark-chunk {
  border: 2px solid var(--blue); border-radius: 9px; background: var(--tile);
  padding: .04em .2em .08em; margin-right: .1em;
  transform: rotate(-4deg);
  box-shadow: 0 5px 14px rgba(0, 0, 0, .13);
}
.dayline { margin: .25rem 0 0; color: var(--muted); font-size: .85rem; letter-spacing: .08em; }

/* ---- the word being built ---- */
.build { margin-bottom: 2rem; }
.word-row { display: flex; align-items: stretch; justify-content: center; gap: .5rem; min-height: 5rem; }

.word {
  position: relative; overflow: hidden;
  flex: 1 1 auto; display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--line); border-radius: var(--radius); background: var(--tile);
  padding: .75rem 1rem; min-width: 0;
  font-family: var(--display);
  font-variation-settings: 'opsz' 72, 'wght' 700, 'SOFT' 40, 'WONK' 0;
  font-size: clamp(1.05rem, 5.2vw, 1.95rem); letter-spacing: .01em;
  word-break: break-all; text-align: center;
}

/* the two halves of the box are the drop targets: front on the left, back on the right */
.half {
  position: absolute; top: 0; bottom: 0; width: 50%;
  display: flex; align-items: center; padding-inline: .7rem;
  border: 0; background: none; cursor: pointer; font: inherit;
  transition: background .12s;
}
.half.pre { left: 0; justify-content: flex-start; }
.half.post { right: 0; justify-content: flex-end; }
.half:disabled { cursor: default; }
.half.over { background: color-mix(in srgb, var(--blue) 15%, transparent); }

/* the chunk rides under the cursor while dragging, so the halves need no label of their own */
.drag-ghost {
  position: fixed; z-index: 50; pointer-events: none;
  transform: translate(-50%, -50%) rotate(-2deg);
  padding: .7rem 1rem; border-radius: var(--radius);
  border: 2px solid var(--blue); background: var(--tile); color: var(--ink);
  font-family: var(--display); font-size: 1.05rem; letter-spacing: 0;
  font-variation-settings: 'opsz' 24, 'wght' 600, 'SOFT' 40, 'WONK' 0;
  box-shadow: 0 8px 20px rgba(0, 0, 0, .22);
}

/* a hairline so it reads as two halves the moment a chunk is in hand */
.word.armed::before {
  content: ''; position: absolute; left: 50%; top: 14%; bottom: 14%;
  border-left: 1px dashed var(--line); pointer-events: none;
}
.word-text { position: relative; }
/* an instruction, not a word in play — keep it in the UI face */
.word-empty {
  font-family: var(--ui); font-variation-settings: normal;
  color: var(--muted); font-weight: 400; font-size: .95rem; letter-spacing: 0;
}

/* before anything is placed the box is a waiting slot, not a preview */
.word.empty { border-style: dashed; }
.word.empty.over { border-color: var(--blue); background: color-mix(in srgb, var(--blue) 12%, transparent); }
.word .seg-first { color: var(--ink); }
.word .seg-add { color: var(--blue); }
.word.not-a-word { border-style: dashed; color: var(--muted); }
.word.bump { animation: bump .28s ease; }
@keyframes bump { 0%,100% { transform: scale(1); } 40% { transform: scale(1.045); } }

.meter { margin: .6rem 0 0; text-align: center; color: var(--muted); font-size: .85rem; min-height: 1.4em; }

/* ---- the rack ---- */
.tiles { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; }
.tile {
  font-family: var(--display); font-size: 1.05rem;
  font-variation-settings: 'opsz' 24, 'wght' 600, 'SOFT' 40, 'WONK' 0;
  padding: .7rem 1rem; border: 2px solid var(--line); border-radius: var(--radius);
  background: var(--tile); color: var(--ink); cursor: grab; touch-action: none;
  user-select: none; -webkit-user-select: none;
  transition: transform .12s, border-color .12s, box-shadow .12s, opacity .2s;
}
.tile:active:not(:disabled) { cursor: grabbing; }
.tile:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--blue); }
.tile.picked { border-color: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 28%, transparent); transform: translateY(-2px); }
.tile:disabled { opacity: .22; cursor: default; transform: none; }
.tile.dragging { opacity: .4; }
.tile.shake { animation: shake .3s; border-color: var(--bad); }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-5px)} 75%{transform:translateX(5px)} }

.say { text-align: center; min-height: 1.5em; margin: 1.25rem 0 0; color: var(--muted); font-size: .9rem; }
.say.bad { color: var(--bad); }

.controls { display: flex; justify-content: center; margin-top: 1rem; }
.btn {
  font: inherit; font-weight: 600; padding: .6rem 1.2rem; border-radius: var(--radius);
  border: 2px solid var(--ink); background: var(--ink); color: var(--paper); cursor: pointer;
}
.btn:hover { opacity: .88; }

/* ---- result ---- */
.result { margin-top: 2rem; padding: 1.5rem; border: 2px solid var(--line); border-radius: var(--radius); text-align: center; background: var(--tile); }
.result-word {
  margin: 0; font-family: var(--display); font-size: clamp(1.2rem, 6vw, 2rem);
  font-variation-settings: 'opsz' 96, 'wght' 700, 'SOFT' 50, 'WONK' 1;
  word-break: break-all;
}
.result-line { margin: .4rem 0 0; color: var(--muted); }
.result-best { margin: .75rem 0 0; font-size: .9rem; }
.result-best strong { color: var(--good); }
.streaks { display: flex; gap: 2rem; justify-content: center; margin: 1.25rem 0; }
.streaks div { text-align: center; }
.streaks dt { font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.streaks dd { margin: .15rem 0 0; font-size: 1.5rem; font-weight: 700; }

.how { margin-top: 3rem; border-top: 1px solid var(--line); padding-top: 1rem; color: var(--muted); font-size: .9rem; }
.how summary { cursor: pointer; font-weight: 600; }
.how ol { padding-left: 1.2rem; }
.how li { margin-bottom: .4rem; }
.how h3 { margin: 1.4rem 0 .3rem; font-size: .9rem; color: var(--ink); }
.how code { background: color-mix(in srgb, var(--ink) 8%, transparent); padding: .1em .35em; border-radius: 4px; }

@media (max-width: 480px) {
  .stage { padding-top: 1.25rem; }
  .half { padding-inline: .5rem; }
  .tile { padding: .6rem .8rem; font-size: 1rem; }
}

.result-note {
  margin: .9rem auto 0; max-width: 30rem; padding: .5rem .75rem;
  border-radius: 6px; background: color-mix(in srgb, var(--ink) 7%, transparent);
  color: var(--muted); font-size: .8rem; line-height: 1.45;
}

/* Only appears if the clipboard refuses us. Scoped to :not([hidden]) because a bare
   `display: block` here would beat the UA stylesheet's rule for the hidden attribute. */
.share-out:not([hidden]) {
  display: block; width: 100%; margin: .75rem auto 0; max-width: 24rem;
  font: inherit; font-size: .85rem; text-align: center;
  padding: .5rem .6rem; border: 2px solid var(--blue); border-radius: 6px;
  background: var(--paper); color: var(--ink);
}
