/*
 * Family Timer styles.
 * Written for old iPads too: no flex "gap", clamp(), inset or bare
 * :focus-visible (all unsupported on iOS 12 and earlier). Grid "gap" is
 * written with the older grid-gap name as well.
 */
:root {
  --bg: #F3EFE8;
  --face: #FDFBF7;
  --text: #2B2926;
  --text-soft: #67625A;
  --track: #E4DED3;
  --accent: #5F8A6E;
  --accent-strong: #46705A;
  --on-accent: #FFFFFF;
  --chip: #E9E4D9;
  --panel: #FFFFFF;
  --line: #E6E0D5;
  --focus: #3D5A80;
  --shadow: 0 8px 28px rgba(60, 50, 35, 0.09);

  /* Clock width: as large as fits above the controls (stacked layout). */
  --clock-width: max(260px, min(94vw, calc((100vh - 430px) / 0.822), 900px));
}

/* Breakfast: warm cream and one muted sunrise accent. No traffic-light colours. */
body[data-mode="breakfast"] {
  --bg: #FCF4E8;
  --face: #FFFBF4;
  --track: #F0E2CD;
  --accent: #C9763F;
  --accent-strong: #B2602B;
  --chip: #F3E8D6;
  --line: #F0E2CD;
  --shadow: 0 8px 28px rgba(120, 75, 30, 0.10);
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  font-variant-numeric: tabular-nums;
  overflow-x: hidden;
}

/* Two faint rings in the corners echo the clock face. Purely decorative. */
body::before, body::after {
  content: "";
  position: fixed;
  z-index: -1;
  border-radius: 50%;
  border: 2px solid var(--line);
  pointer-events: none;
}
body::before { width: 72vmin; height: 72vmin; right: -22vmin; top: -22vmin; }
body::after { width: 48vmin; height: 48vmin; left: -16vmin; bottom: -16vmin; }

[hidden] { display: none !important; }

p, h1, h2 { text-wrap: balance; }

.page {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
  padding-top: max(20px, env(safe-area-inset-top));
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  text-align: center;
}

.page > * { max-width: 100%; }
.page > * + * { margin-top: 14px; }

.heading h1 { margin: 0; font-size: 1.55rem; font-weight: 600; letter-spacing: -0.015em; }
.heading p { margin: 6px auto 0; max-width: 28em; color: var(--text-soft); font-size: 1.05rem; line-height: 1.35; }

/* ---------- Timer views ---------- */

.view {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  -webkit-animation: fade-in 0.6s ease;
  animation: fade-in 0.6s ease;
}

@-webkit-keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* Message, plan, length choice and button. */
.info {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 460px;
  margin-top: 12px;
}
.info > * + * { margin-top: 14px; }

.message { margin: 0; max-width: 20em; font-size: 1.35rem; line-height: 1.3; font-weight: 500; letter-spacing: -0.005em; }
.sub { margin: 0; color: var(--text-soft); font-size: 1.02rem; }
.message:empty, .sub:empty { display: none; }

/* The child's own plan, in her own words. Only appears in the last five minutes. */
.plan {
  margin: 0;
  padding: 10px 16px;
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: var(--face);
  box-shadow: 0 2px 10px rgba(60, 50, 35, 0.06);
  font-size: 1.05rem;
  line-height: 1.35;
  text-align: left;
}
.plan:empty { display: none; }

/* ---------- Clock face (shared by Breakfast and Dinner) ---------- */

.clock-wrap {
  position: relative;
  width: var(--clock-width);
  height: calc(var(--clock-width) * 0.8222); /* matches viewBox 450 x 370 */
}

.clock { width: 100%; height: 100%; overflow: visible; }

.clock-face {
  fill: var(--face);
  stroke: var(--line);
  stroke-width: 1.5;
  -webkit-filter: drop-shadow(0 6px 14px rgba(60, 50, 35, 0.10));
  filter: drop-shadow(0 6px 14px rgba(60, 50, 35, 0.10));
}

.clock-track, .clock-remaining { fill: none; stroke-width: 14; stroke-linecap: round; }
.clock-track { stroke: var(--track); }
.clock-remaining { stroke: var(--accent); }

.clock-halo { fill: var(--accent); opacity: 0.2; }
.is-final .clock-halo { opacity: 0.32; }

.clock-marker {
  fill: #FFFFFF;
  stroke: var(--accent-strong);
  stroke-width: 4;
  -webkit-filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.3));
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.3));
}

.clock-tick { stroke: var(--text-soft); stroke-width: 2; stroke-linecap: round; opacity: 0.4; }

.clock-label { font-size: 15px; fill: var(--text-soft); }
.clock-label-end { font-size: 15px; font-weight: 700; fill: var(--text); letter-spacing: 0.04em; }

/* In the last five minutes the end time simply becomes clearer. */
.is-final .clock-label-end { font-size: 17px; }

/* Centre of the face: the viewBox centre is the middle of the element. */
.clock-centre {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 42%;
  -webkit-transform: translate(-50%, -50%);
  transform: translate(-50%, -50%);
  text-align: center;
}

.clock-main { display: block; font-size: calc(var(--clock-width) * 0.125); font-weight: 300; line-height: 1.05; letter-spacing: -0.02em; }
.clock-main-end { font-size: calc(var(--clock-width) * 0.058); font-weight: 600; line-height: 1.15; letter-spacing: -0.01em; }
.clock-sub { display: block; margin-top: 6px; color: var(--text-soft); font-size: max(0.9rem, calc(var(--clock-width) * 0.034)); }
.clock-cap {
  display: block;
  margin-bottom: 6px;
  color: var(--text-soft);
  font-size: max(0.75rem, calc(var(--clock-width) * 0.024));
  font-weight: 600;
  letter-spacing: 0.16em;
}

/* ---------- Controls ---------- */

button, select, input { font: inherit; color: var(--text); }

button {
  border: 0;
  border-radius: 999px;
  min-height: 48px;
  cursor: pointer;
  touch-action: manipulation;
  transition: background-color 0.2s, -webkit-transform 0.1s, transform 0.1s;
}

button:active { -webkit-transform: scale(0.97); transform: scale(0.97); }

button:focus, select:focus, input:focus { outline: 3px solid var(--focus); outline-offset: 3px; }
button:focus:not(:focus-visible), select:focus:not(:focus-visible), input:focus:not(:focus-visible) { outline: none; }

.primary {
  background: var(--accent-strong);
  color: var(--on-accent);
  width: 100%;
  max-width: 320px;
  min-height: 64px;
  padding: 0 32px;
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  box-shadow: 0 6px 18px rgba(40, 70, 50, 0.28);
}

/* Length choice shown before dinner starts: a segmented control. */
.choice {
  display: inline-flex;
  padding: 4px;
  border-radius: 999px;
  background: var(--chip);
}
.chip {
  min-height: 44px;
  min-width: 70px;
  margin: 0;
  padding: 0 14px;
  background: transparent;
  font-size: 1.02rem;
  color: var(--text-soft);
}
.chip[aria-pressed="true"] {
  background: #FFFFFF;
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.16);
}

.settings-toggle { background: transparent; color: var(--text-soft); padding: 0 18px; font-size: 1.02rem; }
.chevron { display: inline-block; transition: -webkit-transform 0.2s, transform 0.2s; }
.settings-toggle[aria-expanded="true"] .chevron { -webkit-transform: rotate(180deg); transform: rotate(180deg); }

/* ---------- Settings ---------- */

.settings {
  width: 100%;
  max-width: 460px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 6px 22px 22px;
  text-align: left;
  box-shadow: var(--shadow);
}

.field { padding-top: 18px; }
.field + .field { margin-top: 18px; border-top: 1px solid var(--line); }
.field h2 { margin: 0 0 8px; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-soft); }
.field h2 label { font: inherit; }
.hint { margin: 8px 0 0; font-size: 0.88rem; line-height: 1.35; color: var(--text-soft); }

.presets { display: flex; flex-wrap: wrap; margin: -4px; }
.preset { background: var(--chip); min-width: 60px; margin: 4px; padding: 0 16px; font-size: 1.02rem; }
.preset[aria-pressed="true"] { background: var(--accent-strong); color: var(--on-accent); font-weight: 600; }

.custom-form { display: flex; align-items: center; margin-top: 12px; }
.custom-form > * + * { margin-left: 10px; }

input[type="number"], input[type="text"], select {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: #FFFFFF;
}
input[type="number"] { width: 90px; }

.message-fields label { display: block; margin: 12px 0 4px; font-size: 0.9rem; color: var(--text-soft); }
.message-fields { margin-bottom: 14px; }

.small-button { background: var(--chip); padding: 0 18px; font-size: 1rem; }

.back-link { display: inline-block; padding: 8px 0; color: var(--text-soft); font-size: 1rem; text-decoration: none; }
.back-link::before { content: "\2039  "; font-size: 1.2em; }

/* ---------- Landing ---------- */

body[data-mode="landing"] .heading h1 { font-size: 2.4rem; letter-spacing: -0.025em; }
body[data-mode="landing"] .heading p { font-size: 1.15rem; }

.cards {
  display: grid;
  grid-template-columns: 1fr;
  grid-gap: 16px;
  gap: 16px;
  width: 100%;
  max-width: 780px;
  margin-top: 28px;
}

@media (min-width: 640px) {
  .cards { grid-template-columns: 1fr 1fr; grid-gap: 22px; gap: 22px; }
}

.card {
  --card-bg: #FBEBD6;
  --card-bubble: #F6D6B2;
  --card-ink: #B2602B;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-height: 230px;
  padding: 28px 26px 26px;
  border-radius: 30px;
  background: var(--card-bg);
  color: var(--text);
  text-align: left;
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: -webkit-transform 0.15s, transform 0.15s;
}
.card-dinner { --card-bg: #E3EBE0; --card-bubble: #CADBC8; --card-ink: #3E6A52; }

.card:active { -webkit-transform: scale(0.98); transform: scale(0.98); }
.card:focus { outline: 3px solid var(--focus); outline-offset: 3px; }
.card:focus:not(:focus-visible) { outline: none; }

.card-icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 76px;
  height: 76px;
  margin-bottom: 22px;
  border-radius: 50%;
  background: var(--card-bubble);
  color: var(--card-ink);
}
.card-icon { width: 42px; height: 42px; }
.card-title { font-size: 1.8rem; font-weight: 650; letter-spacing: -0.02em; }
.card-text { margin-top: 6px; padding-right: 56px; color: var(--text-soft); font-size: 1.05rem; line-height: 1.35; }
.card-go {
  position: absolute;
  right: 22px;
  bottom: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--card-ink);
  color: #FFFFFF;
  font-size: 1.4rem;
}

.landing-language { display: flex; align-items: center; margin-top: 30px; color: var(--text-soft); }
.landing-language label { margin-right: 10px; font-size: 0.95rem; }
.landing-language select { width: auto; min-width: 140px; }

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

.noscript { text-align: center; }

/* ---------- Wider, landscape screens (iPad on a table): clock beside controls ---------- */

@media (min-width: 780px) and (min-aspect-ratio: 5/4) {
  :root { --clock-width: min(58vw, calc((100vh - 190px) / 0.822), 900px); }

  .view { flex-direction: row; justify-content: center; }
  .info {
    width: min(34vw, 400px);
    margin-top: 0;
    margin-left: 36px;
    align-items: flex-start;
    text-align: left;
  }
  .message { font-size: 1.7rem; }
  .sub { font-size: 1.1rem; }
  .plan { font-size: 1.1rem; }
  .primary { max-width: none; }
}

@media (min-width: 700px) and (max-aspect-ratio: 5/4) {
  .message { font-size: 1.55rem; }
}

@media (max-height: 480px) {
  .heading p { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .view { -webkit-animation: none; animation: none; }
  button, .chevron, .card { transition: none; }
}
