/* ============================================================================
   tokens.css -- one semantic palette, two themes.

   WHY THE DARK BLOCK APPEARS TWICE
   Light is the authored baseline on :root. Dark is declared twice on
   purpose: once under prefers-color-scheme so an un-chosen visitor follows
   their device, and once under [data-theme="dark"] so an explicit choice
   wins on a light device. Plain CSS cannot share one declaration block
   between a media query and an attribute selector without a build step, so
   the two are kept identical by
   core/tests/test_design_tokens.py::test_dark_palettes_are_identical.

   WHY NOT A JS-APPLIED CLASS (one copy instead of two)
   Because of what happens when the inline theme script does not run -- a
   CSP, an extension, a parse error in something earlier. With a class
   scheme no palette would apply at all: every var() invalid, body
   transparent, text inherited black, cards borderless. On a guest's phone
   mid-wedding that is a broken page. With the media query, a script that
   never runs simply yields the device theme, fully styled.

   WHY NOT light-dark()
   It would collapse each token to one declaration, but it needs Chrome
   123 / Safari 17.5 / Firefox 120, and the guest surface runs on whatever
   Android WebView someone is holding. An unsupported light-dark() makes
   every token invalid at computed-value time, and for an inherited
   property that means silently inheriting the parent instead of falling
   back -- a failure that looks like a styling bug, not an error. Revisit
   when the floor rises.

   SURFACE RAMP DIRECTION -- the trap when adding a value
   In LIGHT each surface tier gets DARKER as the number rises; in DARK it
   gets LIGHTER. --border-2 is likewise darker than --border in light and
   lighter in dark. Get this backwards and the result looks subtly muddy
   rather than obviously broken.
   ========================================================================== */

:root {
  color-scheme: light;

  --bg:             #faf9f6;
  --surface:        #ffffff;
  --surface-2:      #f2f0eb;
  --surface-3:      #ebe8e1;   /* recessed: inputs, tier cards */
  --surface-raised: #f7f5f1;   /* raised chips, hover rows */
  --border:         #e6e3db;
  --border-2:       #d6d2c8;

  --text:        #171512;
  --text-strong: #000000;   /* the hover states that used #fff on dark */
  --text-dim:    #44403a;   /* between text and muted; was #b8b8c2 on dark */
  --text-muted:  #6f6a62;
  --text-faint:  #938d80;

  --success: #147539; --success-surface: #e8f5ec; --success-border: #bbe3c7; --success-rgb: 21 128 61;
  --warning: #a16207; --warning-surface: #fdf4e3; --warning-border: #ecdbb0; --warning-rgb: 161 98 7;
  --danger:  #b91c1c; --danger-surface:  #fdeceb; --danger-border:  #f3c9c6; --danger-rgb:  185 28 28;
  --info:    #0369a1; --info-surface:    #e8f2fa; --info-border:    #bcd9ee; --info-rgb:    3 105 161;
  --on-danger: #ffffff;
  --on-success: #ffffff;   /* text on a filled --success button -- same reasoning as --on-danger */
  --processing: #6d28d9; --processing-surface: #f1e9fd; --processing-rgb: 109 40 217;

  --tint-raise: rgba(0, 0, 0, .025);     /* the card top-highlight sheen */
  --tint-row:   rgba(0, 0, 0, .025);     /* tbody tr:hover */
  --scrim:      rgba(23, 21, 18, .45);   /* modal overlays */
  --shadow-sm:   0 1px 2px rgba(23, 21, 18, .06);
  --shadow-card: 0 10px 28px -22px rgba(23, 21, 18, .18);
  --shadow-pop:  0 16px 40px -18px rgba(23, 21, 18, .22);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --bg:             #0a0a0f;
    --surface:        #111116;
    --surface-2:      #15151c;
    --surface-3:      #0e0e13;
    --surface-raised: #1c1c24;
    --border:         #23232c;
    --border-2:       #2e2e38;

    --text:        #e6e6ea;
    --text-strong: #ffffff;
    --text-dim:    #b8b8c2;
    --text-muted:  #8a8a95;
    --text-faint:  #6b6b76;

    --success: #4ade80; --success-surface: #0f3324; --success-border: #1d5537; --success-rgb: 74 222 128;
    --warning: #f2c14e; --warning-surface: #3a2f10; --warning-border: #5a4a1c; --warning-rgb: 242 193 78;
    --danger:  #f87171; --danger-surface:  #3a1414; --danger-border:  #4a1a1a; --danger-rgb:  248 113 113;
    --info:    #7dd3fc; --info-surface:    #123044; --info-border:    #1d4a66; --info-rgb:    125 211 252;
    --on-danger: #2a0a0a;
    --on-success: #05170a;
    --processing: #d8b4fe; --processing-surface: #2e1065; --processing-rgb: 216 180 254;

    --tint-raise: rgba(255, 255, 255, .025);
    --tint-row:   rgba(255, 255, 255, .02);
    --scrim:      rgba(0, 0, 0, .60);
    --shadow-sm:   0 1px 0 rgba(255, 255, 255, .03) inset;
    --shadow-card: 0 12px 30px -20px rgba(0, 0, 0, .6);
    --shadow-pop:  0 12px 36px -12px rgba(0, 0, 0, .65);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg:             #0a0a0f;
  --surface:        #111116;
  --surface-2:      #15151c;
  --surface-3:      #0e0e13;
  --surface-raised: #1c1c24;
  --border:         #23232c;
  --border-2:       #2e2e38;

  --text:        #e6e6ea;
  --text-strong: #ffffff;
  --text-dim:    #b8b8c2;
  --text-muted:  #8a8a95;
  --text-faint:  #6b6b76;

  --success: #4ade80; --success-surface: #0f3324; --success-border: #1d5537; --success-rgb: 74 222 128;
  --warning: #f2c14e; --warning-surface: #3a2f10; --warning-border: #5a4a1c; --warning-rgb: 242 193 78;
  --danger:  #f87171; --danger-surface:  #3a1414; --danger-border:  #4a1a1a; --danger-rgb:  248 113 113;
  --info:    #7dd3fc; --info-surface:    #123044; --info-border:    #1d4a66; --info-rgb:    125 211 252;
  --on-danger: #2a0a0a;
  --on-success: #05170a;
  --processing: #d8b4fe; --processing-surface: #2e1065; --processing-rgb: 216 180 254;

  --tint-raise: rgba(255, 255, 255, .025);
  --tint-row:   rgba(255, 255, 255, .02);
  --scrim:      rgba(0, 0, 0, .60);
  --shadow-sm:   0 1px 0 rgba(255, 255, 255, .03) inset;
  --shadow-card: 0 12px 30px -20px rgba(0, 0, 0, .6);
  --shadow-pop:  0 12px 36px -12px rgba(0, 0, 0, .65);
}

/* ---------------------------------------------------------------------------
   THEME-INVARIANT.
   These sit over photographs, not over the theme surface, so they must NOT
   flip. More than half the rgba(0,0,0,...) in this project is photo chrome
   -- a well-meaning "invert the blacks for light mode" pass would wreck
   every overlay in the app. Naming them is what prevents that.
   ------------------------------------------------------------------------ */
:root {
  --media-chip-bg:       rgba(0, 0, 0, .65);
  --media-chip-fg:       #ffffff;
  --media-chip-light-bg: #ffffff;        /* the white Google Drive chip */
  --media-chip-good:     #4ade80;   /* match-confidence badge -- always sits on media-chip-bg, never on the page's own surface, so it must not follow --success into a dark green that vanishes on the same black chip */
  --media-chip-heart:    #f87171;   /* the filled/active favourite-heart icon, same reasoning (guests/gallery.html, guests/all_photos.html) */
  --media-scrim:         rgba(0, 0, 0, .35);
  --media-shadow:        0 1px 4px rgba(0, 0, 0, .4);
  --media-shadow-lg:     0 12px 40px rgba(0, 0, 0, .5);   /* the Quick Review swipe card, lifted off the stack */
  --lightbox-bg:         rgba(0, 0, 0, .92);
  --lightbox-bar-bg:     #111118;   /* the lightbox's own toolbar */
  --lightbox-fg-muted:   #a3a3ad;
  --lightbox-control-bg: rgba(255, 255, 255, .15);   /* the translucent pill behind zoom/share/download/close */

  --space-1: .25rem; --space-2: .5rem;  --space-3: .75rem; --space-4: 1rem;
  --space-5: 1.5rem; --space-6: 2rem;   --space-7: 3rem;   --space-8: 4rem;

  --step--1: clamp(.78rem, .76rem + .10vw, .84rem);
  --step-0:  clamp(.92rem, .89rem + .14vw, 1rem);
  --step-1:  clamp(1.05rem, .99rem + .28vw, 1.22rem);
  --step-2:  clamp(1.22rem, 1.10rem + .55vw, 1.55rem);
  --step-3:  clamp(1.45rem, 1.22rem + 1.05vw, 2.1rem);
  --step-4:  clamp(1.8rem, 1.35rem + 2.1vw, 3rem);
  --lh-tight: 1.15; --lh-body: 1.6; --lh-loose: 1.85;

  --ease:      cubic-bezier(.2, .7, .2, 1);
  --ease-site: cubic-bezier(.22, .68, .18, 1);
  --dur-fast: .15s; --dur-base: .22s; --dur-slow: .35s;
  --radius-pill: 999px;

  /* The z-index ladder, finally written down in one place.
     guests/album_select.html documents lightbox 200 ... name-modal 600,
     but guests/search.html actually reaches 1000/1100 -- that is the real
     global ceiling, which is why --z-toast clears everything at 2000. */
  --z-nav: 50; --z-sticky: 100; --z-lightbox: 200; --z-overlay: 300;
  --z-page-toast: 400; --z-sheet: 500; --z-name-modal: 600;
  --z-modal: 1000; --z-blocking: 1100; --z-toast: 2000;
}

/* Flipping the theme otherwise animates background and border-color on
   several hundred elements at once -- visibly janky on a mid-range phone.
   transition:none rather than a transform, so this stays compatible with
   the `rise` keyframe constraint in the shells (a transform on <main>
   creates a containing block and breaks the fixed camera/consent modals). */
:root.theme-switching,
:root.theme-switching *,
:root.theme-switching *::before,
:root.theme-switching *::after { transition: none !important; }
