/* ==========================================================================
   screens.css — the stage and the four screens.
   Logical properties only: never left / right.
   ========================================================================== */

.stage {
  position: relative;
  inline-size: 100%;
  block-size: 100%;
}

/* In standalone mode the iPad's home indicator overlaps the bottom edge, and
   viewport-fit=cover means the page is responsible for staying clear of it. */
.screen {
  position: absolute;
  inset: 0;
  padding-block-end: env(safe-area-inset-bottom, 0px);
  padding-inline-start: env(safe-area-inset-left, 0px);
  padding-inline-end: env(safe-area-inset-right, 0px);
}

/* ==========================================================================
   SCREEN 1 — attract
   ========================================================================== */

.screen--attract {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: var(--space-4);
}

.attract__canvas {
  position: absolute;
  inset: 0;
  inline-size: 100%;
  block-size: 100%;
}

.attract__copy {
  position: relative;
  display: grid;
  justify-items: center;
  gap: var(--space-3);
  text-align: center;
}

.attract__headline {
  max-inline-size: 18ch;
  font-size: var(--step-5);
}

.attract__sub {
  color: var(--olive-mid);
  font-size: var(--step-2);
  font-weight: 500;
}

.attract__hint {
  position: absolute;
  inset-block-end: var(--space-6);
  color: var(--olive-mid);
  font-size: var(--step-0);
  opacity: 0.65;
  animation: hint-breathe 3.6s var(--ease-out) infinite;
}

@keyframes hint-breathe {
  0%, 100% { opacity: 0.28; }
  50%      { opacity: 0.72; }
}

/* ==========================================================================
   SCREENS 2 & 3 — the question deck
   One question on the glass at a time, and the same layout for both decks so
   they read as one conversation rather than two separate forms.
   ========================================================================== */

.screen--deck {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: var(--space-3);
  padding-block: var(--space-4) var(--space-3);
  padding-inline: var(--space-5);
}

/* Spans the whole screen so a burst is never clipped by a cell boundary.
   Its stacking order is set in components.css alongside the cup it has to
   stay above. */
.deck__canvas {
  position: absolute;
  inset: 0;
  inline-size: 100%;
  block-size: 100%;
  pointer-events: none;
}

.deck__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.deck__progress {
  color: var(--olive-mid);
  font-size: var(--step-0);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* The question takes what it needs; the answers take everything else. Sizing
   both to content and centring the pair left a third of an iPad empty. */
.deck__stage {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  justify-items: center;
  gap: clamp(var(--space-2), 2.6vh, var(--space-4));
  inline-size: 100%;
  block-size: 100%;
  min-block-size: 0;
}

.deck__question {
  max-inline-size: 22ch;
  font-size: clamp(var(--step-2), 4.6vh, var(--step-4));
  text-align: center;
}

/* Flex, not grid: a wrapped flex line centres its own orphans, so five answers
   land as 3 + 2 with the pair centred under the trio. A grid would leave the
   pair hugging one edge. */
/* Flex, not grid: a wrapped flex line centres its own orphans, so five answers
   land as 3 + 2 with the pair centred under the trio. A grid would leave the
   pair hugging one edge. */
.deck__choices {
  --gap: clamp(var(--space-2), 2.4vh, var(--space-4));

  display: flex;
  flex-wrap: wrap;
  align-content: center;
  justify-content: center;
  gap: var(--gap);
  inline-size: min(100%, 78rem);
  block-size: 100%;
  min-block-size: 0;
}

/* The body question renders one control, not a row of answers. */
.deck__choices[data-control='slider'] { inline-size: auto; }

.deck__foot {
  display: flex;
  justify-content: center;
  min-block-size: 3rem;
}

/* --- motion ---------------------------------------------------------------
   The heading always leads. What follows it depends on the question: a chip
   question tilts its answers in, a sphere question pops them, aroma rises,
   ripples open from their centre, liquid pours up, cards slide. Six questions
   that all animated identically would read as one long form. ---------------- */

.deck__stage.is-entering .deck__question {
  animation: deck-rise var(--dur-settle) var(--ease-out) both;
}

.deck__stage.is-entering .choice {
  animation-duration: 460ms;
  animation-timing-function: var(--ease-spring);
  animation-fill-mode: both;
  animation-delay: var(--stagger, 0ms);
}

.deck__stage[data-control='art'].is-entering    .choice { animation-name: deck-pop; }
.deck__stage[data-control='slider'].is-entering .vol   { animation: deck-pour 520ms var(--ease-out) both; }

.deck__stage.is-leaving {
  opacity: 0;
  transform: scale(0.97);
  transition: opacity 260ms var(--ease-out), transform 260ms var(--ease-out);
}

@keyframes deck-tilt {
  from { opacity: 0; transform: translateY(1.4rem) rotate(-6deg) scale(0.86); }
  to   { opacity: 1; transform: none; }
}

@keyframes deck-waft {
  from { opacity: 0; transform: translateY(2.2rem); }
  to   { opacity: 1; transform: none; }
}

@keyframes deck-open {
  from { opacity: 0; transform: scale(0.4); }
  to   { opacity: 1; transform: none; }
}

@keyframes deck-pour {
  from { opacity: 0; clip-path: inset(100% 0 0 0); }
  to   { opacity: 1; clip-path: inset(0 0 0 0); }
}

@keyframes deck-slide {
  from { opacity: 0; transform: translateY(1.6rem) scale(0.94); }
  to   { opacity: 1; transform: none; }
}

@keyframes deck-rise {
  from { opacity: 0; transform: translateY(0.9rem); }
  to   { opacity: 1; transform: none; }
}

@keyframes deck-pop {
  from { opacity: 0; transform: translateY(1.1rem) scale(0.9); }
  to   { opacity: 1; transform: none; }
}

/* ==========================================================================
   SCREEN 4 — the result
   One column, read top to bottom: the coffee, its name, its measurements,
   what else to try, and the field that keeps in touch. Restarting lives in
   the corner, out of the reading path.
   ========================================================================== */

.screen--result {
  display: grid;
  place-items: center;
}

.assembly__canvas {
  position: absolute;
  inset: 0;
  inline-size: 100%;
  block-size: 100%;
  pointer-events: none;
}

.result {
  display: grid;
  place-items: center;
  inline-size: 100%;
  block-size: 100%;
  padding-block: var(--space-3);
  padding-inline: var(--space-4);

  opacity: 0;
  transition: opacity var(--dur-settle) var(--ease-out);
}

.result.is-revealed { opacity: 1; }

/* Every row declares min-block-size:0 through the child rule below, so the
   column can always resolve inside the screen instead of overflowing it. */
.sheetcol {
  display: grid;
  /* Every row sized to its content and the whole stack centred, rather than
     one row taking the slack: a 1fr row swallowed all the free height on a
     taller screen and pushed the photo to the ceiling and the capture to the
     floor with a void in between. `safe` keeps it from overflowing both ends
     when the content is taller than the screen. */
  grid-template-rows: repeat(5, auto);
  align-content: safe center;
  justify-items: center;
  gap: clamp(var(--space-2), 2vh, var(--space-4));
  inline-size: min(100%, 54rem);
  block-size: 100%;
  min-block-size: 0;
}

.sheetcol > * { min-block-size: 0; }

/* --- the coffee, as a band across the top -------------------------------- */

.shot {
  inline-size: 100%;
  block-size: clamp(5.5rem, 17vh, 11rem);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 1rem 2rem -1.2rem color-mix(in srgb, var(--ink) 70%, transparent);
}

.shot__img {
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
}

/* --- the verdict ---------------------------------------------------------- */

.verdict {
  display: grid;
  justify-items: center;
  gap: 0.1rem;
  inline-size: 100%;
  text-align: center;
}

.verdict__name {
  font-size: clamp(var(--step-2), 4.4vh, var(--step-4));
  line-height: 1.04;
}

.verdict__latin {
  color: var(--olive-mid);
  font-size: clamp(var(--step--1), 1.9vh, var(--step-0));
  font-weight: 500;
  letter-spacing: 0.04em;
}

.verdict__meta { color: var(--olive-mid); font-size: var(--step--1); }

.verdict__notes {
  max-inline-size: 48ch;
  color: var(--ink);
  font-size: clamp(var(--step--1), 2vh, var(--step-1));
  line-height: 1.4;
  text-wrap: balance;
}

/* --- start over, in the corner ------------------------------------------- */

.restart {
  position: absolute;
  inset-block-start: var(--space-3);
  inset-inline-end: var(--space-3);
  z-index: 5;

  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-block-size: 2.8rem;
  padding-block: var(--space-1);
  padding-inline: var(--space-3);
  border: var(--hairline-width) solid var(--hairline);
  border-radius: var(--radius-pill);
  color: var(--olive-mid);
  font-size: var(--step--1);
  font-weight: 500;
  transition: border-color var(--dur-tap) var(--ease-out),
              color var(--dur-tap) var(--ease-out);
}

.restart__icon {
  inline-size: 1.1rem;
  block-size: 1.1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.restart:active { border-color: var(--accent); color: var(--accent); }

/* ==========================================================================
   boot failure
   ========================================================================== */

/* ==========================================================================
   boot failure
   ========================================================================== */

/* ==========================================================================
   boot failure
   ========================================================================== */

.boot-error {
  position: fixed;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: var(--space-3);
  padding-inline: var(--space-6);
  background: var(--cream);
  text-align: center;
  z-index: 100;
}

.boot-error h2 { font-size: var(--step-3); }
.boot-error p  { max-inline-size: var(--measure); color: var(--olive-mid); }

.boot-error__detail {
  max-inline-size: 70ch;
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--cream-sunk);
  color: var(--ink-soft);
  font-family: ui-monospace, monospace;
  font-size: var(--step--1);
  direction: ltr;
  white-space: pre-wrap;
  text-align: start;
}
