/* MINT Word Search — built on design-system/colors_and_type.css */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--fg1);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

p { margin: 0; }

/* The whole game fits one screen — no page scroll. */
body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

.container {
  max-width: var(--container-xl);
  margin: 0 auto;
  padding: 0 var(--space-8);
}

.icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

/* ---------- Header ---------- */
.site-header {
  flex: none;
  position: relative;
  z-index: 10;
  background: rgba(251, 246, 236, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 2px solid var(--border-brand);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  height: 72px;
}
.logo { height: 46px; width: auto; display: block; }
.header-actions { display: flex; align-items: center; gap: var(--space-3); }

.stat {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 600;
  font-size: var(--fs-md);
  font-variant-numeric: tabular-nums;
  color: var(--fg2);
  min-width: 84px;
  padding-right: var(--space-2);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  border-radius: var(--radius-pill);
  padding: 12px 22px;
  border: 0;
  cursor: pointer;
  transition: background var(--dur-base) var(--ease-out),
              box-shadow var(--dur-base) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn:disabled { opacity: 0.4; box-shadow: none; cursor: default; }

.btn-primary {
  background: var(--accent);
  color: var(--fg-inverse);
  box-shadow: 0 4px 12px rgba(45, 14, 50, 0.12);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { background: var(--accent-press); transform: translateY(2px); box-shadow: var(--shadow-sm); }

.btn-secondary {
  background: var(--bg);
  color: var(--fg-brand);
  box-shadow: inset 0 0 0 2px var(--border-brand);
  padding: 10px 20px;
}
.btn-secondary:hover { background: var(--mint-purple-50); }
.btn-secondary:active { transform: translateY(1px); }

/* ---------- Stage: story | grid | words ---------- */
.stage {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr) minmax(220px, 280px);
  grid-template-areas: "info board words";
  gap: var(--space-6);
  padding-top: var(--space-6);
  padding-bottom: var(--space-6);
}
.info, .board-wrap, .words-card { min-height: 0; }

.object-card,
.words-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
}

/* Left: the object, then the intro */
.info {
  grid-area: info;
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}
.intro-title {
  font-size: clamp(22px, 2.2vw, var(--fs-2xl));
  color: var(--fg-brand);
  margin: 0 0 var(--space-2);
}
.intro .lead { font-size: var(--fs-sm); line-height: var(--lh-base); }
.howto { margin-top: var(--space-2); font-size: var(--fs-xs); color: var(--fg3); }

.object-card {
  margin: 0;
  overflow: hidden;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
/* Photo of the doll; hover (or tap) shows the menu close-up beside it */
.info { position: relative; }
.object-frame {
  position: relative;
  flex: 1;
  min-height: 120px;
  background: #f2f1ee;
  overflow: hidden;
  cursor: zoom-in;
}
.object-frame:focus-visible { outline: none; box-shadow: inset var(--focus-ring); }
.object-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.info.is-zoomed .object-frame { cursor: zoom-out; }
.info.is-zoomed .zoom-hint { opacity: 0; }

.menu-zoom {
  position: absolute;
  z-index: 30;
  top: 0;
  left: calc(100% + var(--space-6));
  width: min(620px, 48vw);
  height: auto;
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-out);
}
.info.is-zoomed .menu-zoom { opacity: 1; pointer-events: auto; cursor: zoom-out; }

.zoom-hint {
  position: absolute;
  left: 50%;
  bottom: var(--space-3);
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: var(--bg);
  box-shadow: var(--shadow-md);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--fg-brand);
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-out);
}
.zoom-hint .icon { width: 16px; height: 16px; }
.hint-touch { display: none; }
@media (hover: none) {
  .hint-hover { display: none; }
  .hint-touch { display: inline; }
}

.plaque {
  flex: none;
  margin: var(--space-3);
  background: var(--bg-sunken);
  border-radius: var(--radius-lg);
  padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-inset);
}
.plaque .eyebrow { font-size: 10px; letter-spacing: 0.16em; margin-bottom: 4px; }
.plaque-title { font-weight: 800; font-size: var(--fs-base); line-height: 1.15; letter-spacing: -0.01em; margin-bottom: 6px; }
.plaque-facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px var(--space-3);
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
}
.plaque-facts dt { color: var(--neutral-500); }
.plaque-facts dd { margin: 0; color: var(--fg1); font-weight: 600; }

/* Centre: the largest square that fits the space */
.board-wrap {
  grid-area: board;
  position: relative;
  container-type: size;
  display: flex;
  align-items: center;
  justify-content: center;
}
.board {
  position: relative;
  width: min(100cqw, 100cqh);
  height: min(100cqw, 100cqh);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-inset), var(--shadow-md);
  padding: var(--space-3);
  container-type: inline-size;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.grid {
  position: relative;
  z-index: 2;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(var(--n, 12), 1fr);
  grid-template-rows: repeat(var(--n, 12), 1fr);
}
.cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: calc(100cqw / var(--n, 12) * 0.46);
  color: var(--fg1);
  cursor: pointer;
  border-radius: var(--radius-pill);
  transition: color var(--dur-fast) var(--ease-out);
}
.cell:hover { color: var(--fg-brand); }
.cell.anchor { color: var(--fg-inverse); background: var(--accent); }
.cell.found { color: var(--mint-purple-700); }
.cell.hint { animation: hint 1.2s var(--ease-out) 2; }
@keyframes hint {
  0%, 100% { background: transparent; }
  40% { background: var(--mint-gold); color: var(--fg-inverse); }
}

.marks {
  position: absolute;
  inset: var(--space-3);
  width: calc(100% - 2 * var(--space-3));
  height: calc(100% - 2 * var(--space-3));
  z-index: 1;
  pointer-events: none;
  overflow: visible;
}
.marks line { stroke-linecap: round; stroke-width: 0.78; }
.marks .found { stroke: var(--mint-purple-200); opacity: 0.75; animation: fade-in var(--dur-slow) var(--ease-out); }
.marks .found.alt1 { stroke: var(--mint-mint); opacity: 0.6; }
.marks .found.alt2 { stroke: #e9cf95; opacity: 0.8; }
.marks .active { stroke: var(--accent); opacity: 0.22; }
.marks .miss { stroke: var(--danger); opacity: 0.25; animation: miss var(--dur-slow) var(--ease-out) forwards; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes miss { to { opacity: 0; } }

/* Mini pop-up describing the dish just found */
.dish-pop {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: var(--space-4);
  transform: translateX(-50%);
  width: min(420px, calc(100% - 2 * var(--space-4)));
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-top: 4px solid var(--border-brand);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: var(--space-4) var(--space-10) var(--space-4) var(--space-5);
  /* Presses fall through to the grid (which dismisses the pop-up),
     so it never blocks the letters underneath. */
  pointer-events: none;
}
.dish-pop[hidden] { display: none; }
.dish-pop.is-in { animation: fade-in var(--dur-base) var(--ease-out); }
.dish-pop .eyebrow { font-size: 10px; margin-bottom: 4px; }
.pop-title {
  font-weight: 800;
  font-size: var(--fs-lg);
  line-height: var(--lh-snug);
  letter-spacing: var(--tracking-tight);
  color: var(--fg-brand);
  margin-bottom: 4px;
}
.pop-text { font-size: var(--fs-sm); line-height: var(--lh-base); color: var(--fg2); }
.pop-close {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--fg2);
  cursor: pointer;
  pointer-events: auto;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.pop-close:hover { background: var(--mint-purple-50); color: var(--fg-brand); }
.pop-close:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* Right: the words */
.words-card {
  grid-area: words;
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  overflow: auto;
}
.words-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: var(--space-4);
}
.progress { font-size: var(--fs-sm); color: var(--fg2); font-variant-numeric: tabular-nums; }
.progress strong { color: var(--fg-brand); font-weight: 700; }
.word-list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--space-2);
}
.word-list li { display: flex; }
.word-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  text-align: left;
  color: inherit;
  border-radius: var(--radius-sm);
}
.word-btn:disabled { cursor: default; }
.word-btn:not(:disabled) { cursor: pointer; }
.word-btn:not(:disabled):hover .dish { color: var(--fg-brand); }
.word-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.word {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: var(--fs-base);
  letter-spacing: var(--tracking-wide);
  color: var(--fg1);
  transition: color var(--dur-base) var(--ease-out);
}
.word .icon { width: 16px; height: 16px; color: var(--success); display: none; }
.dish { font-size: 11px; color: var(--fg3); font-style: italic; opacity: 0; transition: opacity var(--dur-slow) var(--ease-out); }
.word-list li.is-found .word { color: var(--fg3); text-decoration: line-through; text-decoration-color: var(--mint-purple-300); }
.word-list li.is-found .word .icon { display: inline; }
.word-list li.is-found .dish { opacity: 1; }

/* ---------- Completion dialog ---------- */
.scrim {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(26, 16, 20, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  animation: fade-in var(--dur-slow) var(--ease-out);
}
.scrim[hidden] { display: none; }
.dialog {
  width: min(760px, 100%);
  max-height: calc(100dvh - 48px);
  overflow: auto;
  background: var(--bg);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
}
.dialog-feature {
  background: var(--bg-inverse);
  color: var(--fg-inverse);
  padding: var(--space-10) var(--space-10) var(--space-8);
}
.dialog-feature h2 { color: var(--fg-inverse); font-size: var(--fs-2xl); margin: var(--space-2) 0; }
.dialog-feature p { color: var(--fg-inverse); }
.eyebrow-inverse { color: var(--mint-gold); }
.acrostic {
  margin-top: var(--space-6);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 0.45em;
  font-weight: 900;
  font-size: clamp(24px, 4.4vw, 40px);
  letter-spacing: var(--tracking-tight);
}
.acrostic-word { display: inline-flex; gap: 6px; }
.acrostic-word span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.15em;
  height: 1.3em;
  border-radius: var(--radius-md);
  background: var(--mint-cream);
  color: var(--mint-purple-500);
  opacity: 0;
  animation: appear var(--dur-slow) var(--ease-out) forwards;
}
@keyframes appear { to { opacity: 1; } }
.dialog-body {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: var(--space-6);
  padding: var(--space-8) var(--space-10) var(--space-10);
  align-items: start;
}
.menu-photo { width: 100%; border-radius: var(--radius-lg); box-shadow: var(--shadow-md); display: block; }
.dialog-text { display: grid; gap: var(--space-4); justify-items: start; }

/* ---------- Responsive ---------- */
/* Narrower landscape screens: slimmer side columns */
@media (min-aspect-ratio: 1/1) and (max-width: 1100px) {
  .container { padding-left: var(--space-5); padding-right: var(--space-5); }
  .stage {
    grid-template-columns: minmax(180px, 240px) minmax(0, 1fr) minmax(170px, 210px);
    gap: var(--space-4);
  }
}
/* Short landscape screens: drop secondary text */
@media (min-aspect-ratio: 1/1) and (max-height: 760px) {
  .stage { gap: var(--space-4); padding-top: var(--space-4); padding-bottom: var(--space-4); }
  .howto, .dish { display: none; }
  .words-card { padding: var(--space-4); }
}
@media (min-aspect-ratio: 1/1) and (max-height: 560px) {
  .header-inner { height: 56px; }
  .logo { height: 34px; }
  .plaque, .intro .lead { display: none; }
}

/* Portrait (tablet & phone): title row, grid, word chips */
@media (max-aspect-ratio: 1/1) {
  .stage {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-areas: "info" "board" "words";
    gap: var(--space-4);
    padding-top: var(--space-4);
    padding-bottom: var(--space-4);
  }
  .info { flex-direction: row; align-items: center; gap: var(--space-4); }
  .object-card { flex: none; width: 72px; height: 72px; border-radius: var(--radius-lg); }
  .object-frame { min-height: 0; }
  .object-frame img { object-fit: cover; object-position: top; }
  .zoom-hint { display: none; }
  .menu-zoom { left: 0; top: calc(100% + var(--space-4)); width: 100%; }
  .plaque, .howto, .dish { display: none; }
  .intro-title { font-size: clamp(20px, 4.6vw, 32px); margin: 0 0 2px; }
  .intro .lead { font-size: var(--fs-xs); line-height: 1.4; }
  .words-card { padding: var(--space-4); overflow: visible; }
  .words-head { margin-bottom: var(--space-3); }
  .word-list { flex-direction: row; flex-wrap: wrap; justify-content: flex-start; gap: var(--space-2); }
  .word-list li {
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    background: var(--mint-purple-50);
    border: 1px solid var(--mint-purple-100);
  }
  .word { font-size: var(--fs-sm); }
}
@media (max-width: 640px) {
  .container { padding-left: var(--space-4); padding-right: var(--space-4); }
  .header-inner { height: 60px; }
  .logo { height: 36px; }
  .stat { display: none; }
  .btn { padding: 9px 14px; font-size: 14px; }
  .board { padding: var(--space-2); border-radius: var(--radius-lg); }
  .marks {
    inset: var(--space-2);
    width: calc(100% - 2 * var(--space-2));
    height: calc(100% - 2 * var(--space-2));
  }
  .object-card { width: 56px; height: 56px; }
  .intro .lead { font-size: 11px; }
  .words-card { padding: var(--space-3); }
  .word-list { gap: 6px; }
  .word-list li { padding: 3px 10px; }
  .word { font-size: 12px; letter-spacing: 0.02em; }
  .scrim { padding: var(--space-4); }
  .dialog-feature { padding: var(--space-6); }
  .dialog-feature h2 { font-size: var(--fs-xl); }
  .acrostic { margin-top: var(--space-4); }
  .dialog-body { grid-template-columns: 1fr; padding: var(--space-6); }
  .menu-photo { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
