/* paper.css -- the newspaper "cut-out" look: cream paper, ink serif type,
   word scraps with torn edges and a slight hand-cut tilt. */

:root {
  --paper: #f3ead4; /* the page itself */
  --sheet: #faf4e3; /* board + pool sheets */
  --scrap: #fbf6e7; /* a word scrap */
  --ink: #1b1b18; /* near-black newsprint ink */
  --muted: #6f6655; /* faded ink */
  --rule: #2a2a26; /* heavy rules / nameplate lines */
  --hairline: rgba(20, 18, 12, 0.16);
  --accent: #7c1d12; /* deep press red */
  --correct: #1f6f3f;
  --wrong: #9b2c1f;
  --hover: #f6e7b8; /* slot under the dragged scrap */
  --shadow: 2px 3px 7px rgba(40, 30, 10, 0.28);
  --shadow-lift: 6px 10px 20px rgba(40, 30, 10, 0.4);
  --serif: Georgia, "Times New Roman", "Times", serif;
}

body {
  background-color: var(--paper);
  /* faint newsprint grain + column tint, all pure CSS */
  background-image:
    repeating-linear-gradient(
      0deg,
      rgba(0, 0, 0, 0.015) 0,
      rgba(0, 0, 0, 0.015) 1px,
      transparent 1px,
      transparent 3px
    );
  color: var(--ink);
  font-family: var(--serif);
}

/* ---- masthead / nameplate ---- */
.masthead {
  text-align: center;
  border-top: 3px double var(--rule);
  border-bottom: 3px double var(--rule);
  padding: 0.5rem 0 0.6rem;
  margin-bottom: 1rem;
}
.masthead-title {
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1;
  margin: 0.2rem 0;
  font-size: clamp(2.1rem, 9vw, 3.6rem);
}
.masthead-sub {
  margin: 0;
  color: var(--muted);
  font-style: italic;
  font-size: clamp(0.85rem, 3vw, 1rem);
}
.masthead-date {
  margin: 0.15rem 0 0;
  font-style: normal;
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.02em;
  color: var(--ink);
}

/* ---- the two paper sheets ---- */
.board,
.pool {
  background-color: var(--sheet);
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow);
}

/* ---- a word scrap ---- */
.tile {
  display: inline-flex;
  /* the two interaction-critical lines: handle gestures ourselves, never
     start a text selection or page scroll when a finger is on a scrap */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  cursor: grab;
}
.tile-paper {
  display: inline-flex;
  align-items: center;
  min-height: 44px; /* comfortable touch target */
  padding: 0.4em 0.7em;
  background-color: var(--scrap);
  color: var(--ink);
  font-size: clamp(1rem, 3.6vw, 1.4rem);
  font-weight: 600;
  line-height: 1.05;
  white-space: nowrap;
  /* torn-paper edge: a UNIQUE clip-path polygon is set per tile in render.js
     (clipFor) so every scrap is cut differently. */
  /* filter:drop-shadow (not box-shadow) so the shadow follows the torn edge --
     box-shadow would be clipped away by clip-path. */
  filter: drop-shadow(2px 3px 4px rgba(40, 30, 10, 0.32));
  transform: rotate(var(--tilt, 0deg));
  transition: transform 120ms ease, filter 120ms ease;
}
.tile.dragging {
  cursor: grabbing;
}
.tile.dragging .tile-paper {
  transform: rotate(var(--tilt, 0deg)) scale(1.07);
  filter: drop-shadow(5px 9px 12px rgba(40, 30, 10, 0.42));
}

/* ---- slots ---- */
.slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  min-width: 2.8em;
  padding: 2px;
  border: 2px dashed rgba(20, 18, 12, 0.3);
  border-radius: 2px;
  transition: background-color 90ms ease, border-color 90ms ease;
}
.slot.filled {
  border-color: transparent;
  min-width: 0;
}
.slot.drop-hover {
  background-color: var(--hover);
  border-color: var(--ink);
}

/* ---- pool label ---- */
.pool::before {
  content: "✁ word pile";
  flex-basis: 100%;
  margin-bottom: 0.4rem;
  color: var(--muted);
  font-style: italic;
  font-size: 0.85rem;
  letter-spacing: 0.03em;
}

/* ---- buttons ---- */
.btn {
  font-family: var(--serif);
  font-size: 1rem;
  font-weight: 700;
  padding: 0.55rem 1.4rem;
  color: var(--ink);
  background-color: var(--scrap);
  border: 1.5px solid var(--rule);
  border-radius: 2px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 80ms ease, box-shadow 80ms ease;
}
.btn:hover {
  transform: translateY(-1px);
}
.btn:active {
  transform: translateY(1px);
  box-shadow: none;
}
.btn-primary {
  color: #f7efda;
  background-color: var(--accent);
  border-color: var(--accent);
}

/* ---- feedback line ---- */
.feedback {
  min-height: 1.4em;
  margin: 0.6rem 0 0.2rem;
  font-weight: 700;
  font-size: 1.05rem;
}
.feedback[data-kind="info"] {
  color: var(--muted);
  font-weight: 600;
}
.feedback[data-kind="correct"] {
  color: var(--correct);
}
.feedback[data-kind="wrong"] {
  color: var(--wrong);
}
.hint {
  color: var(--muted);
  font-style: italic;
  font-size: 0.85rem;
  margin: 0.2rem 0 0;
}

/* site footer (support / links) */
.site-footer {
  text-align: center;
  margin: 1.5rem 0 0.6rem;
  font-size: 0.85rem;
}
.site-footer a {
  color: var(--muted);
  text-decoration: none;
  border-bottom: 1px dotted var(--hairline);
  padding-bottom: 1px;
}
.site-footer a:hover {
  color: var(--accent);
}

/* tries counter, shown as pips ●●●○○ */
.tries {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.45rem;
  min-height: 1rem;
  margin: 0.3rem 0 0;
}
.pip {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  border: 1.5px solid var(--rule);
  background: transparent;
}
.pip.used {
  background: var(--ink);
}

/* next-puzzle countdown */
.countdown {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-weight: 700;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}

/* share result panel */
.share-panel {
  margin: 0.8rem auto 0.2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}
.share-preview {
  margin: 0;
  padding: 0.7rem 1rem;
  background-color: var(--scrap);
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow);
  font-family: var(--serif);
  font-size: 1.2rem;
  line-height: 1.35;
  letter-spacing: 0.12em;
  text-align: center;
  white-space: pre;
}

/* end-of-game reveal: the real headlines, linked to their articles */
.reveal {
  width: 100%;
  max-width: 30rem;
}
.reveal-title {
  margin: 0 0 0.3rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.8rem;
  color: var(--muted);
  border-bottom: 1px solid var(--hairline);
}
.reveal-list {
  list-style: none;
  margin: 0 0 0.4rem;
  padding: 0;
  text-align: left;
}
.reveal-list li {
  padding: 0.25rem 0;
  border-bottom: 1px dotted var(--hairline);
  font-size: 0.98rem;
  line-height: 1.3;
}
.reveal-list a {
  color: var(--accent);
  text-decoration: none;
}
.reveal-list a:hover {
  text-decoration: underline;
}

/* submit feedback: correct word/headline = green, right headline wrong spot = orange */
.tile.mark-correct .tile-paper {
  background-color: #c9e8c2;
  filter: drop-shadow(0 0 5px rgba(31, 111, 63, 0.55));
}
.tile.mark-misplaced .tile-paper {
  background-color: #f7d9a8;
  filter: drop-shadow(0 0 5px rgba(176, 106, 18, 0.55));
}

/* pinned = locked-correct green: can't be dragged, sits flat & "set in" */
.tile.pinned {
  cursor: default;
  touch-action: auto; /* let the page scroll when touching a locked tile */
}
.tile.pinned .tile-paper {
  background-color: #aedca4;
  filter: drop-shadow(0 0 4px rgba(31, 111, 63, 0.5));
  transform: rotate(var(--tilt, 0deg)) scale(0.97); /* gently pressed into the page */
}

/* line-locked = orange, confined to its line but still draggable WITHIN it,
   so it keeps its normal lift (not pressed-in like a pinned green) */
.tile.line-locked .tile-paper {
  background-color: #f4cb88;
  filter: drop-shadow(2px 3px 4px rgba(40, 30, 10, 0.32));
}

/* solved: gently celebrate and stop the grab cursor */
.solved .tile {
  cursor: default;
}
.solved .slot {
  border-color: transparent;
}

/* wrong-answer shake */
@keyframes shake {
  10%, 90% { transform: translateX(-1px); }
  20%, 80% { transform: translateX(2px); }
  30%, 50%, 70% { transform: translateX(-4px); }
  40%, 60% { transform: translateX(4px); }
}
.feedback.shake {
  animation: shake 0.4s ease;
}

/* respect users who prefer less motion */
@media (prefers-reduced-motion: reduce) {
  .tile-paper,
  .btn,
  .slot {
    transition: none;
  }
  .feedback.shake {
    animation: none;
  }
}
