/* Dago Social Club - Padel Match Roll
   Four colours, the club's own, and nothing else: forest, lime, cream and orange. Forest is the body of the
   camera and of every screen that frames a photo; cream is the text on it and the ground of the roll page;
   lime is the quiet voice (secondary text, the chosen film, the roll counter); orange is only ever the main
   action. Square corners, flat colour, no hairlines or shadows. Labels are sentence case.
   Contrast, all measured: cream on forest 10.9, lime on forest 8.1, forest on cream 10.9, forest on lime 8.1.
   Forest on orange is 3.2, so every orange button carries its label at 24px (large text needs 3). */

@font-face { font-family: "Bricolage Grotesque"; font-weight: 400; font-display: swap;
  src: url("../fonts/bricolage-grotesque-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Bricolage Grotesque"; font-weight: 600; font-display: swap;
  src: url("../fonts/bricolage-grotesque-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Figtree"; font-weight: 400; font-display: swap;
  src: url("../fonts/figtree-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Figtree"; font-weight: 500; font-display: swap;
  src: url("../fonts/figtree-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Figtree"; font-weight: 600; font-display: swap;
  src: url("../fonts/figtree-latin-600-normal.woff2") format("woff2"); }

:root {
  --forest: #144033;
  --lime: #c8e199;
  --cream: #fbf8f1;
  --orange: #d96528;
  --font-display: "Bricolage Grotesque", system-ui, sans-serif;
  --font-text: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --top: env(safe-area-inset-top, 0px);
  --bottom: env(safe-area-inset-bottom, 0px);
  --control: 56px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html, body { height: 100%; background: var(--forest); color: var(--cream); font-family: var(--font-text);
  font-size: 16px; line-height: 1.5; -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
body { overflow: hidden; }

button { font: inherit; color: inherit; background: none; border: 0; border-radius: 0; cursor: pointer;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: square; stroke-linejoin: miter; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Buttons: one shape. Lime is the quiet one, orange is the main action ---------- */
.btn { width: 100%; min-height: var(--control); padding: 0 24px; border-radius: 2px; display: inline-flex; align-items: center; justify-content: center;
  font: 500 17px/1.2 var(--font-text); text-align: center; background: var(--lime); color: var(--forest); }
.btn--primary { background: var(--orange); font: 600 24px/1.1 var(--font-text); }
.btn:disabled { opacity: 0.5; }
.btn:active, .roll-btn:active, .icon-btn:active { transform: scale(0.98); }
@media (hover: hover) { .btn:not(:disabled):hover { box-shadow: inset 0 -4px 0 var(--forest); } }

/* ---------- Camera ---------- */
.cam { position: fixed; inset: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; row-gap: 12px;
  padding: calc(var(--top) + 8px) 0 calc(var(--bottom) + 12px); background: var(--forest); color: var(--cream);
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 16px; min-height: 48px; }
.who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.who-mark { flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--forest); }
.who-name { font: 400 22px/1.05 var(--font-display); letter-spacing: -0.025em; white-space: nowrap; }
.who-sub { margin-top: 3px; font: 500 13px/1.2 var(--font-text); color: var(--lime); white-space: nowrap; }

/* The roll counter: lime while there is film, a cream chip with an orange number when it runs low. */
.counter { flex: none; display: flex; align-items: baseline; gap: 6px; padding: 7px 12px 6px; border-radius: 2px;
  background: var(--lime); color: var(--forest); }
.counter-num { font: 600 24px/1 var(--font-display); letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.counter-unit { font: 500 13px/1 var(--font-text); }
.counter.low { background: var(--cream); }
.counter.low .counter-num { color: var(--orange); }

/* Full frame: the viewfinder is the whole screen and the photo has the same shape. The header, the film
   picker and the controls float over it; a soft forest scrim keeps their text readable. */
.finder { position: absolute; inset: 0; z-index: 0; }
.frame { --w: 360px; --grain: 0.03; --vig: 0.2;
  position: relative; overflow: hidden; background: var(--forest); width: 100%; height: 100%; }
.cam::before { content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(to bottom, rgba(20, 64, 51, 0.72), rgba(20, 64, 51, 0) 20%, rgba(20, 64, 51, 0) 52%, rgba(20, 64, 51, 0.9)); }
.top { grid-row: 1; position: relative; z-index: 2; }
.picker { grid-row: 3; position: relative; z-index: 2; }
/* The film picker is a dropdown: one pill naming the current film, and the live strip only while it is open. */
.picker { grid-template-columns: auto 1fr; align-items: center; }
.picker > :not(.film-toggle):not(.zoom) { grid-column: 1 / -1; }
.film-toggle { grid-column: 1; margin-left: 16px; display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 12px;
  border-radius: 2px; background: var(--cream); color: var(--forest); }
/* Zoom steps, like the iPhone camera: small round buttons, the chosen one in lime. */
.zoom { grid-column: 2; justify-self: end; margin-right: 16px; display: flex; gap: 6px; }
.zoom[hidden] { display: none; }
.zoom-btn { width: 40px; height: 40px; border-radius: 50%; background: rgba(20, 64, 51, 0.72); color: var(--cream); font: 600 14px/1 var(--font-text); }
.zoom-btn[aria-pressed="true"] { background: var(--lime); color: var(--forest); }
.film-toggle-name { font: 600 15px/1 var(--font-text); }
.film-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; transition: transform 0.2s ease; }
.picker.open .film-toggle svg { transform: rotate(180deg); }
.picker:not(.open) .films, .picker:not(.open) .props, .picker:not(.open) .picker-tabs { display: none; }
.controls { grid-row: 4; z-index: 2; }

.frame video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; transition: filter 0.2s ease;
  transform: scale(var(--zoom, 1)); }
.frame video.mirror { transform: scaleX(-1) scale(var(--zoom, 1)); }
/* The 3D padel props: a transparent WebGL layer over the video that takes the drag and pinch. */
.props-layer { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; }

/* The film look of the picture itself (grain, vignette) is photographic, not interface: it stays neutral. */
.fx { position: absolute; inset: 0; pointer-events: none; }
.fx-grain { background-size: 160px 160px; mix-blend-mode: overlay; opacity: calc(var(--grain) * 7); }
.fx-vignette { background: radial-gradient(ellipse at center, transparent 45%, rgba(0, 0, 0, var(--vig)) 100%); }

.flash { position: absolute; inset: 0; background: var(--cream); opacity: 0; pointer-events: none; transition: opacity 0.3s ease-out; }
.flash.on { opacity: 0.85; transition: none; }

/* The camera cannot show a picture: a lime panel, text first, actions below. */
.finder-msg { position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; justify-content: flex-end; gap: 12px;
  padding: calc(var(--top) + 72px) 20px calc(var(--bottom) + 300px); background: var(--lime); color: var(--forest); }
.msg-title { font: 400 28px/1.1 var(--font-display); letter-spacing: -0.025em; }
.msg-body { font-size: 16px; line-height: 1.5; max-width: 34ch; }
.msg-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.msg-actions .btn { background: var(--cream); }
.msg-actions .btn--primary { background: var(--orange); }

/* ---------- Films: each one is a live preview, graded with that film ---------- */
.picker { display: grid; gap: 6px; min-height: 0; }
.picker-tabs { display: flex; align-items: center; gap: 20px; padding: 0 16px; }
.tab { padding: 8px 0 6px; border-bottom: 3px solid transparent; font: 500 15px/1 var(--font-text); color: var(--lime); }
.tab[aria-selected="true"] { color: var(--cream); font-weight: 600; border-bottom-color: var(--lime); }
.picker-hint { margin-left: auto; font: 400 13px/1.2 var(--font-text); color: var(--lime); }
.films, .props { display: flex; gap: 8px; padding: 0 16px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.films::-webkit-scrollbar, .props::-webkit-scrollbar { display: none; }
.props-status { align-self: center; font-size: 14px; line-height: 1.4; color: var(--lime); }
.film { flex: none; display: grid; width: 62px; padding-bottom: 6px; border-bottom: 3px solid transparent; color: var(--lime); text-align: left; }
.film-thumb { display: block; width: 100%; height: auto; aspect-ratio: 3 / 4; margin-bottom: 6px; background: var(--cream); }
.film-name { font: 500 13px/1.25 var(--font-text); white-space: nowrap; }
.film-iso { font: 400 13px/1.25 var(--font-text); }
.film.active { border-bottom-color: var(--lime); color: var(--cream); }
.film.active .film-name { font-weight: 600; }

/* ---------- Controls: roll, shutter, flip ---------- */
.controls { position: relative; display: grid; grid-template-columns: var(--control) 1fr var(--control); gap: 8px; padding: 0 16px; }

/* The print: a cream card with the shot in it, a little crooked like a Polaroid. It rises out of the roll
   button after every shot, waits a moment to be tapped, then slides back into the roll. */
.print { position: absolute; z-index: 3; left: 16px; bottom: calc(var(--control) + 10px); width: 84px; padding: 6px 6px 18px;
  background: var(--cream); transform-origin: 20% 100%; opacity: 0; pointer-events: none; }
.print img { display: block; width: 100%; height: auto; aspect-ratio: 3 / 4; object-fit: cover; background: var(--forest); }
.print.show { pointer-events: auto; animation: print-rise 0.42s cubic-bezier(0.2, 0.9, 0.25, 1.1) forwards; }
.print.away { pointer-events: none; animation: print-away 0.36s cubic-bezier(0.5, 0, 0.9, 0.4) forwards; }
@keyframes print-rise {
  from { opacity: 0; transform: translateY(46px) scale(0.6) rotate(0deg); }
  to { opacity: 1; transform: translateY(0) scale(1) rotate(-3deg); }
}
@keyframes print-away {
  from { opacity: 1; transform: translateY(0) scale(1) rotate(-3deg); }
  to { opacity: 0; transform: translateY(46px) scale(0.5) rotate(0deg); }
}
.roll-btn, .icon-btn { position: relative; width: var(--control); height: var(--control); display: grid; place-items: center;
  border-radius: 2px; background: var(--cream) center / cover no-repeat; color: var(--forest); }
.roll-btn.has-photo svg { display: none; }
.roll-badge { position: absolute; top: 0; right: 0; min-width: 22px; height: 22px; padding: 0 6px; display: grid; place-items: center;
  background: var(--lime); color: var(--forest); font: 600 13px/1 var(--font-text); }
/* The shutter is the round iPhone one: a cream ring around a cream disc that dips when pressed. */
.shutter { justify-self: center; width: 76px; height: 76px; margin-top: -10px; border-radius: 50%; display: grid; place-items: center;
  border: 4px solid var(--cream); background: transparent; }
.shutter-disc { display: block; width: 58px; height: 58px; border-radius: 50%; background: var(--cream); transition: transform 0.1s ease; }
.shutter:active .shutter-disc { transform: scale(0.88); }
.shutter:disabled { opacity: 0.5; }

/* ---------- Intro: the club's forest, its name in cream and lime, one orange button ---------- */
.intro { position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column; justify-content: space-between; gap: 32px;
  padding: calc(var(--top) + 24px) 24px calc(var(--bottom) + 24px); background: var(--forest); color: var(--cream); overflow-y: auto; }
.intro-mark { flex: none; width: 72px; height: 72px; border-radius: 50%; background: var(--forest); }
.intro-title { font: 400 clamp(46px, 15vw, 68px)/0.98 var(--font-display); letter-spacing: -0.03em; }
.intro-title span { display: block; color: var(--lime); }
.intro-title:focus { outline: none; }
.intro-lead { margin-top: 16px; max-width: 30ch; font-size: 18px; line-height: 1.5; }
.intro-form { display: flex; flex-direction: column; gap: 16px; width: 100%; max-width: 440px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field span { font: 500 13px/1.2 var(--font-text); color: var(--lime); }
.field input { height: var(--control); padding: 0 16px; border: 0; border-radius: 2px; background: var(--cream); color: var(--forest);
  font: 400 17px var(--font-text); -webkit-user-select: text; user-select: text; }
.field input::placeholder { color: var(--forest); opacity: 0.6; }
.intro-consent { display: flex; flex-direction: column; gap: 8px; }
.check { display: flex; align-items: center; gap: 12px; min-height: 44px; font: 500 16px/1.3 var(--font-text); cursor: pointer; }
.check input { flex: none; width: 22px; height: 22px; accent-color: var(--orange); }
.intro-fine { font-size: 14px; line-height: 1.5; color: var(--lime); }

/* ---------- Roll page (cream) and photo viewer (forest) ---------- */
.page { position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column; background: var(--cream); color: var(--forest); }
.page-bar { flex: none; padding: calc(var(--top) + 4px) 4px 0; }
.text-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 48px; padding: 0 12px; font: 500 16px/1 var(--font-text); }
.page-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 16px calc(var(--bottom) + 24px); }
.page-title { font: 400 44px/1 var(--font-display); letter-spacing: -0.03em; }
.page-meta { margin-top: 8px; font-size: 15px; line-height: 1.4; }
.page-empty { margin-top: 32px; font-size: 16px; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 20px; }
.tile { position: relative; aspect-ratio: 3 / 4; overflow: hidden; background: var(--forest); }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tag { position: absolute; left: 0; bottom: 0; padding: 4px 8px; background: var(--lime); color: var(--forest); font: 500 13px/1.2 var(--font-text); }

.viewer { z-index: 50; background: var(--forest); color: var(--cream); }
.viewer-stage { flex: 1; min-height: 0; display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); place-items: center; padding: 8px 16px; }
.viewer-stage img { max-width: 100%; max-height: 100%; display: block; -webkit-touch-callout: default; -webkit-user-select: auto; user-select: auto; }
.viewer-actions { display: grid; gap: 8px; width: 100%; max-width: 440px; margin: 0 auto; padding: 8px 16px 0; }
.viewer-hint { padding: 12px 16px calc(var(--bottom) + 16px); font-size: 14px; line-height: 1.4; color: var(--lime); text-align: center; }
.viewer-actions:last-child { padding-bottom: calc(var(--bottom) + 16px); }

/* ---------- Toast: lime reads on both forest and cream ---------- */
.toast { position: fixed; z-index: 70; top: calc(var(--top) + 12px); left: 16px; right: 16px; max-width: 440px; margin: 0 auto;
  padding: 14px 16px; background: var(--lime); color: var(--forest); font: 500 15px/1.3 var(--font-text);
  opacity: 0; transform: translateY(-8px); pointer-events: none; transition: opacity 0.2s ease, transform 0.2s ease; }
.toast.show { opacity: 1; transform: none; }

/* ---------- Wide screens (laptop, tablet): keep the camera body phone-sized, on cream ---------- */
@media (min-width: 560px) and (min-height: 521px) {
  html, body { background: var(--cream); }
  .cam { inset: 0 calc((100vw - 520px) / 2); }
  .page-scroll, .page-bar { width: min(100%, 560px); margin: 0 auto; }
}

/* ---------- Phone held sideways ---------- */
@media (orientation: landscape) and (max-height: 520px) {
  .cam { grid-template-columns: minmax(0, 1fr) 232px; grid-template-rows: auto minmax(0, 1fr) auto; column-gap: 16px;
    grid-template-areas: "top top" "finder films" "finder controls";
    padding-left: calc(env(safe-area-inset-left, 0px)); padding-right: calc(env(safe-area-inset-right, 0px) + 16px); }
  .cam::before { display: none; }
  .top { grid-area: top; }
  .finder { grid-area: finder; position: relative; inset: auto; }
  .picker { grid-area: films; overflow-y: auto; }
  .picker-tabs { padding: 0; }
  .films, .props { display: grid; grid-template-columns: repeat(3, 62px); align-content: start; gap: 12px 8px; padding: 0; overflow: visible; }
  .controls { grid-area: controls; padding: 0; }
  .intro { justify-content: flex-start; }
}

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