/* Pantry.
   Palette taken from the design brief. Urgency is always carried by a word as
   well as a colour — colour alone is useless as colour vision changes with age.
   Everything is sized for a thumb: nothing interactive is under 60px tall. */

:root {
  --ground: #F1F2EE;
  --surface: #FAFAF8;
  --surface-2: #E9EBE5;
  --ink: #1A1F1B;
  --muted: #656C66;
  --rule: #D5D8D0;
  --accent: #27418C;
  --on-accent: #FAFAF8;
  --ok: #3A6E4A;
  --ok-bg: #E4EDE5;
  --soon: #7A4F12;
  --soon-bg: #F3EAD9;
  --now: #8E2F24;
  --now-bg: #F4E3E0;

  --body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --tap: 64px;
  /* One row of the date wheel. app.js measures this off the DOM rather than
     assuming it, so this is the only place it is decided. */
  --wheel-item: 64px;
  --pad: 1.15rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #141714;
    --surface: #1C201D;
    --surface-2: #262B27;
    --ink: #E7EAE4;
    --muted: #9AA199;
    --rule: #333933;
    --accent: #6E8AD8;
    --on-accent: #101319;
    --ok: #7FB98D;
    --ok-bg: #1E2A20;
    --soon: #D6A557;
    --soon-bg: #2C2517;
    --now: #E08477;
    --now-bg: #2E1D1A;
  }
}

* { box-sizing: border-box; }

/* Several things here are laid out with flex or grid, and those declarations
   would otherwise beat the [hidden] attribute's display:none — leaving the
   sheet and the toast permanently over the top of the app. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--body);
  font-size: 18px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

button, label.btn, input { font: inherit; }

button, label.btn {
  /* No accidental double-tap zoom, no grey flash on tap. */
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ------------------------------------------------------------- screens -- */

.screen { display: none; min-height: 100dvh; }
.screen.is-active { display: block; }

.masthead {
  padding: calc(env(safe-area-inset-top) + 1.6rem) var(--pad) 0.9rem;
}

h1 {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.bar {
  padding: calc(env(safe-area-inset-top) + 0.6rem) var(--pad) 0.2rem;
}

.btn-back {
  background: none;
  border: 0;
  color: var(--accent);
  font-size: 1.1rem;
  font-weight: 600;
  padding: 0.7rem 0.9rem 0.7rem 0;
  min-height: 52px;
  cursor: pointer;
}

.btn-back::before { content: "‹ "; font-size: 1.4em; line-height: 0; }

/* ---------------------------------------------------------------- list -- */

.list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  /* Room for the fixed add button so the last row is never trapped under it. */
  padding: 0 var(--pad) calc(var(--tap) + env(safe-area-inset-bottom) + 3rem);
}

.row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  width: 100%;
  min-height: 84px;
  padding: 0.6rem 0.85rem;
  border: 1px solid transparent;
  border-radius: 12px;
  text-align: left;
  cursor: pointer;
  color: inherit;
}

.row-ok   { background: var(--ok-bg); }
.row-soon { background: var(--soon-bg); }
.row-now  { background: var(--now-bg); }

.row-thumb {
  width: 62px;
  height: 62px;
  border-radius: 9px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--surface-2);
}

.row-thumb-none {
  display: grid;
  place-items: center;
  font-size: 1.6rem;
  color: var(--muted);
}

.row-when {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.25;
}

.row-ok   .row-when { color: var(--ok); }
.row-soon .row-when { color: var(--soon); }
.row-now  .row-when { color: var(--now); }

.row-date {
  font-size: 0.92rem;
  color: var(--muted);
  margin-top: 0.1rem;
}

.stale {
  margin: 0 var(--pad) 0.8rem;
  padding: 0.7rem 0.9rem;
  background: var(--surface-2);
  border-radius: 10px;
  font-size: 0.95rem;
  color: var(--muted);
}

.empty { padding: 3rem var(--pad); }
.empty-lead { font-size: 1.3rem; font-weight: 650; margin: 0 0 0.5rem; }
.empty-sub { margin: 0; color: var(--muted); }

.setup { padding: calc(env(safe-area-inset-top) + 4rem) var(--pad); }

/* --------------------------------------------------------------- dock --- */

.dock {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  padding: 0.7rem var(--pad) calc(env(safe-area-inset-bottom) + 0.7rem);
  background: linear-gradient(to top, var(--ground) 70%, transparent);
}

/* -------------------------------------------------------------- buttons -- */

.btn {
  display: block;
  width: 100%;
  min-height: var(--tap);
  padding: 0.9rem 1rem;
  border: 0;
  border-radius: 12px;
  font-size: 1.15rem;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
}

.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-soft { background: var(--surface-2); color: var(--ink); margin-bottom: 0.6rem; }
.btn:active { filter: brightness(0.94); }

.btn-add { line-height: calc(var(--tap) - 1.8rem); }

.btn-quiet {
  display: block;
  width: 100%;
  min-height: 56px;
  margin-top: 0.4rem;
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 1rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* ----------------------------------------------------------- date screen -- */

.date-body {
  padding: 0.2rem var(--pad) calc(env(safe-area-inset-bottom) + 1.2rem);
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.date-photo {
  width: 76px;
  height: 76px;
  border-radius: 12px;
  object-fit: cover;
  align-self: center;
  background: var(--surface-2);
}

.prompt {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  text-align: center;
  text-wrap: balance;
}

.date-reading {
  margin: -0.25rem 0 0;
  min-height: 1.5em;
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
}

.date-reading.is-found {
  color: var(--ok);
  font-weight: 700;
}

.said {
  margin: 0;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--muted);
  min-height: 1.6em;
}

/* ---------------------------------------------------------------- wheel -- */

/* A chunky two-column wheel, never a calendar grid. Every option is also a
   plain tap target, so momentum-scrolling is never the only way to use it. */

.wheel {
  position: relative;
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 14px;
  padding: 0 0.5rem;
  overflow: hidden;
}

.wheel-band {
  position: absolute;
  left: 0.4rem; right: 0.4rem;
  top: 50%;
  height: var(--wheel-item);
  transform: translateY(-50%);
  background: var(--surface-2);
  border-radius: 10px;
  pointer-events: none;
}

.wheel-col {
  position: relative;
  /* Exactly three whole rows: the choice, and one either side. Any other
     height clips its neighbours through the middle of the words. */
  height: calc(var(--wheel-item) * 3);
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding: var(--wheel-item) 0;
}

.wheel-col::-webkit-scrollbar { display: none; }

.wheel-opt {
  display: block;
  width: 100%;
  height: var(--wheel-item);
  scroll-snap-align: center;
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 1.25rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.12s ease;
}

.wheel-opt[aria-selected="true"] {
  color: var(--ink);
  font-weight: 750;
  font-size: 1.4rem;
}

/* ----------------------------------------------------------- item screen -- */

.item-body {
  padding: 0.4rem var(--pad) calc(env(safe-area-inset-bottom) + 2rem);
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.item-photo {
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 46dvh;
  object-fit: cover;
  border-radius: 14px;
  background: var(--surface-2);
}

.item-photo-none {
  display: grid;
  place-items: center;
  color: var(--muted);
}

.item-when { margin: 0.5rem 0 0; font-size: 1.7rem; font-weight: 750; text-align: center; }
.item-when.is-ok   { color: var(--ok); }
.item-when.is-soon { color: var(--soon); }
.item-when.is-now  { color: var(--now); }

.item-date {
  margin: 0 0 0.6rem;
  text-align: center;
  color: var(--muted);
  font-size: 1.05rem;
}

/* ---------------------------------------------------------------- sheet -- */

.sheet {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: flex-end;
  z-index: 20;
}

.sheet-panel {
  width: 100%;
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  padding: 1.3rem var(--pad) calc(env(safe-area-inset-bottom) + 1.1rem);
}

.sheet-title {
  margin: 0 0 1rem;
  font-size: 1.25rem;
  font-weight: 700;
  text-align: center;
}

/* ---------------------------------------------------------------- toast -- */

/* Undo, rather than "are you sure?" — confirmation dialogs train people to be
   frightened of tapping things. */

.toast {
  position: fixed;
  left: var(--pad); right: var(--pad);
  bottom: calc(env(safe-area-inset-bottom) + var(--tap) + 1.4rem);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 0.9rem 0.85rem 1.1rem;
  background: var(--ink);
  color: var(--ground);
  border-radius: 12px;
  font-size: 1.02rem;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.22);
}

.toast-undo {
  margin-left: auto;
  min-height: 48px;
  padding: 0 1.1rem;
  background: none;
  border: 1.5px solid currentColor;
  border-radius: 9px;
  color: inherit;
  font-weight: 700;
  cursor: pointer;
}

/* Short screens — an SE, or a phone with the URL bar showing. The escape hatch
   under the Save button has to stay reachable without scrolling; a link nobody
   scrolls to find is the dead end it exists to prevent. */
@media (max-height: 640px) {
  :root { --wheel-item: 52px; }
  .date-body { gap: 0.5rem; }
  .date-photo { width: 52px; height: 52px; }
  .prompt { font-size: 1.1rem; }
  .said { font-size: 1rem; }
  .wheel-opt { font-size: 1.15rem; }
  .wheel-opt[aria-selected="true"] { font-size: 1.28rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
