/* ==========================================================================
   ELEVATION SYSTEM
   --------------------------------------------------------------------------
   One light source (directly above, x-offset always 0), one shadow color,
   one closed scale. Components use the SEMANTIC tokens (--shadow-*).
   The numbered scale (--elev-*) exists to define those tokens and as a
   fallback when no semantic token fits. Raw box-shadow values do not
   appear anywhere else in the codebase.

   Every level uses the same two-layer structure:
     layer 1 = key shadow   (tight, close to the element)
     layer 2 = ambient shadow (wide, soft, negative spread so it falls
                               beneath the element rather than haloing it)
   Offset and blur increase with level; opacity increases modestly.
   ========================================================================== */


/* --------------------------------------------------------------------------
   1. SHADOW COLOR
   --------------------------------------------------------------------------
   The shadow color is the site's own --shadow-color, set with the brand
   colours in main.css's :root; every layer below is drawn from it. This
   sheet is linked just before main.css (pcf_render_stylesheets()), and the
   tokens read it wherever they are used.
   -------------------------------------------------------------------------- */
:root {
  /* Global intensity multiplier. 1 in light mode, raised in dark mode. */
  --shadow-strength: 1;

  /* Focus-ring color. Not an elevation shadow; brand-colored on purpose. */
  --ring-color: var(--c2);
}


/* --------------------------------------------------------------------------
   2. DARK MODE
   --------------------------------------------------------------------------
   Shadows are much less visible on dark backgrounds, so opacity is scaled up.
   Components never need their own dark-mode shadow overrides; this rule
   covers everything. The site's only dark scheme is data-theme="dark" on the
   root (main.css), which nothing sets yet; the page does not follow the
   system's dark mode, so there is no prefers-color-scheme rule here, which
   would only strengthen the shadows on a page that is still light.
   -------------------------------------------------------------------------- */
:root[data-theme="dark"] {
  --shadow-strength: 2.6;
}


/* --------------------------------------------------------------------------
   3. ALPHA STEPS
   --------------------------------------------------------------------------
   Every shadow layer draws its color from one of these. Each is the shadow
   color at a fixed opacity, multiplied by --shadow-strength.
   -------------------------------------------------------------------------- */
:root {
  --sa-04: color-mix(in oklab, var(--shadow-color) calc(4%  * var(--shadow-strength)), transparent);
  --sa-06: color-mix(in oklab, var(--shadow-color) calc(6%  * var(--shadow-strength)), transparent);
  --sa-08: color-mix(in oklab, var(--shadow-color) calc(8%  * var(--shadow-strength)), transparent);
  --sa-10: color-mix(in oklab, var(--shadow-color) calc(10% * var(--shadow-strength)), transparent);
  --sa-12: color-mix(in oklab, var(--shadow-color) calc(12% * var(--shadow-strength)), transparent);
  --sa-14: color-mix(in oklab, var(--shadow-color) calc(14% * var(--shadow-strength)), transparent);
  --sa-16: color-mix(in oklab, var(--shadow-color) calc(16% * var(--shadow-strength)), transparent);
  --sa-20: color-mix(in oklab, var(--shadow-color) calc(20% * var(--shadow-strength)), transparent);
}


/* --------------------------------------------------------------------------
   4. ELEVATION SCALE (0–6)
   --------------------------------------------------------------------------
   0  Flat. On the page surface.
   1  Barely lifted. Resting buttons, chips, list tiles, segmented controls.
   2  Resting surface. Cards, panels, tiles that sit on the page.
   3  Raised. Hovered cards, hovered buttons, small floating controls.
   4  Floating. Dropdowns, menus, popovers, tooltips, autocomplete lists.
   5  Overlay. Drawers/side sheets, dragged items, toasts, floating action button.
   6  Top. Modal dialogs, command palettes, lightboxes.
   -------------------------------------------------------------------------- */
:root {
  --elev-0: none;

  --elev-1:
    0 1px 1px 0 var(--sa-06),
    0 1px 3px 0 var(--sa-08);

  --elev-2:
    0 1px 2px 0 var(--sa-06),
    0 3px 6px -1px var(--sa-10);

  --elev-3:
    0 2px 4px -1px var(--sa-08),
    0 6px 14px -3px var(--sa-12);

  --elev-4:
    0 4px 8px -2px var(--sa-08),
    0 12px 24px -6px var(--sa-14);

  --elev-5:
    0 6px 12px -3px var(--sa-10),
    0 20px 36px -8px var(--sa-16);

  --elev-6:
    0 10px 20px -5px var(--sa-10),
    0 32px 56px -12px var(--sa-20);
}


/* --------------------------------------------------------------------------
   5. DIRECTIONAL EDGE SHADOWS
   --------------------------------------------------------------------------
   For bars that span the viewport, where a full elevation shadow would
   bleed onto the sides. The large negative spread confines the shadow to
   one edge.

   --shadow-edge-top deliberately breaks the single-light-source rule: a
   bottom-anchored bar casts its shadow upward because a downward shadow
   would be off-screen. This is a standard convention, and this token is
   the only permitted exception.
   -------------------------------------------------------------------------- */
:root {
  --shadow-edge-bottom:            /* sticky header, top app bar (scrolled state) */
    0 1px 2px -1px var(--sa-08),
    0 6px 10px -6px var(--sa-12);

  --shadow-edge-top:               /* sticky footer, bottom nav, bottom action bar */
    0 -1px 2px -1px var(--sa-08),
    0 -6px 10px -6px var(--sa-12);

  /* Scroll hints: placed on the inner edge of a scroll container to show
     more content beyond. Apply only while content is actually clipped. */
  --shadow-scroll-top:    inset 0  8px 8px -8px var(--sa-14);
  --shadow-scroll-bottom: inset 0 -8px 8px -8px var(--sa-14);
}


/* --------------------------------------------------------------------------
   6. INSET SHADOWS (recessed surfaces)
   --------------------------------------------------------------------------
   Below the page surface, rather than above it. Light still comes from
   above, so the shadow sits at the top inner edge.
   -------------------------------------------------------------------------- */
:root {
  --shadow-inset-1: inset 0 1px 2px 0 var(--sa-08);   /* input wells, tracks, code blocks */
  --shadow-inset-2: inset 0 2px 4px 0 var(--sa-12);   /* pressed toggle, active segmented option */
}


/* --------------------------------------------------------------------------
   7. DROP SHADOWS (non-rectangular shapes)
   --------------------------------------------------------------------------
   box-shadow follows the box. For SVG icons, transparent PNGs, or clip-path
   shapes, use filter: drop-shadow(), which follows the visible pixels.
   drop-shadow() takes one shadow and no spread, so these are single-layer
   approximations of the matching levels.
   Usage:  filter: var(--drop-3);
   -------------------------------------------------------------------------- */
:root {
  --drop-1: drop-shadow(0 1px 2px var(--sa-12));
  --drop-2: drop-shadow(0 2px 4px var(--sa-12));
  --drop-3: drop-shadow(0 4px 8px var(--sa-14));
  --drop-4: drop-shadow(0 8px 16px var(--sa-16));
}


/* --------------------------------------------------------------------------
   8. FOCUS RINGS
   --------------------------------------------------------------------------
   Not elevation. Brand-colored. When an element has both, list the ring
   first and the elevation second:
     box-shadow: var(--ring), var(--shadow-card);
   Never combine a ring with --elev-0 / none (use the ring alone).
   -------------------------------------------------------------------------- */
:root {
  --ring:       0 0 0 3px color-mix(in oklab, var(--ring-color) 45%, transparent);
  --ring-inset: inset 0 0 0 2px var(--ring-color);  /* for elements clipped by overflow: hidden parents */
  --ring-error: 0 0 0 3px color-mix(in oklab, var(--c-red) 40%, transparent);
}


/* --------------------------------------------------------------------------
   9. SEMANTIC TOKENS — what components actually use
   --------------------------------------------------------------------------
   Pick by what the element IS. Interactive states move one level up on
   hover and back to the resting level (or lower) when pressed.
   -------------------------------------------------------------------------- */
:root {
  /* Cards and surfaces */
  --shadow-card:          var(--elev-2);
  --shadow-card-hover:    var(--elev-3);   /* only for clickable cards */
  --shadow-card-subtle:   var(--elev-1);   /* dense grids, list tiles */
  --shadow-panel:         var(--elev-2);   /* sidebars and panels that sit on the page */

  /* Buttons and controls */
  --shadow-button:        var(--elev-1);
  --shadow-button-hover:  var(--elev-2);
  --shadow-button-active: var(--elev-0);   /* pressed: lowers to the surface */
  --shadow-toggle-active: var(--shadow-inset-2);
  --shadow-fab:           var(--elev-5);
  --shadow-fab-hover:     var(--elev-6);

  /* Form fields */
  --shadow-input:         var(--shadow-inset-1);
  --shadow-input-focus:   var(--ring), var(--shadow-inset-1);
  --shadow-input-error:   var(--ring-error), var(--shadow-inset-1);

  /* Bars */
  --shadow-header:        var(--elev-0);           /* at top of page */
  --shadow-header-stuck:  var(--shadow-edge-bottom); /* once page has scrolled */
  --shadow-bottom-bar:    var(--shadow-edge-top);

  /* Floating UI */
  --shadow-tooltip:       var(--elev-3);
  --shadow-dropdown:      var(--elev-4);   /* select menus, autocomplete, nav dropdowns */
  --shadow-popover:       var(--elev-4);
  --shadow-menu:          var(--elev-4);   /* context menus */

  /* Overlays */
  --shadow-drawer:        var(--elev-5);
  --shadow-toast:         var(--elev-5);
  --shadow-dragging:      var(--elev-5);   /* item being dragged */
  --shadow-modal:         var(--elev-6);
}


/* --------------------------------------------------------------------------
   10. MOTION
   --------------------------------------------------------------------------
   Transitioning box-shadow repaints every frame. That is acceptable on a
   single element (a button, one card). For grids or lists of hoverable
   items, use the pseudo-element pattern below, which transitions opacity
   instead.

   Pseudo-element pattern:

     .card {
       position: relative;
       box-shadow: var(--shadow-card);
     }
     .card::after {
       content: "";
       position: absolute;
       inset: 0;
       border-radius: inherit;
       box-shadow: var(--shadow-card-hover);
       opacity: 0;
       transition: opacity var(--shadow-duration) var(--shadow-easing);
       pointer-events: none;
     }
     .card:hover::after { opacity: 1; }

   Respect reduced motion: the global rule below removes the transition,
   and the shadow change still happens instantly.
   -------------------------------------------------------------------------- */
:root {
  --shadow-duration: 180ms;
  --shadow-easing: cubic-bezier(0.2, 0, 0, 1);
}

@media (prefers-reduced-motion: reduce) {
  :root { --shadow-duration: 0ms; }
}
