/* base.css — design tokens + primitives for HoliSnap.
 *
 * Direction: "twilight postcard". A deep dusk-blue base (so the camera preview and
 * every screen read with high contrast), warm postcard-paper surfaces, a sunset
 * coral primary action, gold + sea-teal accents. System fonts only; personality
 * comes from weight, spacing and scale, not a downloaded typeface.
 *
 * Everything here is same-origin and inline-free to satisfy the strict CSP.
 */

:root {
  /* ---- palette ---- */
  --ink: #14233b;          /* dusk base background */
  --ink-2: #1e3357;        /* raised dark surface */
  --ink-3: #2a4571;        /* borders on dark */
  --paper: #fff6e9;        /* postcard paper surface */
  --paper-edge: #f0e2ca;   /* paper hairline */
  --coral: #ff7a4d;        /* primary action (sunset) */
  --coral-press: #ef663a;
  --gold: #ffc24b;         /* accent / highlight */
  --teal: #2fbfa6;         /* secondary / success */

  /* ---- text ---- */
  --on-ink: #f5efe3;       /* body text on dusk */
  --on-ink-dim: #b9c6dc;   /* muted text on dusk */
  --on-paper: #21304a;     /* body text on paper */
  --on-paper-dim: #5c6b83; /* muted text on paper */
  --on-coral: #14233b;     /* dark ink on coral = AA contrast */

  /* ---- spacing scale ---- */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;

  /* ---- radii ---- */
  --r-sm: 10px;
  --r: 16px;
  --r-lg: 22px;
  --r-pill: 999px;

  /* ---- type ---- */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial,
    "Apple Color Emoji", "Segoe UI Emoji", sans-serif;

  /* ---- misc ---- */
  --shadow-lift: 0 10px 30px rgba(0, 0, 0, 0.28);
  --tap: 48px;             /* comfortable one-handed target */
  --dur: 200ms;

  /* safe-area insets, defaulting to 0 where unsupported */
  --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);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  color: var(--on-ink);
  background: var(--ink);
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  /* Lock to a portrait, app-like viewport that never body-scrolls. */
  overflow: hidden;
  overscroll-behavior: none;
}

.app {
  position: relative;
  width: 100%;
  height: 100dvh;
  min-height: 100%;
  overflow: hidden;
}

/* ---- screen visibility (state machine toggles .is-active) ---- */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  min-height: 0;
}

.screen.is-active {
  display: flex;
}

/* ---- typography primitives ---- */
h1,
h2 {
  margin: 0;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.05;
}

p {
  margin: 0;
}

/* ---- buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: var(--tap);
  padding: 0 var(--s5);
  border: 0;
  border-radius: var(--r-pill);
  font: inherit;
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: transform var(--dur) ease, background-color var(--dur) ease,
    opacity var(--dur) ease;
  touch-action: manipulation;
}

.btn:active {
  transform: scale(0.97);
}

.btn-lg {
  min-height: 56px;
  font-size: 1.08rem;
  padding: 0 var(--s6);
}

.btn-primary {
  background: var(--coral);
  color: var(--on-coral);
  box-shadow: 0 6px 18px rgba(255, 122, 77, 0.35);
}

.btn-primary:active {
  background: var(--coral-press);
}

.btn-primary:disabled {
  background: var(--ink-3);
  color: var(--on-ink-dim);
  box-shadow: none;
  cursor: default;
  transform: none;
}

.btn-ghost {
  background: transparent;
  color: var(--on-paper);
  border: 2px solid var(--paper-edge);
}

.btn-ghost:active {
  background: rgba(0, 0, 0, 0.05);
}

/* icon-only round button */
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap);
  height: var(--tap);
  border: 0;
  border-radius: var(--r-pill);
  background: rgba(20, 35, 59, 0.55);
  color: #fff;
  cursor: pointer;
  touch-action: manipulation;
  backdrop-filter: blur(6px);
}

.btn-icon:active {
  transform: scale(0.94);
}

.btn-icon-dark {
  background: transparent;
  color: var(--on-ink);
}

/* file-picker fallback rendered as a button (native input hidden inside) */
.btn-file {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  min-height: var(--tap);
  padding: 0 var(--s5);
  border-radius: var(--r-pill);
  background: rgba(255, 246, 233, 0.14);
  color: var(--on-ink);
  border: 1.5px solid rgba(245, 239, 227, 0.4);
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
}

.btn-file:active {
  transform: scale(0.97);
}

.ico {
  flex: 0 0 auto;
  display: block;
}

/* ---- chips ---- */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 var(--s4);
  border-radius: var(--r-pill);
  border: 1.5px solid var(--paper-edge);
  background: #fffdf8;
  color: var(--on-paper);
  font: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  touch-action: manipulation;
  transition: transform var(--dur) ease, background-color var(--dur) ease,
    border-color var(--dur) ease;
}

.chip:active {
  transform: scale(0.95);
}

.chip.is-used {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--on-coral);
}

/* ---- accessibility helpers ---- */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
  border-radius: 6px;
}

[hidden] {
  display: none !important;
}

/* ---- motion preferences ---- */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
