:root {
  --bg: #f2f1ed;
  --surface: #ffffff;
  --ink: #16181d;
  --ink-2: #5b606b;
  --line: #e2e0da;
  --chip: #ecebe6;

  --dry: #17945a;
  --damp: #e0ad12;
  --puddles: #e2681a;
  --wet: #d13b3b;
  --none: #3d424c;
  --rain: #3b7fd9;

  --radius: 20px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111317;
    --surface: #1b1e24;
    --ink: #f1f2f4;
    --ink-2: #9aa0ab;
    --line: #2a2e36;
    --chip: #242831;
    --none: #2b2f37;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111317; --surface: #1b1e24; --ink: #f1f2f4; --ink-2: #9aa0ab;
  --line: #2a2e36; --chip: #242831; --none: #2b2f37; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.wrap {
  max-width: 480px;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
           calc(28px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  /* Phones: one column in reading order (the two column wrappers dissolve). */
  display: flex; flex-direction: column;
}
.col-main, .col-side { display: contents; }
.top { order: 0; } .status { order: 1; } .etq { order: 2; } .weather { order: 3; }
.report { order: 4; } .history { order: 5; } .foot { order: 6; }

/* Small tablets: a bit wider single column. */
@media (min-width: 600px) { .wrap { max-width: 560px; } }

/* Tablets landscape / desktop, and phones held sideways: status + report on the left,
   etiquette, weather, history on the right. */
@media (min-width: 900px), (orientation: landscape) and (min-width: 640px) {
  .wrap {
    max-width: 1080px; display: grid; column-gap: 32px; align-items: start;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    padding-top: max(24px, env(safe-area-inset-top));
  }
  .top, .foot { grid-column: 1 / -1; }
  .col-main, .col-side { display: block; min-width: 0; }
  .col-side > :first-child { margin-top: 0; }
  .col-side .history h2 { margin-top: 24px; }
  .gallery-item { flex-basis: 62%; }
}


/* ---------- Header ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -0.01em; min-width: 0; }
.brand span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Amigos do PdG circle badge (logo contest winner). Thin ring so the black badge reads on dark mode. */
.logo { flex: none; width: 32px; height: 32px; border-radius: 50%; display: block; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .logo { box-shadow: 0 0 0 1.5px rgba(255,255,255,.28); } }
:root[data-theme="dark"] .logo { box-shadow: 0 0 0 1.5px rgba(255,255,255,.28); }
.lang {
  position: relative; flex: none; display: inline-flex; align-items: center; gap: 4px;
  border: 1px solid var(--line); background: var(--surface);
  border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; color: var(--ink-2);
}
.lang select {
  appearance: none; -webkit-appearance: none; border: 0; background: transparent;
  font: inherit; color: inherit; padding: 0; cursor: pointer;
}
.lang:focus-within { outline: 3px solid color-mix(in srgb, var(--ink) 40%, transparent); outline-offset: 2px; }

/* ---------- Status card ---------- */
.status {
  --c: var(--none);
  background: var(--c);
  color: #fff;
  border-radius: var(--radius);
  --pad-x: 22px; /* the photo strip bleeds to the card edges by exactly this */
  padding: 22px var(--pad-x) 20px;
  transition: background-color .35s ease;
}
.status[data-cond="dry"] { --c: var(--dry); }
.status[data-cond="damp"] { --c: var(--damp); color: #241b00; }
.status[data-cond="puddles"] { --c: var(--puddles); }
.status[data-cond="wet"] { --c: var(--wet); }
.status.is-stale { filter: saturate(.35); }

.kicker { margin: 0; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; opacity: .8; }
.status h1 { margin: 2px 0 4px; font-size: clamp(44px, 14vw, 60px); line-height: 1; letter-spacing: -0.035em; font-weight: 800; }
.verdict { margin: 0; font-size: 18px; font-weight: 600; }
.meta { margin: 10px 0 0; font-size: 14px; opacity: .85; }
.meta:empty { display: none; }
.status-media:empty { display: none; }
.status-media { margin-top: 14px; }
.status-note { margin: 0 0 10px; font-size: 15px; font-style: italic; }

/* Gallery inside the status card: one = full width, several = swipe strip */
.gallery {
  display: flex; gap: 8px; overflow-x: auto; scroll-snap-type: x mandatory;
  margin: 0 calc(-1 * var(--pad-x)); padding: 0 var(--pad-x); scrollbar-width: none;
}
.gallery::-webkit-scrollbar { display: none; }
.gallery-item {
  position: relative; flex: 0 0 78%; scroll-snap-align: start; scroll-margin-left: var(--pad-x);
  padding: 0; border: 0; border-radius: 14px; overflow: hidden; background: rgba(0,0,0,.15); aspect-ratio: 4 / 3;
}
.gallery.is-single .gallery-item { flex-basis: 100%; }
.gallery-media { display: block; width: 100%; height: 100%; object-fit: cover; }

/* ---------- Weather ---------- */
.weather {
  margin-top: 12px; padding: 16px 18px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 18px;
}
.w-head { display: flex; align-items: center; gap: 12px; }
.w-icon { font-size: 34px; line-height: 1; }
.w-main p { margin: 0; }
.w-kicker { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-2); }
.w-now { font-size: 17px; }
.w-now strong { font-size: 24px; letter-spacing: -0.02em; margin-right: 4px; }
.w-details, .w-rain { margin: 8px 0 0; font-size: 14px; color: var(--ink-2); }
.w-rain { color: var(--ink); }
.w-hint {
  margin: 10px 0 0; padding: 8px 12px; border-radius: 10px; font-size: 14px; font-weight: 600;
  background: color-mix(in srgb, var(--rain) 14%, var(--surface)); color: var(--ink);
}
.w-next { margin-top: 12px; }
.w-label { margin: 0 0 6px; font-size: 12px; font-weight: 600; color: var(--ink-2); }
.w-hours { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.w-hour { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 12px; font-variant-numeric: tabular-nums; }
.w-bar { position: relative; width: 100%; height: 34px; border-radius: 6px; background: var(--chip); overflow: hidden; }
.w-bar span { position: absolute; left: 0; right: 0; bottom: 0; background: color-mix(in srgb, var(--rain) 35%, var(--chip)); }
.w-hour[data-level="mid"] .w-bar span { background: color-mix(in srgb, var(--rain) 65%, var(--chip)); }
.w-hour[data-level="high"] .w-bar span { background: var(--rain); }
.w-pct { font-weight: 600; }
.w-hour time { color: var(--ink-2); }
.w-src { margin: 10px 0 0; font-size: 11px; text-align: right; }
.w-src a { color: var(--ink-2); }

/* ---------- Skatepark etiquette ---------- */
.etq { margin-top: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; }
.etq summary {
  list-style: none; cursor: pointer; padding: 14px 18px;
  display: flex; align-items: center; gap: 12px;
}
.etq summary::-webkit-details-marker { display: none; }
.etq summary::after { content: '+'; margin-left: auto; font-size: 24px; font-weight: 500; color: var(--ink-2); }
.etq[open] summary::after { content: '−'; }
.etq summary:focus-visible { outline: 3px solid color-mix(in srgb, var(--ink) 40%, transparent); outline-offset: 2px; border-radius: 18px; }
.etq-icon { font-size: 26px; line-height: 1; }
.etq-sum { display: flex; flex-direction: column; min-width: 0; }
.etq-sum strong { font-size: 17px; }
.etq-sum small { font-size: 13px; color: var(--ink-2); }
.etq-list { list-style: none; margin: 0; padding: 0 18px 10px; }
.etq-list li { display: grid; grid-template-columns: 26px 1fr; gap: 8px; padding: 9px 0; border-top: 1px solid var(--line); font-size: 15px; }

/* ---------- Report ---------- */
h2 { font-size: 17px; letter-spacing: -0.01em; margin: 28px 0 12px; }

.conds { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cond {
  --c: var(--ink);
  display: flex; flex-direction: column; align-items: flex-start; gap: 18px;
  padding: 16px; min-height: 108px;
  background: var(--surface); border: 2px solid var(--line); border-radius: 18px;
  font-size: 18px; font-weight: 700; text-align: left;
  transition: border-color .15s, background-color .15s, transform .1s;
}
.cond:active { transform: scale(.97); }
.cond svg { width: 30px; height: 30px; fill: none; stroke: var(--c); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.cond[data-cond="dry"] { --c: var(--dry); }
.cond[data-cond="damp"] { --c: var(--damp); }
.cond[data-cond="puddles"] { --c: var(--puddles); }
.cond[data-cond="wet"] { --c: var(--wet); }
.cond[aria-checked="true"] { border-color: var(--c); background: color-mix(in srgb, var(--c) 12%, var(--surface)); }
.cond:focus-visible, .chip:focus-visible, .send:focus-visible, .media-btn:focus-within { outline: 3px solid color-mix(in srgb, var(--ink) 40%, transparent); outline-offset: 2px; }

.extras {
  margin-top: 14px; padding: 16px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 18px;
  animation: rise .22s ease-out;
}
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

.tags { border: 0; padding: 0; margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 8px; }
.tags legend { padding: 0; margin-bottom: 8px; font-size: 13px; color: var(--ink-2); font-weight: 600; }
.chip {
  border: 1px solid transparent; background: var(--chip);
  border-radius: 999px; padding: 8px 14px; font-size: 15px; font-weight: 500;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); }

.note {
  width: 100%; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg); font-size: 16px;
}
.note:focus { outline: 2px solid color-mix(in srgb, var(--ink) 35%, transparent); outline-offset: 0; }

.media-row { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.media-btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 10px 14px; border-radius: 12px; border: 1.5px dashed var(--line);
  font-weight: 600; font-size: 15px;
}
.media-btn input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.media-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linejoin: round; }
.clear {
  position: absolute; top: -8px; right: -8px; width: 24px; height: 24px; border-radius: 50%;
  border: 0; background: var(--ink); color: var(--bg); font-size: 15px; line-height: 1;
}
.media-count { font-size: 14px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 10px; margin-top: 12px; }
.pick { position: relative; aspect-ratio: 1; }
.pick img, .pick video { display: block; width: 100%; height: 100%; object-fit: cover; border-radius: 10px; background: var(--chip); }
.pick .play { border-radius: 10px; pointer-events: none; }
.hint { margin: 8px 0 0; font-size: 13px; color: var(--ink-2); }

.send {
  --c: var(--ink);
  width: 100%; margin-top: 16px; padding: 16px; border: 0; border-radius: 14px;
  background: var(--c); color: #fff; font-size: 18px; font-weight: 700;
}
.extras[data-cond="dry"] .send { --c: var(--dry); }
.extras[data-cond="damp"] .send { --c: var(--damp); color: #241b00; }
.extras[data-cond="puddles"] .send { --c: var(--puddles); }
.extras[data-cond="wet"] .send { --c: var(--wet); }
.send:disabled { opacity: .7; }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.tl-item {
  --c: var(--none);
  display: grid; grid-template-columns: 12px 1fr auto; gap: 12px; align-items: start;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.tl-item[data-cond="dry"] { --c: var(--dry); }
.tl-item[data-cond="damp"] { --c: var(--damp); }
.tl-item[data-cond="puddles"] { --c: var(--puddles); }
.tl-item[data-cond="wet"] { --c: var(--wet); }
.tl-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--c); margin-top: 5px; }
.tl-head { display: flex; justify-content: space-between; gap: 8px; }
.tl-head time { color: var(--ink-2); font-size: 14px; font-variant-numeric: tabular-nums; }
.tl-tags { font-size: 14px; color: var(--ink-2); }
.tl-note { margin: 4px 0 0; font-size: 15px; overflow-wrap: anywhere; }
/* Reporter's own report: delete control (only on the phone that made it, for 24 h). */
.tl-own { display: flex; align-items: center; gap: 10px; margin-top: 6px; font-size: 13px; color: var(--ink-2); }
.tl-del, .own-del {
  border: 1px solid currentColor; background: transparent; border-radius: 999px;
  padding: 6px 12px; min-height: 32px; font-size: 13px; font-weight: 600; line-height: 1;
}
.tl-del { color: var(--wet); }
.own-del { display: block; margin-top: 14px; color: inherit; opacity: .9; }
.tl-del:disabled, .own-del:disabled { opacity: .45; }
.tl-thumb { position: relative; padding: 0; border: 0; background: none; border-radius: 10px; overflow: hidden; }
.tl-media { display: block; width: 56px; height: 56px; object-fit: cover; background: var(--chip); }
.play {
  position: absolute; inset: 0; display: grid; place-items: center;
  color: #fff; font-size: 16px; background: rgba(0,0,0,.25);
}
.more {
  position: absolute; right: 4px; bottom: 4px; padding: 1px 6px; border-radius: 99px;
  background: rgba(0,0,0,.65); color: #fff; font-size: 12px; font-weight: 700;
}
.empty { color: var(--ink-2); margin: 0; }

.foot { margin-top: 28px; font-size: 13px; color: var(--ink-2); text-align: center; }

/* ---------- Toast + viewer ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 12px;
  background: var(--ink); color: var(--bg); font-weight: 600; box-shadow: 0 8px 30px rgba(0,0,0,.2);
  animation: rise .2s ease-out; z-index: 10;
}
.toast[data-kind="error"] { background: var(--wet); color: #fff; }


.viewer {
  width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none; margin: 0;
  border: 0; padding: 0; background: rgba(0,0,0,.92); color: #fff;
}
.viewer::backdrop { background: rgba(0,0,0,.92); }
.viewer-track {
  display: flex; width: 100%; height: 100%; overflow-x: auto;
  scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior: contain;
}
.viewer-track::-webkit-scrollbar { display: none; }
/* Media fills the slide box and is letterboxed with object-fit, so it always fits the
   screen in portrait and landscape (max-height % inside a grid cell was ignored → huge zoom). */
/* Equal top/bottom padding so the media is centred on the screen, level with the prev/next arrows. */
.viewer-slide {
  --pad-y: calc(60px + max(env(safe-area-inset-top), env(safe-area-inset-bottom)));
  flex: 0 0 100%; height: 100%; min-width: 0; scroll-snap-align: center; scroll-snap-stop: always;
  display: flex; align-items: center; justify-content: center;
  padding: var(--pad-y) calc(8px + env(safe-area-inset-right)) var(--pad-y) calc(8px + env(safe-area-inset-left));
}
.viewer-slide img { display: block; width: 100%; height: 100%; object-fit: contain; }
/* Video box hugs the video, so its controls sit right under the picture (not at the screen bottom). */
.viewer-slide video { display: block; width: auto; height: auto; max-width: 100%; max-height: 100%; min-width: 0; min-height: 0; }
/* Phone sideways: little height, so move the chrome to the sides instead of top/bottom. */
@media (orientation: landscape) and (max-height: 500px) {
  .viewer-slide {
    --pad-y: calc(8px + max(env(safe-area-inset-top), env(safe-area-inset-bottom)));
    padding: var(--pad-y) calc(60px + env(safe-area-inset-right)) var(--pad-y) calc(60px + env(safe-area-inset-left));
  }
  .viewer .viewer-count { top: auto; left: calc(14px + env(safe-area-inset-left)); bottom: calc(12px + env(safe-area-inset-bottom)); transform: none; }
}
.viewer-close, .viewer-nav {
  position: fixed; width: 44px; height: 44px; border-radius: 50%; border: 0;
  background: rgba(255,255,255,.15); color: #fff; font-size: 26px; line-height: 1;
}
.viewer-close { top: calc(10px + env(safe-area-inset-top)); right: 10px; }
.viewer-nav { top: 50%; transform: translateY(-50%); }
.viewer-nav.prev { left: 10px; }
.viewer-nav.next { right: 10px; }
.viewer-count {
  position: fixed; top: calc(20px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; opacity: .85;
}
/* Prev/next stay visible on phones too (swipe works as well). */
@media (hover: none) { .viewer-nav { width: 48px; height: 48px; background: rgba(255,255,255,.18); } }
/* While the viewer is open the page behind it is frozen (iOS needs position: fixed). */
html.viewer-open, html.viewer-open body { overflow: hidden; overscroll-behavior: none; }
html.viewer-open body { position: fixed; left: 0; right: 0; width: 100%; }
.viewer { overscroll-behavior: contain; }
.viewer-track { overflow-y: hidden; touch-action: pan-x pinch-zoom; }
.viewer-box { width: 100%; height: 100%; }
/* In real fullscreen the box inside the dialog is the fullscreen element: black, edge to edge. */
.viewer-box:fullscreen { width: 100vw; height: 100vh; background: #000; }
.viewer-box:-webkit-full-screen { width: 100vw; height: 100vh; background: #000; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* Phones sideways (short screens): tighter vertical rhythm so a useful amount fits on screen. */
@media (orientation: landscape) and (max-height: 500px) {
  .wrap { column-gap: 20px; padding-top: max(10px, env(safe-area-inset-top)); }
  .top { margin-bottom: 10px; }
  .status { --pad-x: 18px; padding: 16px var(--pad-x); }
  .status h1 { font-size: 44px; }
  .verdict { font-size: 16px; }
  .gallery-item { aspect-ratio: 16 / 9; }
  .cond { min-height: 0; flex-direction: row; align-items: center; gap: 10px; padding: 12px 14px; }
  .cond svg { width: 24px; height: 24px; flex: none; }
  h2 { margin: 18px 0 10px; }
  .col-side .history h2 { margin-top: 18px; }
}
