/* ============================================================================
   Missing Link.

   Built on the same tokens and the same tile shape as the daily game, so the
   two read as one site, with one difference that matters: nothing here is ever
   typed, so every tile is a target big enough for a thumb. The 44px floor is
   the reason the pool wraps rather than shrinking to fit.
   ========================================================================== */

.link-shell {
  width: min(100%, 44rem);
  margin: clamp(0.5rem, 2.5vw, 1.5rem) auto;
  padding-inline: clamp(0.5rem, 3vw, 1rem);
}

.link-board {
  padding: clamp(0.9rem, 3.5vw, 1.75rem);
}

.link-lead {
  max-width: 26rem;
  margin: 0.5rem auto 0;
  text-align: center;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--ink-2);
}

/* ------------------------------------------------------------------ scores */

.link-scores {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.4rem 1rem;
  margin-top: 0.9rem;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.link-score b {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------- the chain --
   Five cells across on any width. They shrink rather than wrap, because a
   chain that wraps stops reading as a line, and the words are short.        */

.link-chain {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(0.5rem, 2.2vw, 0.9rem);
  align-items: stretch;
}

.link-cell {
  position: relative;
  min-width: 0;
}

/* The rail between two boxes is the whole feedback language: joined or broken.
   It stays neutral when the pair makes a phrase, because a colour there reads
   as a verdict on the tiles, which is not what the board knows. */
.link-cell:not(:last-child)::after {
  content: '';
  position: absolute;
  inset-block-start: 50%;
  inset-inline-start: 100%;
  width: clamp(0.5rem, 2.2vw, 0.9rem);
  height: 2px;
  translate: 0 -50%;
  background: var(--border-strong);
  opacity: 0.6;
}

/* Broken: the rail goes red and thins to nothing behind the cross. */
.link-cell.is-broken:not(:last-child)::after {
  height: 3px;
  background: var(--row-1-line);
  opacity: 1;
}

/* Solved: every rail lights at once, which is the one moment green is earned. */
.link-chain.is-solved .link-cell:not(:last-child)::after {
  height: 3px;
  background: var(--row-3-line);
  opacity: 1;
}

/* The join mark sits in the gap to the right of its cell. */
.link-join {
  position: absolute;
  inset-block-start: 50%;
  inset-inline-start: 100%;
  translate: -50% -50%;
  width: clamp(0.5rem, 2.2vw, 0.9rem);
  text-align: center;
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1;
  pointer-events: none;
  /* Above the rail, and with a little ground of its own so the line does not
     run through the middle of the mark. */
  z-index: 2;
  border-radius: var(--r-pill);
  background: var(--surface);
}

/* Borrowed from game.css, where the keyframes live. Only the cells either side
   of a broken join move, so the animation points at the problem. */
.link-cell.shake {
  animation: shake 0.34s var(--ease);
}

/* Only a break carries a glyph. An intact join is just rail. */
.link-join.is-open,
.link-join.is-good { color: transparent; background: transparent; }

.link-join.is-bad {
  color: var(--row-1-line);
  font-size: 1rem;
}

/* --------------------------------------------------------------- the tiles */

.link-tile {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  height: 100%;
  padding: 0.3rem 0.2rem;
  appearance: none;
  font-family: var(--font-ui);
  font-size: clamp(0.62rem, 2.5vw, 0.95rem);
  font-weight: 600;
  line-height: 1.15;
  text-align: center;
  text-transform: lowercase;
  overflow-wrap: anywhere;
  color: var(--ink);
  background: var(--surface);
  border: 2px solid color-mix(in srgb, var(--border-strong) 70%, transparent);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-tile);
  cursor: pointer;
  transition: background var(--t-fast) var(--ease),
    border-color var(--t-fast) var(--ease), transform var(--t-fast) var(--ease),
    box-shadow var(--t-fast) var(--ease);
}

/* The two words the puzzle gives you. Same recede as the daily game. */
.link-tile.is-given {
  cursor: default;
  font-weight: 700;
  color: var(--ink);
  background: var(--surface-2);
  border-color: var(--border-strong);
  border-style: dashed;
}

.link-tile.is-gap {
  background: var(--surface-inset);
  border-style: dashed;
  border-color: var(--border-strong);
}

.link-tile.is-gap.is-next {
  border-style: solid;
  border-color: var(--brand-500);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-400) 22%, transparent);
}

.link-tile.is-placed {
  color: var(--ink);
  background: var(--row-2-wash);
  border-color: var(--row-2-line);
  font-weight: 700;
}

/* Beside a break: one of these two is out of place, and the board cannot say
   which. Amber, not red, because red would be a verdict on a tile. */
.link-tile.is-suspect {
  background: var(--row-0-wash);
  border-color: var(--row-0-line);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--row-0-line) 18%, transparent);
}

/* A given end word next to a break is not itself wrong, so it only dims. */
.link-tile.is-given.is-beside-break {
  border-color: color-mix(in srgb, var(--row-1-line) 45%, transparent);
}

.link-chain.is-solved .link-tile.is-placed {
  background: var(--row-3-wash);
  border-color: var(--row-3-line);
}

/* A hinted word is the one tile the board can honestly call settled, so it is
   pinned rather than coloured: no amber, which now means look here, and no
   green, which now means solved. */
.link-tile.is-placed.is-locked {
  background: var(--surface-3);
  border-color: var(--border-strong);
  border-style: solid;
  color: var(--ink-2);
  cursor: default;
  box-shadow: none;
}

.link-tile.is-pool.is-used {
  opacity: 0.35;
  cursor: default;
  box-shadow: none;
}

.link-tile:not(:disabled):hover {
  border-color: var(--brand-500);
  transform: translateY(-1px);
}

.link-tile:not(:disabled):active {
  transform: translateY(0);
}

/* ---------------------------------------------------------------- the pool */

.link-pool__title {
  margin: 1.25rem 0 0.5rem;
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.link-pool {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(0.4rem, 2vw, 0.6rem);
}

@media (max-width: 380px) {
  .link-pool { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* --------------------------------------------------------------- feedback */

.link-status {
  min-height: 1.5rem;
  margin: 0.9rem 0 0;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink-2);
}

.link-status.is-bad { color: var(--row-1-line); }
.link-status.is-good { color: var(--row-3-line); }

/* ------------------------------------------------------------ solved panel */

.link-done {
  margin-top: 1.25rem;
  padding: clamp(0.9rem, 3vw, 1.4rem);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  text-align: center;
}

.link-done__title {
  margin: 0 0 0.75rem;
  font-family: var(--font-display);
  font-size: clamp(1.15rem, 4vw, 1.5rem);
}

.link-done__chain {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
  margin-bottom: 0.85rem;
}

/* Each pair spelled out, which is the part people read back to themselves. */
.link-phrase {
  padding: 0.3rem 0.7rem;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: lowercase;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-pill);
}

.link-done__note {
  margin: 0 0 0.9rem;
  font-size: 0.92rem;
  color: var(--ink-2);
}

.link-done .btn--block + .btn--block {
  margin-top: 0.5rem;
}

/* ------------------------------------------------------------------ prose */

.link-about {
  margin-top: clamp(1.25rem, 4vw, 2rem);
  padding: clamp(1rem, 3.5vw, 1.75rem);
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
}

.link-about h2 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.1rem, 3.5vw, 1.35rem);
}

.link-about p {
  max-width: var(--prose-max);
  margin-bottom: 0.9rem;
  color: var(--ink-2);
  line-height: 1.7;
}

.link-about p:last-child { margin-bottom: 0; }

/* ------------------------------------------------------------- the New tag --
   Hidden by default and revealed by a flag on <html>, so a page whose script
   has not run, or has not run yet, shows nothing rather than a badge that may
   be wrong. js/lib/newness.js decides, and retires it by date and per player. */

.tag-new {
  display: none;
}

[data-link-new="yes"] .tag-new {
  display: inline-block;
  margin-inline-start: 0.4rem;
  padding: 0.1rem 0.45rem;
  vertical-align: middle;
  font-family: var(--font-ui);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.5;
  color: #fff;
  background: var(--brand-500);
  border-radius: var(--r-pill);
  /* A quiet pulse: enough to catch the eye once, not enough to nag. */
  animation: tag-new-pulse 2.4s var(--ease) 3;
}

@keyframes tag-new-pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--brand-400) 60%, transparent); }
  50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--brand-400) 0%, transparent); }
}

@media (prefers-reduced-motion: reduce) {
  [data-link-new="yes"] .tag-new { animation: none; }
}

/* In the drawer the label and the tag share a row, so it sits at the end. */
[data-link-new="yes"] .drawer a .tag-new {
  margin-inline-start: auto;
}

/* ----------------------------------------------------- the home page card */

.link-promo {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-top: 1rem;
  padding: 0.9rem 1.1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}

.link-promo__text {
  flex: 1 1 14rem;
  min-width: 0;
}

.link-promo__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.15rem, 3.5vw, 1.35rem);
  font-weight: 700;
  color: var(--ink);
}

.link-promo__sub {
  margin: 0.15rem 0 0;
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--ink-2);
}

.link-promo .btn {
  flex: 0 0 auto;
}
