/* Suni's Wings. Colours follow the Suni's Adventure style guide (Siemens palette). */
:root {
  --deep-blue: #000028;
  --petrol: #009999;
  --bold-green: #00ffb9;
  --bold-blue: #00e6dc;
  --soft-blue: #00bedc;
  --sand: #f3f3f0;
  --sand-2: #dfdfd9;
  --yellow: #ffd732;
  --red: #ef0137;

  --bg: var(--deep-blue);
  --text: var(--sand);
  --muted: rgba(243, 243, 240, 0.72);
  --glass: rgba(0, 0, 40, 0.55);
  --glass-strong: rgba(0, 0, 40, 0.86);
  --line: rgba(243, 243, 240, 0.16);
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: "Nunito", ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }

#stage, #overlay {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: block;
  touch-action: none;
}
#overlay { pointer-events: none; }
#cam { position: fixed; width: 2px; height: 2px; opacity: 0; pointer-events: none; left: 0; top: 0; }

/* ---------------------------------------------------------------- intro */
.screen {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  display: grid;
  place-items: center;
  padding: calc(24px + var(--safe-top)) 16px calc(24px + var(--safe-bottom));
  background:
    radial-gradient(1200px 700px at 50% 115%, rgba(0, 153, 153, 0.55), transparent 60%),
    radial-gradient(600px 400px at 85% -10%, rgba(128, 92, 255, 0.28), transparent 70%),
    var(--deep-blue);
}
.screen::before { /* a few stars: Suni comes from Mythorian */
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.55;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 18%, #fff, transparent),
    radial-gradient(1px 1px at 28% 72%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 66% 12%, #fff, transparent),
    radial-gradient(1px 1px at 82% 42%, #fff, transparent),
    radial-gradient(1px 1px at 44% 36%, #fff, transparent),
    radial-gradient(1.5px 1.5px at 90% 80%, #fff, transparent),
    radial-gradient(1px 1px at 8% 88%, #fff, transparent),
    radial-gradient(1px 1px at 56% 90%, #fff, transparent);
}
.intro-inner {
  position: relative;
  width: 100%;
  max-width: 420px;
  text-align: center;
}
.logo {
  width: min(78%, 300px);
  height: auto;
  filter: invert(1);
  margin: 0 auto 18px;
  display: block;
}
h1 {
  font-size: clamp(34px, 9vw, 46px);
  font-weight: 900;
  letter-spacing: -0.01em;
  margin: 0 0 12px;
  color: var(--bold-green);
}
.lede {
  font-size: 17px;
  line-height: 1.5;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 28px;
  text-wrap: pretty;
}
.actions { display: grid; gap: 12px; }
.fine { font-size: 13px; color: var(--muted); margin: 22px 0 0; opacity: 0.8; }
.error {
  margin: 18px 0 0;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(239, 1, 55, 0.16);
  border: 1px solid rgba(239, 1, 55, 0.5);
  font-weight: 700;
  font-size: 14px;
  line-height: 1.4;
}

/* ---------------------------------------------------------------- buttons */
.btn {
  appearance: none;
  border: 0;
  font: inherit;
  font-weight: 800;
  font-size: 17px;
  min-height: 54px;
  padding: 0 22px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s ease, background-color 0.2s ease, opacity 0.2s;
  user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn:focus-visible, .icon-btn:focus-visible, .shutter:focus-visible { outline: 3px solid var(--bold-green); outline-offset: 3px; }
.btn.primary { background: var(--bold-green); color: var(--deep-blue); }
.btn.primary:hover { background: #4dffcf; }
.btn.secondary { background: rgba(0, 153, 153, 0.35); color: var(--text); box-shadow: inset 0 0 0 1.5px rgba(0, 230, 220, 0.55); }
.btn.secondary:hover { background: rgba(0, 153, 153, 0.5); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); }
.btn.small { min-height: 42px; font-size: 15px; padding: 0 16px; }

.icon-btn {
  appearance: none;
  border: 0;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--glass);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: none;
}
.icon-btn.small { width: 38px; height: 38px; background: rgba(243, 243, 240, 0.08); }
.icon-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-spacer { width: 48px; flex: none; }

/* ---------------------------------------------------------------- HUD */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }
.topbar, .bottombar {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
}
.topbar { top: calc(14px + var(--safe-top)); }
.bottombar {
  bottom: calc(22px + var(--safe-bottom));
  padding: 0 28px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
}
#btn-flip { grid-column: 1; justify-self: start; }
#btn-shutter { grid-column: 2; }
#btn-settings { grid-column: 3; justify-self: end; }
.pill {
  min-width: 0;
  max-width: 100%;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--glass);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  font-weight: 800;
  font-size: 15px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.4s ease;
}
.pill.ok { color: var(--bold-green); }
.pill.dim { opacity: 0.0; }

.shutter {
  appearance: none;
  border: 4px solid var(--sand);
  background: transparent;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  padding: 5px;
  cursor: pointer;
  flex: none;
}
.shutter span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--sand);
  transition: transform 0.12s ease, background-color 0.2s;
}
.shutter:active span { transform: scale(0.88); background: var(--bold-green); }

#flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
#flash.go { animation: flash 0.45s ease-out; }
@keyframes flash { from { opacity: 0.85; } to { opacity: 0; } }

/* ---------------------------------------------------------------- settings */
.sheet {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(100%, 460px);
  max-height: min(78vh, 720px);
  display: flex;
  flex-direction: column;
  background: var(--glass-strong);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  border-radius: 22px 22px 0 0;
  border: 1px solid var(--line);
  border-bottom: 0;
  padding-bottom: var(--safe-bottom);
  z-index: 5;
}
.sheet header, .sheet footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
}
.sheet header { border-bottom: 1px solid var(--line); }
.sheet footer { border-top: 1px solid var(--line); justify-content: flex-start; }
.sheet h2 { margin: 0; font-size: 19px; font-weight: 900; }
#settings-body { overflow-y: auto; padding: 6px 16px 12px; }
.field { padding: 10px 0; }
.field-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-weight: 700; font-size: 15px; }
.field-row output { font-variant-numeric: tabular-nums; color: var(--bold-blue); font-weight: 800; font-size: 14px; }
.field input[type="range"] { width: 100%; margin: 10px 0 0; accent-color: var(--bold-green); height: 28px; }
.field.toggle { display: flex; align-items: center; justify-content: space-between; }
.field.toggle input { width: 22px; height: 22px; accent-color: var(--bold-green); }
.segmented { display: flex; gap: 6px; margin-top: 10px; }
.segmented button {
  flex: 1;
  appearance: none;
  border: 0;
  font: inherit;
  font-weight: 800;
  font-size: 14px;
  min-height: 38px;
  border-radius: 10px;
  color: var(--text);
  background: rgba(243, 243, 240, 0.08);
  cursor: pointer;
  text-transform: capitalize;
}
.segmented button[aria-pressed="true"] { background: var(--petrol); }
details.group { border-top: 1px solid var(--line); margin-top: 6px; }
details.group summary {
  cursor: pointer;
  list-style: none;
  padding: 14px 0 8px;
  font-weight: 900;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
details.group summary::-webkit-details-marker { display: none; }
details.group summary::after { content: " +"; }
details.group[open] summary::after { content: " –"; }

/* ---------------------------------------------------------------- photo */
.modal {
  position: fixed;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: calc(18px + var(--safe-top)) 16px calc(18px + var(--safe-bottom));
  background: rgba(0, 0, 40, 0.92);
}
.modal img {
  max-width: 100%;
  max-height: calc(100% - 90px);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  object-fit: contain;
}
.photo-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

/* ---------------------------------------------------------------- loading, toast */
.loading {
  position: fixed;
  inset: 0;
  z-index: 7;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 16px;
  background: rgba(0, 0, 40, 0.82);
  font-weight: 800;
  text-align: center;
  padding: 0 16px;
}
.spinner {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 4px solid rgba(0, 255, 185, 0.2);
  border-top-color: var(--bold-green);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(120px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 8;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 12px;
  background: var(--glass-strong);
  font-weight: 800;
  font-size: 14px;
}

body[data-mode="intro"] #stage { visibility: hidden; }

@media (prefers-reduced-motion: reduce) {
  #flash.go { animation: none; }
  .spinner { animation-duration: 2.5s; }
}
