/* ═══════════════════════════════════════════════════════════════════
   PlateDiary — the what-should-I-eat wheel (/tools/what-should-i-eat-wheel).
   Loaded after css/pages.css, whose tokens, type and components it uses.

   The wheel is a plate seen from above: Cobalt slices and paper ones, a
   white rim with pegs, the logo's plate in the middle. The answer lands as
   a die-cut save under a lid. Flat fills, no outlines; transitions use the
   app's springs sampled into linear() (--snap, --soft), never an easing curve.
   Script-only controls hide until the head marks <html class="js">, so a
   visitor without JavaScript gets the drawn wheel and the lists, not dead
   buttons.
   ═══════════════════════════════════════════════════════════════════ */

html:not(.js) .wh-needs-js {
  display: none !important;
}

.js .wh-nojs {
  display: none;
}

.wh-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ── the hero is the tool ── */

.wh-app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 560px);
  grid-template-areas:
    'copy play'
    'chips play'
    'panel play';
  grid-template-rows: auto auto 1fr;
  column-gap: clamp(28px, 4vw, 64px);
  padding-bottom: 48px;
}

.wh-copy { grid-area: copy; }
.wh-chips { grid-area: chips; }
.wh-play { grid-area: play; align-self: start; }
.wh-panel { grid-area: panel; }

.wh-copy .pd-h1 {
  font-size: clamp(42px, 5.6vw, 76px);
}

.wh-copy .pd-lede {
  max-width: 28em;
}

/* ── which wheel: chips ── */

.wh-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 26px 0 0;
  padding: 0;
}

.wh-chip {
  height: 42px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: var(--sunken);
  color: var(--ink);
  font: 600 15px/1 var(--font-ui);
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--t-snap) var(--snap), color var(--t-snap) var(--snap), translate var(--t-snap) var(--snap);
}

.wh-chip:hover {
  translate: 0 -1px;
}

.wh-chip[aria-pressed='true'] {
  background: var(--accent);
  color: var(--on-accent);
}

.wh-chip--mine {
  font-family: var(--font-hand);
  font-weight: 400;
  font-size: 17px;
}

/* ── the stage: the wheel, and the answer over it ── */

.wh-play {
  position: relative;
}

.wh-stage {
  position: relative;
  width: min(100%, 560px);
  aspect-ratio: 1;
  margin-inline: auto;
}

.wh-wheel {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  touch-action: none;
  cursor: grab;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

html:not(.js) .wh-wheel {
  cursor: default;
}

.wh-wheel::before {
  /* the plate's shadow on the table: still, so the turning layer stays cheap */
  content: '';
  position: absolute;
  inset: 1.5%;
  border-radius: 50%;
  box-shadow: var(--shadow-lift);
}

.wh-wheel:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 6px;
  border-radius: 50%;
}

.is-dragging .wh-wheel {
  cursor: grabbing;
}

.wh-wheel[aria-disabled='true'] {
  cursor: default;
}

/* A turning square's corners would widen the page (a transformed box counts
   as scrollable overflow, and a phone zooms out to fit it), so the disc turns
   inside a still, round clip. */
.wh-clip {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 50%;
}

.wh-disc {
  position: absolute;
  inset: 0;
  will-change: transform;
}

.wh-svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.wh-rim { fill: var(--sheet); }
.wh-peg { fill: color-mix(in oklab, var(--accent) 55%, var(--sheet)); }
.wh-s0 { fill: var(--accent); }
.wh-s1 { fill: var(--accent-soft); }
.wh-s2 { fill: var(--die); }
.wh-s3 { fill: color-mix(in oklab, var(--accent) 42%, var(--sheet)); }

.wh-t {
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: 0.01em;
}

.wh-t0 { fill: var(--on-accent); }
.wh-t1 { fill: var(--accent-text); }
.wh-t2 { fill: #131A2E; }
.wh-t3 { fill: var(--ink); }

.wh-empty {
  font: 400 15px var(--font-hand);
  fill: #4A5270;
}

.wh-plate { fill: var(--accent); }
.wh-plate-rim { fill: none; stroke: var(--on-accent); stroke-width: 2.2; }

/* the middle of the plate is the Spin button (script only) */
.wh-hub {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 25%;
  aspect-ratio: 1;
  translate: -50% -50%;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--on-accent);
  font: 400 clamp(18px, 4.4vw, 26px)/1 var(--font-hand);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: scale var(--t-snap) var(--snap), opacity 120ms var(--snap);
}

.wh-hub:hover {
  scale: 1.06;
}

.wh-hub:active {
  opacity: 0.7;
}

.is-spinning .wh-hub,
.has-result .wh-hub {
  opacity: 0;
  pointer-events: none;
}

/* the pointer: a pin that swings as the pegs go by */
.wh-pointer {
  position: absolute;
  left: 50%;
  top: -3.2%;
  z-index: 2;
  width: 9.5%;
  height: auto;
  margin-left: -4.75%;
  transform-origin: 50% 32%;
  filter: drop-shadow(0 4px 5px color-mix(in oklab, var(--ink) 30%, transparent));
  pointer-events: none;
}

.wh-pointer .pin { fill: var(--ink); }
.wh-pointer .dot { fill: var(--surface); }

/* the answer: a covered plate on a die-cut save */
.wh-reveal {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  pointer-events: none;
}

.wh-reveal[hidden] {
  display: none;
}

.wh-card {
  width: min(64%, 300px);
  display: grid;
  justify-items: center;
  gap: 10px;
  text-align: center;
  pointer-events: auto;
}

.wh-card__kicker {
  font: 400 clamp(19px, 2.4vw, 24px)/1.1 var(--font-hand);
  color: var(--accent-text);
  rotate: -2deg;
}

.wh-card .pd-save {
  width: 100%;
  padding: 14px 14px 18px;
  border-radius: 30px;
}

.wh-save__art {
  position: relative;
}

.wh-save__art > img,
.wh-save__art > .pd-plate {
  width: 86%;
  margin: 0 auto;
}

.wh-save__art > img {
  aspect-ratio: auto;
  max-height: 100%;
  object-fit: contain;
}

.wh-card .pd-save__tag {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: clamp(19px, 2.6vw, 24px);
}

/* the lid, drawn in fills; it lifts on a spring */
.wh-lid {
  /* sized so the dome sits over the plate's well and its rim crosses the plate */
  position: absolute;
  left: 0;
  top: -26%;
  width: 100%;
  height: auto;
  pointer-events: none;
}

.wh-lid .l1 { fill: #DCE2F2; }
.wh-lid .l2 { fill: #FFFFFF; opacity: 0.7; }
.wh-lid .l3 { fill: #C7CFE6; }
.wh-lid .l4 { fill: #2F4FA0; }

.wh-from {
  font-size: 14px;
  color: var(--ink-muted);
}

.wh-close {
  position: absolute;
  top: 2%;
  right: 2%;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--sheet);
  color: var(--ink);
  box-shadow: var(--shadow-float);
  cursor: pointer;
  pointer-events: auto;
}

/* confetti: paper bits in food colours, thrown inside a clipped layer a
   little larger than the stage */
.wh-fx {
  position: absolute;
  top: -200px;
  right: -16px;
  bottom: -40px;
  left: -16px;
  z-index: 4;
  overflow: hidden;
  pointer-events: none;
}

.wh-confetti {
  position: absolute;
  left: 16px;
  top: 200px;
  z-index: 4;
  width: 0;
  height: 0;
  pointer-events: none;
}

.wh-bit {
  position: absolute;
  left: -4px;
  top: -6px;
  width: 8px;
  height: 12px;
  border-radius: 2px;
  opacity: 0;
  will-change: transform, opacity;
}

.wh-bit--dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.wh-bit--0 { background: #E8604C; } /* tomato */
.wh-bit--1 { background: #F2B544; } /* mustard */
.wh-bit--2 { background: #7DB46C; } /* matcha */
.wh-bit--3 { background: var(--accent); }
.wh-bit--4 { background: #F6A6B2; } /* strawberry */

/* ── the buttons under the wheel ── */

.wh-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-top: 22px;
}

.wh-btn {
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.wh-btn .i {
  width: 22px;
  height: 22px;
}

.wh-btn[aria-disabled='true'] {
  opacity: 0.55;
  cursor: progress;
}

.wh-btn[hidden] {
  display: none;
}

.wh-hint {
  min-height: 1.5em;
  margin-top: 12px;
  text-align: center;
  font: 400 18px/1.3 var(--font-hand);
  color: var(--accent-text);
}

.wh-nojs {
  max-width: 34em;
  margin: 22px auto 0;
  padding: 16px 20px;
  border-radius: 18px;
  background: var(--accent-soft);
  font-size: 16px;
}

/* ── the panel beside the wheel ── */

.wh-panel {
  margin-top: 28px;
  padding: 22px clamp(18px, 3vw, 26px) 20px;
  border-radius: 26px;
  background: var(--sheet);
  box-shadow: var(--shadow-float);
  align-self: start;
}

.wh-panel__top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 2px 12px;
}

.wh-panel__name {
  font: 500 clamp(26px, 3vw, 32px)/1.1 var(--font-display);
  letter-spacing: -0.015em;
}

.wh-panel__count {
  font: 600 12px/1.2 var(--font-ui);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.wh-panel__note {
  margin-top: 4px;
  font: 400 19px/1.35 var(--font-hand);
  color: var(--accent-text);
}

.wh-nearby {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font: 600 15px/1.3 var(--font-ui);
  text-decoration: none;
  overflow-wrap: anywhere;
}

.wh-nearby[hidden] {
  display: none;
}

.wh-nearby:hover {
  text-decoration: underline;
}

.wh-vetoed {
  margin-top: 16px;
}

.wh-vetoed[hidden] {
  display: none;
}

.wh-label {
  font: 600 12px/1.2 var(--font-ui);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.wh-vetoed__list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.wh-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 10px 0 14px;
  border: 0;
  border-radius: 999px;
  background: var(--sunken);
  color: var(--ink-muted);
  font: 500 14px/1.2 var(--font-ui);
  cursor: pointer;
}

.wh-pill span {
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
}

.wh-pill .i {
  width: 16px;
  height: 16px;
}

/* your wheel */
.wh-editor {
  margin-top: 18px;
}

.wh-editor[hidden] {
  display: none;
}

.wh-add {
  display: flex;
  gap: 8px;
}

.wh-add input {
  flex: 1;
  min-width: 0;
  height: 48px;
  padding: 0 16px;
  border: 0;
  border-radius: 14px;
  background: var(--sunken);
  color: var(--ink);
  font: 400 17px/1 var(--font-ui);
}

.wh-add input::placeholder {
  color: var(--ink-faint);
}

.wh-add input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.wh-add .pill {
  height: 48px;
  padding: 0 18px;
  box-shadow: none;
}

.wh-mine {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.wh-mine li {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  min-height: 38px;
  padding: 0 4px 0 14px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font: 500 15px/1.2 var(--font-ui);
  max-width: 100%;
}

.wh-mine li span {
  overflow-wrap: anywhere;
}

.wh-x {
  width: 32px;
  height: 32px;
  flex: none;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.wh-x .i {
  width: 16px;
  height: 16px;
}

.wh-editor__note {
  margin-top: 10px;
  font-size: 14px;
  color: var(--ink-muted);
}

.wh-panel__foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.wh-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 12px;
  background: var(--sunken);
  color: var(--ink);
  font: 600 14px/1 var(--font-ui);
  cursor: pointer;
}

.wh-link[hidden] {
  display: none;
}

.wh-link[aria-pressed='true'] {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.wh-link .i {
  width: 18px;
  height: 18px;
}

/* ── the wheels as menus, below ── */

.wh-menus {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
  gap: 16px;
  max-width: none;
  margin-top: 26px;
}

.wh-menu {
  display: flex;
  flex-direction: column;
  padding: 20px 20px 16px;
  border-radius: 22px;
  background: var(--sheet);
  box-shadow: var(--shadow-float);
}

.wh-menu__name {
  font: 500 22px/1.15 var(--font-display);
}

.wh-menu__note {
  margin-top: 4px;
  font: 400 17px/1.3 var(--font-hand);
  color: var(--accent-text);
}

.wh-menu__list {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 6px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.wh-menu__list li {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--sunken);
  font-size: 14px;
  color: var(--ink-muted);
}

.wh-menu__spin {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  padding: 8px 0;
  border: 0;
  background: none;
  color: var(--accent-text);
  font: 400 19px/1 var(--font-hand);
  cursor: pointer;
}

.wh-menu__spin .i {
  width: 18px;
  height: 18px;
}

/* the app section's scatter sits a little lower */
.wh-app-sec .pd-scatter {
  width: min(100%, 300px);
  margin-top: 26px;
}

/* ═══ narrower screens ══════════════════════════════════════════════ */

@media (max-width: 959px) {
  .wh-app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      'copy'
      'chips'
      'play'
      'panel';
    grid-template-rows: none;
  }

  .wh-play {
    margin-top: 30px;
  }

  .wh-panel {
    margin-top: 22px;
  }
}

@media (max-width: 699px) {
  .wh-copy .pd-h1 {
    margin: 14px 0 12px;
  }

  .wh-copy .pd-lede {
    font-size: 17px;
  }

  /* the chips scroll sideways inside their strip, never the page */
  .wh-chips {
    flex-wrap: nowrap;
    margin: 14px calc(-1 * clamp(16px, 4vw, 48px)) 0;
    padding: 2px clamp(16px, 4vw, 48px) 6px;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: none;
  }

  .wh-chips::-webkit-scrollbar {
    display: none;
  }

  .wh-chip {
    scroll-snap-align: start;
    scroll-margin-left: 16px;
  }

  .wh-play {
    margin-top: 20px;
  }

  .wh-card {
    width: min(70%, 260px);
    gap: 6px;
  }

  .wh-card .pd-save {
    padding: 10px 10px 14px;
    border-radius: 24px;
  }

  .wh-from {
    font-size: 13px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .wh-chip,
  .wh-hub {
    transition: none;
  }
}
