/* Look: sandy white ground, warm white controls, and purple for everything
   that stands out: the recipe block, selected options and the switch. */

/* Ancizar (Universidad Nacional de Colombia, OFL): the serif sets titles and
   numbers, the sans everything else. Variable files, one per unicode block. */
@font-face { font-family: "Ancizar Sans"; font-weight: 400 700; font-display: swap; src: url("fonts/ancizar-sans-latin-ext.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Ancizar Sans"; font-weight: 400 700; font-display: swap; src: url("fonts/ancizar-sans-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Ancizar Serif"; font-weight: 400 700; font-display: swap; src: url("fonts/ancizar-serif-latin-ext.woff2") format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C4, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Ancizar Serif"; font-weight: 400 700; font-display: swap; src: url("fonts/ancizar-serif-latin.woff2") format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  color-scheme: light;
  --bg: #f6f1e7;
  --surface: #fffdf9;
  --ink: #1f2a33;
  --soft: #5b5d62;
  /* Rules are warmed to sit on the sand; cool greys looked dirty on it. */
  --line: #d3cbbb;
  --row-line: #e5ded1;
  --control-line: #aca392;
  --accent: #6b3fa8;
  --on-accent: #ffffff;
  --selected-bg: #1f2a33;
  --selected-text: #ffffff;
  /* Pastel lavender, so the text on it is dark rather than white. */
  --block: #d2c5f1;
  --block-line: transparent;
  --block-rule: rgb(43 33 68 / 0.16);
  --on-block: #2b2144;
  --on-block-soft: #54467a;
  --shadow: 0 12px 32px rgb(31 42 51 / 0.16);
  --text: "Ancizar Sans", "Helvetica Neue", Arial, sans-serif;
  --heading: "Ancizar Serif", Georgia, serif;
  --numeral: "Ancizar Serif", Georgia, serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #12181d;
  --surface: #1b242b;
  --ink: #e6eaed;
  --soft: #9daab4;
  --line: #34414b;
  --row-line: #232d35;
  --control-line: #4a5863;
  --accent: #b6a0f5;
  --on-accent: #17131f;
  --selected-bg: #e6eaed;
  --selected-text: #12181d;
  /* A dusty, muted purple: a light pastel block would glare on a dark page. */
  --block: #473b6e;
  --block-line: #5c4f88;
  --block-rule: rgb(241 236 250 / 0.18);
  --on-block: #f1ecfa;
  --on-block-soft: #cbc0e6;
  --shadow: 0 12px 32px rgb(0 0 0 / 0.5);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 18px/1.4 var(--text);
}

button { font: inherit; color: inherit; }
button:focus-visible, input:focus-visible, ul:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app { max-width: 980px; margin: 0 auto; padding: 34px 24px 56px; }

/* Wraps on narrow screens: the Spanish title and both selectors do not fit
   on one phone-width line. */
header {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 16px;
  padding-bottom: 16px; margin-bottom: 26px; border-bottom: 1px solid var(--line);
}
.header-controls { display: flex; gap: 8px; margin-left: auto; }
h1 { margin: 0; font: 600 32px/1.1 var(--heading); }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 370px; gap: 48px; align-items: start; }

/* Form */

.section + .section { margin-top: 24px; }
.section-title {
  display: flex; align-items: center; gap: 4px; padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
  font: 600 21px/1.25 var(--heading);
}
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 52px; border-bottom: 1px solid var(--row-line);
}
.row[hidden] { display: none; }
.row-label { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }

.stepper {
  display: inline-flex; align-items: center; height: 40px;
  border: 1px solid var(--control-line); border-radius: 6px; background: var(--surface);
}
.stepper:focus-within { border-color: var(--accent); }
.stepper button {
  width: 42px; height: 100%; padding: 0; border: 0; background: none; color: var(--soft);
  font: 400 21px/1 var(--text); cursor: pointer; touch-action: manipulation;
}
.stepper button:hover:not(:disabled) { color: var(--ink); }
.stepper button:disabled { opacity: 0.3; cursor: default; }
.stepper .value {
  display: flex; justify-content: center; align-items: baseline; gap: 4px;
  width: 92px; cursor: text;
}
.stepper input {
  border: 0; padding: 0; background: none; color: inherit; min-width: 1ch;
  font: 600 25px/1.2 var(--numeral); text-align: right; font-variant-numeric: tabular-nums;
}
/* The outer control shows focus, so the bare input needs no ring of its own. */
.stepper input:focus-visible { outline: none; }
.stepper .unit { color: var(--soft); font-size: 16px; }

.segmented {
  display: inline-flex; gap: 2px; padding: 3px;
  border: 1px solid var(--control-line); border-radius: 6px; background: var(--surface);
}
.segmented button {
  height: 32px; padding: 0 12px; border: 0; border-radius: 4px; background: none; cursor: pointer;
  font: 500 16px/1 var(--text); white-space: nowrap;
}
.segmented button[aria-checked="true"] { background: var(--accent); color: var(--on-accent); }

/* The state is spelled out next to the switch so it never has to be read
   from the knob position or colour alone. */
.switch {
  display: inline-flex; align-items: center; gap: 10px; height: 40px; padding: 0;
  border: 0; background: none; cursor: pointer; color: var(--soft); font: 500 16px/1 var(--text);
}
.switch-track {
  position: relative; width: 46px; height: 26px; border-radius: 13px;
  background: var(--control-line); transition: background 0.15s;
}
.switch-track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #ffffff; box-shadow: 0 1px 2px rgb(0 0 0 / 0.3); transition: transform 0.15s;
}
.switch[aria-checked="true"] { color: var(--ink); }
.switch[aria-checked="true"] .switch-track { background: var(--accent); }
.switch[aria-checked="true"] .switch-track::after { transform: translateX(20px); }

.link {
  border: 0; background: none; padding: 0; cursor: pointer; color: inherit;
  font: 500 16px/1.2 var(--text); text-decoration: underline; text-underline-offset: 3px;
}
.form-foot { display: flex; align-items: center; gap: 10px; margin-top: 20px; }
.form-foot .link { margin-left: auto; color: var(--soft); }
.form-foot .link:hover { color: var(--ink); }

/* Tooltips: the only place explanations live. Shown on hover and on focus
   (a tap focuses the trigger on touch screens). */

/* The bubble is positioned against its whole row, not against the small
   trigger, so it starts at the row's left edge and can never be wider than
   the column. Anchored to the trigger it ran off the side of phone screens. */
.section-title, .row { position: relative; }
.tip { display: inline-flex; }
.tip-trigger {
  width: 22px; height: 22px; padding: 0; border: 0; background: none; cursor: help;
  font: 600 15px/1 var(--text); color: var(--soft); letter-spacing: 0;
}
.tip-bubble {
  position: absolute; z-index: 10; top: calc(100% + 4px); left: 0;
  width: max-content; max-width: min(340px, 100%); padding: 10px 12px; border-radius: 6px;
  background: var(--selected-bg); color: var(--selected-text);
  font: 400 16px/1.45 var(--text); text-transform: none; letter-spacing: 0; white-space: normal;
  opacity: 0; visibility: hidden; transition: opacity 0.12s; pointer-events: none;
}
.tip:hover .tip-bubble, .tip-trigger:focus + .tip-bubble { opacity: 1; visibility: visible; }

/* Recipe block */

.result {
  position: sticky; top: 28px; padding: 20px 24px 8px; border-radius: 10px;
  background: var(--block); border: 1px solid var(--block-line); color: var(--on-block);
}
.summary {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding-bottom: 14px; font: 500 16px/1.2 var(--text); color: var(--on-block-soft);
}
.summary .link { color: var(--on-block); }
.quantity {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
  padding: 14px 0 12px; border-top: 1px solid var(--block-rule);
}
.quantity .name { display: block; font: 500 19px/1.2 var(--text); }
.quantity .sub { display: block; margin-top: 2px; font-size: 16px; color: var(--on-block-soft); }
.quantity .amount { font: 600 54px/0.85 var(--numeral); letter-spacing: -0.01em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.quantity .amount small { margin-left: 5px; font: 500 18px/1 var(--numeral); letter-spacing: 0; color: var(--on-block-soft); }

/* Method popover */

.panel {
  position: fixed; inset: auto; margin: 0; width: 360px; max-width: calc(100vw - 24px); padding: 6px 18px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow);
}
.panel ol { margin: 8px 0; padding-left: 20px; }
.panel li { padding: 3px 0; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20;
  display: flex; gap: 16px; align-items: center; padding: 10px 16px; border-radius: 8px;
  background: var(--selected-bg); color: var(--selected-text); box-shadow: var(--shadow);
}
.toast[hidden] { display: none; }
.toast .link { color: inherit; }

/* Wheel picker, opened by touching a time or temperature value. A scroll-snap
   list stands in for the native wheel, which iOS no longer shows for <select>. */

.wheel {
  width: min(100%, 460px); max-width: 100%; margin: auto auto 0; padding: 0 0 env(safe-area-inset-bottom);
  border: 0; border-radius: 14px 14px 0 0; background: var(--surface); color: var(--ink);
}
.wheel::backdrop { background: rgb(0 0 0 / 0.5); }
.wheel-head {
  display: flex; align-items: center; justify-content: space-between; padding: 12px 20px;
  border-bottom: 1px solid var(--row-line); font: 600 20px/1.2 var(--heading);
}
#wheel-done {
  height: 38px; padding: 0 18px; border: 0; border-radius: 6px; cursor: pointer;
  background: var(--selected-bg); color: var(--selected-text); font: 500 16px/1 var(--text);
}
.wheel-body { position: relative; }
/* The band that marks the selected row. */
.wheel-body::before {
  content: ""; position: absolute; left: 20px; right: 20px; top: 50%; height: 48px;
  transform: translateY(-50%); border-block: 1px solid var(--control-line); pointer-events: none;
}
/* Five rows tall; two rows of padding let the first and last value reach the
   centre band. app.js relies on every row having the same height. */
#wheel-list {
  list-style: none; margin: 0; padding: 96px 0; height: 240px;
  overflow-y: scroll; scroll-snap-type: y mandatory; overscroll-behavior: contain; scrollbar-width: none;
  -webkit-mask-image: linear-gradient(transparent, #000 32%, #000 68%, transparent);
  mask-image: linear-gradient(transparent, #000 32%, #000 68%, transparent);
}
#wheel-list::-webkit-scrollbar { display: none; }
#wheel-list li {
  height: 48px; text-align: center; scroll-snap-align: center; cursor: pointer; opacity: 0.45;
  font: 600 29px/48px var(--numeral); font-variant-numeric: tabular-nums;
}
#wheel-list li[aria-selected="true"] { opacity: 1; }

@media (max-width: 780px) {
  .app { padding: 18px 16px 0; }
  header { margin-bottom: 20px; }
  h1 { font-size: 27px; }
  .layout { grid-template-columns: 1fr; gap: 26px; }

  /* Narrower steppers leave room for the long Spanish labels, which may
     also wrap as a last resort so a row can never push the page sideways. */
  .stepper button { width: 36px; }
  .stepper .value { width: 80px; }
  .row-label { white-space: normal; }

  /* On a phone the recipe becomes a strip pinned to the bottom edge, so the
     numbers stay visible while the inputs above are being changed. */
  .result {
    top: auto; bottom: 0; margin: 0 -16px; border-radius: 14px 14px 0 0; border-width: 1px 0 0;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    box-shadow: 0 -8px 24px rgb(0 0 0 / 0.18);
  }
  .summary { padding-bottom: 10px; font-size: 15px; }
  .quantities { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 10px; }
  .quantity { flex-direction: column-reverse; align-items: flex-start; gap: 4px; padding: 0; border: 0; }
  .quantity .name { font-size: 15px; color: var(--on-block-soft); }
  .quantity .sub { display: none; }
  .quantity .amount { font-size: 32px; }
  .quantity .amount small { font-size: 14px; margin-left: 3px; }
  .toast { bottom: 130px; }
}
