/* Plain Steps styles. Sizes are in rem so they follow the user's system font size
   and the in-app text-size setting. No fixed heights that could clip text. */

:root {
  --bg: #ffffff;
  --surface: #f2f5f9;
  --border: #5b6676;
  --text: #11161d;          /* 17:1 on --bg */
  --text-muted: #3b4452;    /* 9:1 on --bg */
  --primary: #0a4a99;       /* 8.9:1 against white text */
  --on-primary: #ffffff;
  --secondary-bg: #ffffff;
  --secondary-text: #0a4a99;
  --stuck: #9a2b00;         /* 8.2:1 against white text */
  --on-stuck: #ffffff;
  --caution-bg: #fff3c4;
  --caution-text: #4a3500;
  --focus: #b35c00;
  --radius: 0.75rem;
  --tap: 3rem;              /* 48px at default; grows with text size */
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10141a;
    --surface: #1b222c;
    --border: #98a3b3;
    --text: #f4f7fb;        /* 16:1 on --bg */
    --text-muted: #c8d0db;  /* 11:1 on --bg */
    --primary: #9ccbff;     /* dark text on it: 10:1 */
    --on-primary: #08121f;
    --secondary-bg: #10141a;
    --secondary-text: #9ccbff;
    --stuck: #ffb08a;
    --on-stuck: #2b0d00;
    --caution-bg: #3d3000;
    --caution-text: #ffe9a3;
    --focus: #ffd166;
  }
}

/* Text size: 20px base at "normal" (125% of the 16px browser default), and the
   percentage keeps following the user's system font size. */
html { font-size: 125%; }
html[data-text-size="large"] { font-size: 150%; }
html[data-text-size="xlarge"] { font-size: 175%; }

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari",
    "Mangal", sans-serif;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

main {
  max-width: 40rem;
  margin: 0 auto;
  padding: 1rem;
}
main:focus { outline: none; }

h1 { font-size: 1.6rem; line-height: 1.25; margin: 0.5rem 0 1rem; }
h2 { font-size: 1.25rem; line-height: 1.3; margin: 0 0 0.5rem; }
p { margin: 0 0 1rem; }
.hint { color: var(--text-muted); font-size: 0.9rem; }

.view { display: block; }
.stack { display: flex; flex-direction: column; gap: 0.75rem; }
.footer-actions { margin-top: 2rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}

/* Buttons: native <button> and <a>, both styled the same. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 0.5rem 1.25rem;
  border: 2px solid var(--primary);
  border-radius: var(--radius);
  font: inherit;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-secondary { background: var(--secondary-bg); color: var(--secondary-text); }
.btn-stuck { background: var(--stuck); color: var(--on-stuck); border-color: var(--stuck); }

/* Form controls */
fieldset.field { border: 1px solid var(--border); border-radius: var(--radius); margin: 0 0 1rem; padding: 0.5rem 1rem 0.75rem; }
fieldset.field legend { font-weight: 700; padding: 0 0.25rem; }
.field { margin-bottom: 1rem; }
.choice { display: flex; align-items: center; gap: 0.75rem; min-height: var(--tap); }
.choice input { width: 1.5rem; height: 1.5rem; flex: none; accent-color: var(--primary); }
.choice label { flex: 1; padding: 0.4rem 0; }

/* Focus: visible everywhere, high contrast in both themes. */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}
h1:focus { outline: none; }

/* Skip link appears only on keyboard focus. */
.skip-link {
  position: absolute;
  left: 0.5rem;
  top: -4rem;
  background: var(--primary);
  color: var(--on-primary);
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  z-index: 10;
}
.skip-link:focus { top: 0.5rem; }

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

.noscript { padding: 1rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---- Guides, forms, dialogs ---- */
.btn-big { min-height: 4rem; font-size: 1.15rem; width: 100%; }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.plain-list { list-style: none; margin: 0 0 1rem; padding: 0; }
.guide-card h2 { font-size: 1.4rem; }

label { display: block; font-weight: 600; margin-bottom: 0.25rem; }
.choice label { display: block; margin: 0; font-weight: 400; }
input[type="text"], input[type="tel"], textarea {
  display: block;
  width: 100%;
  min-height: var(--tap);
  padding: 0.6rem 0.75rem;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
}
textarea { resize: vertical; }
[aria-invalid="true"] { border-color: var(--stuck); }
.error-text { color: var(--stuck); font-weight: 600; margin: 0 0 0.25rem; }
.error-card { border-color: var(--stuck); border-width: 2px; }
.error-card ul { margin: 0; padding-left: 1.25rem; }
.step-card h3 { font-size: 1.1rem; margin: 0 0 0.5rem; }
.field > .hint { margin: 0 0 0.35rem; }

dialog.dialog {
  max-width: min(32rem, calc(100vw - 2rem));
  padding: 1.25rem;
  color: var(--text);
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
}
dialog.dialog::backdrop { background: rgba(0, 0, 0, 0.6); }

/* ---- Player ---- */
.notice {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
}
.player-top { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.5rem; }
.player-top .btn { flex: none; white-space: nowrap; }
.player-title { font-size: 1rem; font-weight: 600; margin: 0; color: var(--text-muted); }
.step-heading { font-size: 1.25rem; margin: 0.5rem 0; }
.step-heading:focus { outline: none; }
.step-progress { display: block; width: 100%; height: 0.75rem; margin-bottom: 1rem; accent-color: var(--primary); }
.step-text { font-size: 1.5rem; line-height: 1.4; font-weight: 500; margin: 1rem 0; }
.photo-button { display: block; width: 100%; padding: 0; background: none; border: 2px solid var(--border); border-radius: var(--radius); font: inherit; color: var(--text); cursor: pointer; overflow: hidden; line-height: 1.5; }
.photo-hint { display: block; padding: 0.5rem; text-align: center; }
.photo-dialog { width: min(40rem, calc(100vw - 1rem)); text-align: center; }
.photo-dialog .photo-frame { margin-bottom: 1rem; }
.caution {
  background: var(--caution-bg);
  color: var(--caution-text);
  border: 3px solid var(--caution-text);
  border-radius: var(--radius);
  padding: 0.5rem 1rem;
  font-size: 1.2rem;
  margin: 0.5rem 0;
}
.read-row { margin-bottom: 1rem; }
.action-bar {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 1rem -1rem 0;
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
  background: var(--bg);
  border-top: 2px solid var(--border);
}
.action-bar-row { display: flex; gap: 0.75rem; }
.action-bar-row .btn { flex: 1; min-height: 3.5rem; padding-inline: 0.5rem; }
.btn-next { min-height: 4.5rem; font-size: 1.4rem; width: 100%; }
html[data-text-size="xlarge"] .btn-next { min-height: 4rem; font-size: 1.25rem; }
.done-title { font-size: 2.2rem; margin-top: 2rem; }
.done-time { font-size: 1.3rem; }

/* On short screens (landscape) the bar scrolls with the page instead of eating the view.
   Media queries ignore the in-app text size, so this is in real pixels. */
@media (max-height: 640px) {
  .action-bar { position: static; }
}

/* ---- Photos, marker, voice notes, warnings ---- */
.photo-frame { position: relative; display: block; width: 100%; margin: 0 auto; line-height: 0; }
.photo-img { display: block; width: 100%; height: auto; border-radius: calc(var(--radius) - 2px); }
.photo-frame.fit { width: fit-content; max-width: 100%; }
.photo-frame.fit .photo-img { width: auto; max-width: 100%; max-height: 70vh; }
.photo-tap { position: absolute; inset: 0; width: 100%; height: 100%; padding: 0; background: transparent; border: 0; cursor: crosshair; }
.photo-tap:focus-visible { outline-offset: -3px; }

/* High-contrast ring: bright inner ring plus dark outer ring, visible on any photo. */
.marker-ring {
  position: absolute;
  width: 3.25rem;
  height: 3.25rem;
  transform: translate(-50%, -50%);
  border: 0.35rem solid #ffe000;
  border-radius: 50%;
  box-shadow: 0 0 0 0.2rem #000, inset 0 0 0 0.2rem #000;
  pointer-events: none;
}
@media (prefers-reduced-motion: no-preference) {
  .marker-ring { animation: ring-pulse 1.4s ease-in-out infinite; }
}
@keyframes ring-pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.25); }
}

.media-field { margin-bottom: 1rem; }
.media-field legend { font-weight: 700; }
.voice-status { margin: 0.25rem 0 0.5rem; font-weight: 600; }
.voice-status.recording { color: var(--stuck); }
.notice.warning { background: var(--caution-bg); color: var(--caution-text); border-color: var(--caution-text); margin-bottom: 0.5rem; }
.notice[hidden] { display: none; }

.expected h3 { font-size: 1.1rem; margin: 0 0 0.5rem; }
.expected-text { font-size: 1.35rem; margin: 0 0 0.75rem; }
.expected-question { font-weight: 700; margin: 0 0 0.75rem; }
.yes-no .btn { flex: 1; min-height: 4rem; font-size: 1.25rem; }
.media-field .btn-row { margin: 0.5rem 0; }
.media-field .field { margin-top: 0.75rem; }
