/*
  Recipes' Cast screen. Colours, type, spacing and corners come from
  design/tokens.json (copied here by hand: keep them in step). Light and
  dark follow the phone: the phone sends its theme and the page sets
  data-theme on <html>; before it does, the device's own preference.

  Everything is sized in rem, and 1rem is a thirtieth of the screen's
  height (or less on a screen narrower than 16:9), so the layout is the
  same on a 1080p TV and a 1024×600 Nest Hub.
*/

:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-muted: #f7f6f4;
  --ink: #222222;
  --ink-muted: #6a6a6a;
  --ink-disabled: #c4c4c4;
  --border: #dddddd;
  --border-strong: #8c8c8c;
  --brand: #1b4332;
  --brand-hover: #143528;
  --on-brand: #ffffff;
  --brand-soft: #d8f3dc;
  --on-brand-soft: #1b4332;
  --herb: #2d6a4f;
  --on-herb: #ffffff;
  --inverse-surface: #222222;
  --inverse-ink: #ffffff;

  --sans: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --script: "Pacifico", cursive;

  /* radius-sm / -md / -lg (8 / 12 / 16px against 16px body), in rem. */
  --radius-sm: 0.35rem;
  --radius-lg: 0.7rem;
  --radius-pill: 999px;

  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #121110;
  --surface: #1c1a18;
  --surface-muted: #242120;
  --ink: #f4f1ed;
  --ink-muted: #a9a39d;
  --ink-disabled: #4a4440;
  --border: #3a3633;
  --border-strong: #7a736d;
  --brand: #52b788;
  --brand-hover: #74c69d;
  --on-brand: #0b1f15;
  --brand-soft: #1b3a2b;
  --on-brand-soft: #b7e4c7;
  --herb: #74c69d;
  --on-herb: #0b1f15;
  --inverse-surface: #f4f1ed;
  --inverse-ink: #121110;
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121110;
    --surface: #1c1a18;
    --surface-muted: #242120;
    --ink: #f4f1ed;
    --ink-muted: #a9a39d;
    --ink-disabled: #4a4440;
    --border: #3a3633;
    --border-strong: #7a736d;
    --brand: #52b788;
    --brand-hover: #74c69d;
    --on-brand: #0b1f15;
    --brand-soft: #1b3a2b;
    --on-brand-soft: #b7e4c7;
    --herb: #74c69d;
    --on-herb: #0b1f15;
    --inverse-surface: #f4f1ed;
    --inverse-ink: #121110;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html {
  font-size: min(calc(100vh / 30), calc(100vw / 53.33));
  height: 100%;
}

body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

#app {
  height: 100%;
  padding: 1.5rem 2.25rem;
  display: grid;
  /* One column no wider than the screen: without it, a long title (kept
     on one line) widens the column and pushes everything off the right. */
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 1.25rem;
}

/* The Cast framework lays a full-screen media touch layer over the page on
   a Nest Hub, even with no player, and it catches every tap. This page has
   its own touch controls, so hide it. */
touch-controls { display: none !important; }

/* Waiting for the phone. */
.splash {
  grid-row: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}
.wordmark {
  margin: 0;
  font-family: var(--script);
  font-size: 4rem;
  line-height: 1.5;
  color: var(--brand);
}
.splash-text {
  margin: 0;
  font-size: 1.25rem;
  color: var(--ink-muted);
}

/* Along the top: the recipe, its times, where you are. */
.top {
  display: flex;
  align-items: flex-end;
  gap: 1.5rem;
}
.top-text { flex: 1; min-width: 0; }
.title {
  margin: 0;
  font-size: 1.75rem;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.meta {
  display: flex;
  gap: 1.5rem;
  margin-top: 0.4rem;
}
.meta div { display: flex; flex-direction: column; }
.meta-label {
  font-size: 0.7rem;
  line-height: 1.3;
  font-weight: 600;
  color: var(--ink-muted);
}
.meta-value { font-size: 0.9rem; line-height: 1.4; }
.where {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--brand);
  white-space: nowrap;
}

/* The step you're on, and what it uses beside it. */
.middle {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 1.25rem;
  min-height: 0;
}
.middle.single { grid-template-columns: minmax(0, 1fr); }

.panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 0.1rem solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  overflow: hidden;
}
.panel.current {
  background: var(--brand-soft);
  border: 0.18rem solid var(--brand);
}
.panel-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}
.label {
  flex: 1;
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.3;
  font-weight: 600;
  color: var(--brand);
}
.group {
  margin: 0 0 0.25rem;
  font-weight: 700;
  color: var(--brand);
}
.step-text {
  margin: 0;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  font-weight: 500;
  line-height: 1.35;
  /* Set by fit() in receiver.js, between 1.1rem and 2.4rem. */
  font-size: 2.4rem;
}
.done .step-text {
  text-decoration: line-through;
  color: var(--ink-muted);
}
.scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: none;
}
.scroll::-webkit-scrollbar { display: none; }
.notes { white-space: pre-line; color: var(--ink); margin: 0.25rem 0 0; }
.subhead {
  margin: 1rem 0 0.4rem;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--brand);
}
.empty { margin: 0; color: var(--ink-muted); }

/* One ingredient to tick off. */
.ingredients { list-style: none; margin: 0; padding: 0; }
.ingredient {
  display: flex;
  gap: 0.6rem;
  padding: 0.3rem 0;
  font-size: 1.1rem;
  line-height: 1.45;
}
.ingredient.header {
  padding-top: 0.6rem;
  font-weight: 700;
  color: var(--brand);
}
.amount { font-weight: 800; }
.ingredient.ticked .body {
  text-decoration: line-through;
  color: var(--ink-muted);
}
.instead {
  display: block;
  color: var(--ink-muted);
  font-size: 0.9rem;
}

.tick {
  flex: none;
  width: 1.4rem;
  height: 1.4rem;
  margin-top: 0.1rem;
  border-radius: 50%;
  border: 0.12rem solid var(--border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.tick svg { width: 75%; height: 75%; visibility: hidden; }
.ticked > .tick,
.tick.on {
  background: var(--herb);
  border-color: var(--herb);
  color: var(--on-herb);
}
.ticked > .tick svg,
.tick.on svg { visibility: visible; }
.step-tick { width: 2rem; height: 2rem; }

/* Along the bottom: Back and Next on a touch screen, what's next on a TV. */
.bottom {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  min-height: 3rem;
}
.next-up {
  flex: 1;
  min-width: 0;
  margin: 0;
  color: var(--ink-muted);
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.next-up strong { color: var(--ink); font-weight: 600; }
.dots { display: flex; gap: 0.4rem; flex-wrap: nowrap; }
.dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--border);
}
.dot.past { background: var(--border-strong); }
.dot.here { background: var(--brand); }

button {
  font: inherit;
  font-size: 1.1rem;
  font-weight: 600;
  min-height: 3rem;
  min-width: 8rem;
  padding: 0 1.25rem;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button svg { width: 1.4rem; height: 1.4rem; }
.outlined {
  background: transparent;
  color: var(--ink);
  border: 0.06rem solid var(--border-strong);
}
.filled {
  background: var(--brand);
  color: var(--on-brand);
  border: 0.06rem solid var(--brand);
}
.filled:active { background: var(--brand-hover); }
button:disabled {
  color: var(--ink-disabled);
  border-color: var(--ink-disabled);
  background: transparent;
  cursor: default;
}

[data-tap] { cursor: pointer; }

/* The phone has gone: a quiet pill at the top. */
.lost {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius-pill);
  background: var(--inverse-surface);
  color: var(--inverse-ink);
  font-size: 0.9rem;
  white-space: nowrap;
}
