/* Malmö Street Quest
 *
 * Design constraints that drove every choice here:
 *  - Read in direct August sunlight  -> light ground, near-black ink (>=7:1)
 *  - Held one-handed with a beer     -> primary action always in the bottom bar
 *  - iOS home-screen standalone      -> safe-area insets, dvh, no overscroll
 *  - No network                      -> system fonts only, zero external assets
 */

:root {
  --ink:        #12100E;
  --ink-soft:   #574F45;
  --ground:     #FDF6EC;
  --card:       #FFFFFF;
  --line:       #E4D9C8;
  --coral:      #9E3211;   /* button fill — white on it = 7.20:1 */
  --coral-text: #8A2A0E;   /* coral used as TEXT on cream = 8.09:1 */
  --coral-dark: #7A250C;
  --teal:       #14554F;
  --gold:       #C98A16;

  --tap: 52px;                 /* > 44px iOS minimum */
  --pad: 22px;
  --radius: 16px;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior: none;          /* kill pull-to-refresh bounce */
}

body {
  background: var(--ground);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

#app {
  position: fixed;                    /* never 100vh — iOS lies about it */
  inset: 0;
  height: 100dvh;
  overflow: hidden;
}

/* ── screens ───────────────────────────────────────────── */

.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
}
.screen.is-active { display: flex; }

.body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: calc(var(--safe-t) + var(--pad)) calc(var(--safe-r) + var(--pad))
           var(--pad) calc(var(--safe-l) + var(--pad));
}
.body--center {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* Bottom action bar — every primary control lives in thumb reach. */
.bar {
  flex: none;
  padding: 14px calc(var(--safe-r) + var(--pad))
           calc(var(--safe-b) + 14px) calc(var(--safe-l) + var(--pad));
  background: linear-gradient(to top, var(--ground) 72%, transparent);
  border-top: 1px solid var(--line);
}
.bar--stack { display: grid; gap: 10px; }

.top {
  flex: none;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: calc(var(--safe-t) + 16px) calc(var(--safe-r) + var(--pad))
           14px calc(var(--safe-l) + var(--pad));
  border-bottom: 1px solid var(--line);
}
.top__text { min-width: 0; }
.top__title { margin: 0; font-size: 22px; letter-spacing: -0.02em; }
.top__eyebrow {
  margin: 0 0 2px;
  font-size: 13px;
  font-weight: 700;
  color: var(--coral-text);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── type ──────────────────────────────────────────────── */

.eyebrow {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--coral-text);
}

.hero {
  margin: 0 0 18px;
  font-size: clamp(46px, 16vw, 68px);
  line-height: 0.94;
  letter-spacing: -0.035em;
  font-weight: 800;
}
.hero--sm { font-size: clamp(32px, 10vw, 44px); line-height: 1.05; }

.lede { margin: 0 0 20px; font-size: 18px; color: var(--ink-soft); }

.promises {
  margin: 0 0 30px;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 7px;
}
.promises li {
  position: relative;
  padding-left: 24px;
  font-size: 15px;
  color: var(--teal);
  font-weight: 600;
}
.promises li::before {
  content: "✓";
  position: absolute;
  left: 0;
  font-weight: 800;
}

/* ── form ──────────────────────────────────────────────── */

.field { display: block; margin: 0 0 12px; }
.field__label {
  display: block;
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.field input {
  width: 100%;
  min-height: var(--tap);
  padding: 12px 15px;
  font: inherit;
  font-size: 18px;
  color: var(--ink);
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  appearance: none;
}
.field input:focus {
  outline: none;
  border-color: var(--teal);
}
#code-input {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  text-align: center;
}

.error {
  margin: 0 0 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: #FBE3DA;
  color: var(--coral-text);
  font-size: 15px;
  font-weight: 600;
}

/* ── buttons ───────────────────────────────────────────── */

.btn {
  display: block;
  width: 100%;
  min-height: var(--tap);
  padding: 15px 20px;
  font: inherit;
  font-size: 17px;
  font-weight: 700;
  border: 2px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.btn--primary { background: var(--coral); color: #fff; }
.btn--primary:active { background: var(--coral-dark); }
.btn--ghost {
  background: transparent;
  color: var(--teal);
  border-color: var(--line);
}
.btn--ghost:active { background: #F1E7D8; }
.btn--danger { color: var(--coral-text); margin-top: 26px; }
.btn[disabled] { opacity: 0.45; }

.btn-back {
  min-height: 44px;
  padding: 6px 4px;
  font: inherit;
  font-size: 17px;
  font-weight: 700;
  color: var(--teal);
  background: none;
  border: 0;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.btn-back span { font-size: 24px; line-height: 1; vertical-align: -2px; }

/* ── progress ring ─────────────────────────────────────── */

.ring {
  position: relative;
  flex: none;
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    conic-gradient(var(--teal) calc(var(--pct, 0) * 1%), var(--line) 0);
}
.ring::after {
  content: "";
  position: absolute;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--ground);
}
.ring__count {
  position: relative;
  z-index: 1;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

/* ── station list ──────────────────────────────────────── */

.stations { margin: 0 0 8px; padding: 0; list-style: none; display: grid; gap: 10px; }

.station {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: var(--tap);
  padding: 15px 16px;
  text-align: left;
  font: inherit;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.station:active { background: #F7EEE1; }
.station--done { border-color: var(--teal); background: #F0F6F4; }

.station__no {
  flex: none;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--line);
  color: var(--ink);
  font-size: 14px;
  font-weight: 800;
}
.station--done .station__no { background: var(--teal); color: #fff; }

.station__body { min-width: 0; flex: 1; }
.station__title { display: block; font-weight: 700; font-size: 17px; }
.station__sub {
  display: block;
  font-size: 14px;
  color: var(--ink-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── station detail ────────────────────────────────────── */

.station__name { margin: 0 0 2px; font-size: 30px; letter-spacing: -0.03em; }
.station__sv { margin: 0 0 18px; font-size: 16px; color: var(--ink-soft); font-style: italic; }
.station__task {
  margin: 0 0 24px;
  padding: 16px 18px;
  font-size: 17px;
  background: var(--card);
  border-left: 4px solid var(--gold);
  border-radius: 0 12px 12px 0;
}

.stamped { text-align: center; padding: 20px 0; }
.stamped__mark {
  margin: 0 auto 10px;
  width: 74px;
  height: 74px;
  display: grid;
  place-items: center;
  font-size: 38px;
  color: #fff;
  background: var(--teal);
  border-radius: 50%;
}
.stamped__text { margin: 0; font-weight: 600; color: var(--teal); }

/* ── done ──────────────────────────────────────────────── */

.stamp-grid {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px;
}
.stamp-grid li {
  padding: 10px 8px;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  color: var(--teal);
  background: #F0F6F4;
  border: 2px solid var(--teal);
  border-radius: 12px;
}

/* ── install hint ──────────────────────────────────────── */

.install-hint {
  margin-top: 4px;
  padding: 14px 16px;
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: #FBF0DA;
  border: 2px dashed var(--gold);
  border-radius: var(--radius);
}
.glyph {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--card);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 700;
}
