/* ===========================================================================
   Liquid glass
   ===========================================================================
   One visual language for the site, built from the pattern the Eggs page uses:
   a translucent layered fill, a hairline rim that catches the light, a per-item
   tint bleeding in from the top, and a soft lift on hover.

   Two tiers, on purpose:

   * `.glass` / panels — real `backdrop-filter` frost. Reserved for chrome and
     containers, maybe a dozen elements per page.
   * cards and rows — layered gradient only, no `backdrop-filter`. A grid can
     hold ninety cards; ninety independently-blurred layers would re-sample the
     backdrop ninety times per frame and destroy scrolling. The layered fill
     reads as the same material without the cost.

   Everything degrades: `prefers-reduced-transparency` and browsers without
   `backdrop-filter` get an opaque panel, and `prefers-reduced-motion` drops the
   lift and the entrance animation.
   =========================================================================== */

:root {
  /* Fill: a top-lit gradient, never a flat block. */
  --glass-fill-top: rgba(255, 255, 255, 0.055);
  --glass-fill-bottom: rgba(255, 255, 255, 0.022);
  --glass-fill: linear-gradient(180deg, var(--glass-fill-top), var(--glass-fill-bottom));

  /* Rim: a hairline, but a *soft* one. A crisp 12% white line on near-black
     reads as a drawn stroke; the edge should look like light catching the rim,
     which the inset highlight in --glass-shadow does better than the border
     alone. These sit low on purpose. */
  --glass-border: rgba(255, 255, 255, 0.05);
  --glass-border-hi: rgba(255, 255, 255, 0.1);

  /* Panels and cards rest on an almost-invisible hairline. The 6.5% rim read
     as a drawn outline around large surfaces — worst around artwork — so the
     big containers use this instead. Controls keep `--glass-border`: at their
     size a 4% edge disappears entirely. */
  --edge-rest: rgba(255, 255, 255, 0.04);

  /* Depth: ambient drop plus an inset top light. */
  --glass-shadow: 0 10px 30px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  --glass-shadow-hi:
    0 16px 40px rgba(0, 0, 0, 0.36), inset 0 1px 0 rgba(255, 255, 255, 0.18);

  --glass-blur: 16px;
  --glass-radius: 16px;
  --glass-ease: cubic-bezier(0.16, 1, 0.3, 1);
}

/* --------------------------------------------------------------------------
   Panel glass — chrome, containers, overlays
   -------------------------------------------------------------------------- */

.glass,
.site-nav,
.collection-toolbar,
.pdash-tabs,
.pdash-head {
  position: relative;
  border: 1px solid var(--edge-rest);
  background: var(--glass-fill);
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(var(--glass-blur)) saturate(150%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(150%);
}

/* The specular rim: a 135deg sweep that lights the top-left edge and falls
   away. Masked to a 1px ring so it reads as the edge of the material. */
.glass::before,
.site-nav::before,
.collection-toolbar::before,
.pdash-tabs::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  /* Dimmer than a true specular rim: at full brightness it competed with the
     content and read as a border rather than a reflection. */
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.3),
    rgba(255, 255, 255, 0) 45%,
    rgba(255, 255, 255, 0) 62%,
    rgba(255, 255, 255, 0.09)
  );
  -webkit-mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask:
    linear-gradient(#000 0 0) content-box,
    linear-gradient(#000 0 0);
  mask-composite: exclude;
  pointer-events: none;
}

/* Overlays sit above content and can afford a heavier frost. */
.site-dropdown,
.site-search-results,
.advanced-panel,
.dev-login-card {
  /* Overlays need to separate from the page, so they keep the lit rim rather
     than the softer panel one. */
  border: 1px solid var(--glass-border-hi);
  background: linear-gradient(180deg, rgba(26, 31, 42, 0.86), rgba(18, 22, 30, 0.9));
  box-shadow:
    0 20px 50px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(28px) saturate(170%);
  -webkit-backdrop-filter: blur(28px) saturate(170%);
}

/* --------------------------------------------------------------------------
   Flat glass — repeated cards, rows, stat tiles
   --------------------------------------------------------------------------
   Same material, no blur. The per-card tint comes from `--glass-tint`, which
   components set to their own accent (a rarity colour, an egg colour, …). */

.pet-card,
.web-hatch-card,
.my-hatch-card,
.pdash-stat,
.pdash-row,
.profile-hero,
.pet-panel,
.settings-card,
.settings-panel,
.web-alert,
.web-account-card,
.script-card,
.script-viewer-panel,
.egg-public-card,
.egg-pool-panel,
.egg-pool-card,
.egg-hero-fact,
.hatches-page .hatch-card,
.hatches-page .hatch-toolbar,
.eggs-public-bar,
.collection-toolbar,
.pdash-tabs,
.pdash-head {
  /* Match the pet page's quiet surface: the colour is a barely-there 3% tint
     rather than the old lit gradient, and the border does the shape work. */
  background:
    radial-gradient(
      120% 80% at 50% 0%,
      color-mix(in srgb, var(--glass-tint, #ffffff) 3%, transparent),
      transparent 68%
    ),
    var(--glass-fill);
  border: 1px solid var(--edge-rest);
  box-shadow: none;
}

/* Quiet chrome follows the same surface as the pet-page panels; the old
   specular rim was still drawing a hard white edge on the right of the Values
   toolbar even after its fill was flattened. */
.pdash-tabs::before,
.pdash-head::before,
.collection-toolbar::before {
  display: none;
}

/* The catalogue toolbar is a single wide surface, so it reads lighter than the
   card grid even at the same tint. A touch darker here balances it. */
.collection-toolbar,
.hatches-page .hatch-toolbar,
.eggs-public-bar {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.022), rgba(255, 255, 255, 0.012));
  border-color: rgba(255, 255, 255, 0.04);
  box-shadow: none;
}

/* Egg detail, profile and dashboard panels share the pet page's soft surface:
   a 2% wash, 4% hairline, 10px corners and no drop shadow. */
.egg-hero-fact,
.egg-accounts-panel,
.egg-pool-panel,
.egg-pool-card,
.profile-hero,
.pdash-head,
.pdash-stat,
.pdash-row,
.pdash-person,
.web-account-card,
.web-hatch-card,
.pdash-tabs,
.settings-panel,
.script-card,
.script-viewer-panel,
.landing-stat,
.landing-feature,
.landing-hatch {
  background: var(--surface-soft);
  border: 1px solid var(--surface-soft-border);
  border-radius: var(--surface-soft-radius);
  box-shadow: none;
}

/* The audit pane keeps its inset scroll fade; only its shell material changes. */
.pdash-audit {
  background: var(--surface-soft);
  border-color: var(--surface-soft-border);
  border-radius: var(--surface-soft-radius);
}

/* Keep the cost fact's currency accent, but put it on the same soft base. */
.egg-hero-fact.egg-cost-fact {
  background: color-mix(in srgb, var(--currency, #ffcf70) 4%, var(--surface-soft));
  border-color: color-mix(in srgb, var(--currency, #ffcf70) 16%, var(--surface-soft-border));
}

/* Soften the egg hero frame to the pet frame's hairline and tint. */
.egg-hero-media {
  border-color: var(--surface-soft-border);
  background:
    radial-gradient(70% 65% at 50% 45%, color-mix(in srgb, var(--egg) 7%, transparent), transparent 72%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(0, 0, 0, 0.18));
}

/* Popups inherit the top bar's charcoal, not the old blue glass overlay. */
body .site-dropdown,
body .site-search-results,
body .advanced-panel,
body .dev-login-card {
  border: 1px solid var(--popup-border);
  border-radius: var(--popup-radius);
  background: var(--popup-bg);
  box-shadow: var(--popup-shadow);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* Hatches carry their rarity colour as a broad wash; the shared quiet surface
   had removed that identity along with the old glass. */
.hatches-page .hatch-card {
  background:
    radial-gradient(75% 105% at 0% 45%, rgba(var(--hatch-rgb, 255, 255, 255), 0.36), transparent 74%),
    radial-gradient(140% 120% at 6% 0%, rgba(var(--hatch-rgb, 255, 255, 255), 0.28), transparent 70%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.02));
  border-color: rgba(var(--hatch-rgb, 255, 255, 255), 0.16);
}

/* Safari paints a large blurred shadow for every card in the value grid, even
   though only one can be hovered. The grid supplies depth through its tinted
   background, and collection.v1.css adds the lift/ring on hover. */
.pet-card {
  box-shadow: none;
}

/* Small tiles keep the slightly stronger rim; at their size the 4% edge reads
   as nothing, and they need the boundary more than a full-bleed panel does. */
.pdash-stat {
  border-color: var(--edge-rest);
}

/* The tint source. Rarity classes already define `--dot` and the eggs page
   defines `--egg` per card; both feed `--glass-tint`, which is what the fill and
   the hover read. Without the egg mapping the fallback is white, so every egg
   hovered in white and its coloured fill was replaced by a plain one. */
/* Pets carry a per-pet dominant colour in `--pet-hex` (from the artwork) and a
   rarity colour in `--dot`. Prefer the pet's own colour: it is what the card's
   existing hover glow is built from, and it distinguishes two pets of the same
   rarity. */
.pet-card {
  --glass-tint: var(--pet-hex, var(--dot, #ffffff));
}

.web-hatch-card {
  --glass-tint: var(--dot, #ffffff);
}

.egg-public-card {
  --glass-tint: var(--egg, #ffffff);
}

.hatches-page .hatch-card {
  --glass-tint: rgb(var(--hatch-rgb, 255 255 255));
}

/* The single tinted hover for the cards this file owns.
   `.pet-card` is deliberately absent: `collection.v1.css` already gives it a
   richer hover built from `--pet-hex` — a tinted border, a 1px ring, a soft drop
   glow and a fading radial wash. Overriding that here replaced the per-pet
   colour with the shared rarity tint and dropped the ring, which is exactly the
   "coloured hover is gone on pets" regression. */
.web-hatch-card:hover,
.egg-public-card:hover,
.pdash-row:hover {
  border-color: color-mix(in srgb, var(--glass-tint, #ffffff) 55%, var(--glass-border-hi));
  box-shadow:
    0 0 28px color-mix(in srgb, var(--glass-tint, #ffffff) 20%, transparent),
    var(--glass-shadow-hi);
}

/* --------------------------------------------------------------------------
   Controls — glass fills rather than flat blocks
   -------------------------------------------------------------------------- */

.web-btn,
.icon-button,
.collection-search,
.collection-sort select,
.eggs-search,
.eggs-sort select,
.segmented,
.rarity-switch,
.pdash-controls input:not([type="checkbox"]):not([type="radio"]),
.pdash-controls select {
  background: var(--glass-fill);
  border: 1px solid var(--glass-border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition:
    background 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}

/* `.pdash-tab` is deliberately absent above: it is a *segment* inside the
   `.pdash-tabs` trough, not a standalone control. Giving it the control
   material drew a border and fill around every tab, so the strip read as four
   separate buttons instead of one segmented switch. */

.web-btn:hover,
.icon-button:hover,
.pdash-tab:hover,
.segmented button:hover,
.rarity-switch button:hover {
  border-color: var(--glass-border-hi);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 6px 18px rgba(0, 0, 0, 0.22);
}

/* --------------------------------------------------------------------------
   Motion — animate the qualities of the glass, not its geometry
   -------------------------------------------------------------------------- */

.pet-card,
.web-hatch-card,
.egg-public-card,
.pdash-row {
  transition:
    transform 200ms var(--glass-ease),
    border-color 200ms ease,
    box-shadow 200ms ease;
}

/* Custom select triggers and the settings gear are buttons too: use the same
   glass fill and inset highlight as the segmented/rarity controls. */
body :is(.custom-select-trigger, .advanced-toggle) {
  background-color: rgba(255, 255, 255, 0.03);
  background-image: var(--glass-fill);
  border-color: var(--glass-border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* Secondary controls use the same hairline and weight as the pet page's
   variant/poll chips. Grouped controls and inputs keep their own layouts; only
   the material is shared. */
body :is(
  .web-btn:not(.web-btn-primary),
  .icon-button,
  .advanced-toggle,
  .pdash-tab,
  .pdash-toggle,
  .profile-edit,
  .poll-detail-pet,
  .variants-toggle,
  .eggs-public-tools .icon-button,
  .segmented,
  .rarity-switch,
  .eggs-search,
  .eggs-sort select,
  .collection-search,
  .egg-hero-links a,
  .web-account-history,
  .history-tabs,
  .history-tabs button,
  .pdash-controls input:not([type="checkbox"]):not([type="radio"]),
  .pdash-controls select
) {
  border-color: var(--glass-border);
  background-color: rgba(255, 255, 255, 0.03);
  font-weight: 550;
}

body :is(.web-btn:not(.web-btn-primary), .eggs-sort select) {
  color: #e6eaf2;
}

body :is(.eggs-sort select, .eggs-search input, .collection-search input) {
  font-weight: 550;
}

/* --------------------------------------------------------------------------
   Accessibility and fallbacks
   -------------------------------------------------------------------------- */

@media (prefers-reduced-transparency: reduce) {
  .glass,
  .site-nav,
  .collection-toolbar,
  .pdash-tabs,
  .site-dropdown,
  .site-search-results,
  .advanced-panel,
  .pet-card,
  .web-hatch-card,
  .pdash-stat,
  .pdash-row,
  .pet-panel,
  .settings-card {
    background: #171b24;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    box-shadow: none;
  }

  .glass::before,
  .site-nav::before,
  .collection-toolbar::before,
  .pdash-tabs::before {
    display: none;
  }
}

@supports not (backdrop-filter: blur(1px)) {
  .glass,
  .site-nav,
  .collection-toolbar,
  .pdash-tabs,
  .site-dropdown,
  .site-search-results,
  .advanced-panel {
    background: linear-gradient(180deg, rgba(26, 31, 42, 0.94), rgba(18, 22, 30, 0.96));
  }
}

@media (prefers-reduced-motion: reduce) {
  .pet-card,
  .web-hatch-card,
  .egg-public-card,
  .pdash-row,
  .web-btn,
  .icon-button {
    transition: none;
  }

  .pet-card:hover,
  .web-hatch-card:hover,
  .egg-public-card:hover {
    transform: none;
  }
}

/* --------------------------------------------------------------------------
   Soft edges
   --------------------------------------------------------------------------
   Several component stylesheets still draw their own `1px solid rgba(255,255,255,
   0.1–0.14)` outlines. Loaded last, these rules re-point them at the soft token
   so the whole surface language agrees, without editing each page. */

.collection-search,
.collection-sort select,
.eggs-search,
.eggs-sort select,
.segmented,
.rarity-switch,
.pdash-controls input:not([type="checkbox"]):not([type="radio"]),
.pdash-controls select,
.icon-button,
.web-btn {
  border-color: var(--glass-border);
}

/* Controls brighten toward the lit rim. Cards are deliberately absent: their
   hover is tinted by the item colour above, and a white rim here would cancel
   it (it did — this rule was the regression). */
.web-btn:hover,
.icon-button:hover {
  border-color: var(--glass-border-hi);
}
