/* ==========================================================================
   Materials — copied from the intranet, not written here.

   The `@layer components` blocks of CaplaIntranet src/app/globals.css: the
   panel, the materials, press, rise, the brand hairline, the grounds, the
   glow and the rail's scroll bar. Its docs/design-system.md says to copy the
   block whole when another portal takes the look, and this is that copy, with
   one change: the hex tile is served from /assets/brand/ here.

   Refresh it from the intranet rather than editing it.
   ========================================================================== */

/* Brand gradient (logo cyan → blue → deep) as a device: a hairline accent, a
   text fill, or a mark fill. The logo's own gradient, reused structurally. */
.brand-hairline {
  background-image: linear-gradient(
    90deg,
    hsl(var(--brand-from)),
    hsl(var(--brand-mid)) 55%,
    hsl(var(--brand-to))
  );
}
.text-brand-gradient {
  background-image: linear-gradient(
    100deg,
    hsl(var(--brand-from)),
    hsl(var(--brand-mid)) 60%
  );
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* Metric readout: mono + tabular figures, for KPI numbers. */
.metric {
  font-family: var(--font-mono), ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

/* The page ground. Three soft brand-blue lights laid over the paper token,
   fixed so they do not travel with the scroll: the ground has depth without
   anything moving. This is the same atmosphere layer the public site puts
   behind its heroes, turned down and spread across the whole surface. */
.app-ground::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background-image:
    radial-gradient(60vmax 46vmax at 12% -8%, rgba(33, 173, 242, 0.16), transparent 70%),
    radial-gradient(52vmax 40vmax at 96% 4%, rgba(75, 125, 255, 0.12), transparent 72%),
    radial-gradient(46vmax 46vmax at 60% 108%, rgba(101, 220, 255, 0.1), transparent 70%);
}
.dark .app-ground::before {
  background-image:
    radial-gradient(60vmax 46vmax at 12% -8%, rgba(33, 173, 242, 0.12), transparent 70%),
    radial-gradient(52vmax 40vmax at 96% 4%, rgba(75, 125, 255, 0.1), transparent 72%),
    radial-gradient(46vmax 46vmax at 60% 108%, rgba(101, 220, 255, 0.08), transparent 70%);
}

/* Grain. A single fixed, non-interactive layer -- never on a scrolling
   container, which would repaint the whole surface every frame. It stops the
   large flat gradients above from banding on cheap panels. */
.app-ground::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.4;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.32'/%3E%3C/svg%3E");
}

/* Glass. The brand system already carries this material (`--glass`,
   `--panel-ink`, `--blur-glass`) and uses it for panels that sit over other
   content. Here it is a class so a panel can pick it up on ink grounds
   without every caller rebuilding the recipe: a translucent ground, a 1px
   inner highlight along the top edge for the refracted lip, and a real solid
   fallback for anyone who has asked their system for less transparency. */
.glass {
  background-color: rgba(255, 255, 255, 0.72);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
  -webkit-backdrop-filter: blur(14px) saturate(150%);
  backdrop-filter: blur(14px) saturate(150%);
}
.dark .glass {
  background-color: rgba(14, 42, 73, 0.55);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.09);
}
@media (prefers-reduced-transparency: reduce) {
  .glass {
    background-color: hsl(var(--card));
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .dark .glass {
    background-color: hsl(var(--card));
  }
}

/* ---------------------------------------------------------------------
   MATERIALS

   iOS does not have "a translucent card"; it has a set of materials that
   differ in how much of what is behind them survives. Three here, which is
   all this app needs, named the way the platform names them:

     .mat-thin     chrome that floats over content (tab bar, nav bar)
     .mat-regular  the standard surface a widget or list group sits on
     .mat-thick    something that must stay legible over anything (sheets)

   Each one is blur + saturation + a specular top edge, and each falls back to
   a solid fill when the viewer has asked for less transparency.
   --------------------------------------------------------------------- */
.mat-thin,
.mat-regular,
.mat-thick {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}
.mat-thin {
  background-color: rgba(248, 251, 253, 0.72);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
}
.mat-regular {
  background-color: rgba(255, 255, 255, 0.82);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  backdrop-filter: blur(30px) saturate(180%);
}
.mat-thick {
  background-color: rgba(255, 255, 255, 0.94);
  -webkit-backdrop-filter: blur(40px) saturate(190%);
  backdrop-filter: blur(40px) saturate(190%);
}
.dark .mat-thin,
.dark .mat-regular,
.dark .mat-thick {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}
.dark .mat-thin {
  background-color: rgba(9, 24, 46, 0.72);
}
.dark .mat-regular {
  background-color: rgba(16, 38, 66, 0.76);
}
.dark .mat-thick {
  background-color: rgba(12, 30, 54, 0.92);
}
@media (prefers-reduced-transparency: reduce) {
  .mat-thin,
  .mat-regular,
  .mat-thick {
    background-color: hsl(var(--card));
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

/* Press. Every tappable thing on iOS acknowledges the finger before anything
   else happens: it dips, and it comes back on a spring rather than a curve. */
.press {
  transition:
    transform 0.34s cubic-bezier(0.34, 1.56, 0.64, 1),
    background-color 0.2s ease,
    box-shadow 0.3s cubic-bezier(0.33, 0.02, 0, 1);
}
.press:active {
  transform: scale(0.972);
}
@media (prefers-reduced-motion: reduce) {
  .press,
  .press:active {
    transition: none;
    transform: none;
  }
}

/* App-icon squircle. A saturated two-stop fill with a light top edge, the way
   a home-screen icon is lit. Colour comes from --tile-a / --tile-b. */
.squircle {
  border-radius: 30%;
  background-image: linear-gradient(160deg, var(--tile-a), var(--tile-b));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.45),
    0 6px 14px -6px var(--tile-b);
  color: #fff;
}

/* A large title that shrinks into the bar as the page scrolls, driven by the
   scroll timeline rather than a scroll listener, so it costs no frames on the
   main thread. Where the browser has no scroll timeline the title simply
   stays large, which is the correct fallback. */
@supports (animation-timeline: scroll()) {
  @media (prefers-reduced-motion: no-preference) {
    .large-title {
      animation: large-title-collapse linear both;
      animation-timeline: scroll();
      animation-range: 0 120px;
    }
    @keyframes large-title-collapse {
      to {
        font-size: 1.35rem;
        opacity: 0.9;
      }
    }
  }
}

/* THE PANEL. One material, one radius, one shadow, everywhere: cards, stat
   bands, list groups, drawers. Before this the app had three panel looks side
   by side on the same screen, which is what made it read as assembled rather
   than designed.

   Shaped after an iOS grouped-inset list: a generous corner, a hairline
   rather than a drawn border, and translucency so the ground shows through.
   Anything that is a surface uses `.panel`; nothing else invents one. */
.panel {
  border-radius: var(--radius);
  border: 1px solid hsl(var(--border) / 0.75);
  background-color: rgba(255, 255, 255, 0.88);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.8),
    var(--shadow-light-card);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  backdrop-filter: blur(16px) saturate(160%);
}
.dark .panel {
  border-color: rgba(255, 255, 255, 0.1);
  background-color: rgba(14, 42, 73, 0.58);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    var(--shadow-light-card);
}
@media (prefers-reduced-transparency: reduce) {
  .panel {
    background-color: hsl(var(--card));
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .dark .panel {
    background-color: hsl(var(--card));
  }
}

/* Rows inside a panel: one hairline between rows, none at the ends. */
.panel-rows > * + * {
  border-top: 1px solid hsl(var(--border) / 0.7);
}

/* Entrance. One movement, the Capla curve, and only ever on first paint:
   8px of rise and a fade, stepped 60ms across a row so a group of figures
   settles in sequence rather than all at once. Anything more would be an
   interface springing about, which the brand's motion tokens rule out. */
.rise {
  animation: capla-rise 0.55s var(--ease-capla) both;
  animation-delay: var(--rise-delay, 0ms);
}
@keyframes capla-rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@media (prefers-reduced-motion: reduce) {
  .rise {
    animation: none;
  }
}

/* Ambient glow: the site's atmosphere layer (tokens/atmosphere.css). Always
   behind content, never over it, and only ever in the blue family. One per
   page, at the header, where the page announces itself. */
.capla-glow {
  position: absolute;
  pointer-events: none;
  border-radius: 50%;
  background-image: radial-gradient(closest-side, rgba(33, 173, 242, 0.2), transparent 100%);
}

/* Section grounds, ported from the public site's `.section.light`,
   `.section.deep` and `.section.mesh`. Same three grounds, same hex-noise
   tile at the same 320x280 and 0.45 opacity the site uses on light sections.
   The texture file itself is the site's, vendored to /brand. */
.section-light {
  background-image: var(--ground-light);
}
.section-deep {
  background-image: var(--ground-deep);
}
.section-mesh::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("/assets/brand/hex-noise.svg");
  background-size: 320px 280px;
  opacity: 0.45;
  pointer-events: none;
}

/* Signature: a faint registration reticle grid (nav-registration motif). */
.reticle {
  background-image:
    linear-gradient(hsl(var(--border) / 0.6) 1px, transparent 1px),
    linear-gradient(90deg, hsl(var(--border) / 0.6) 1px, transparent 1px);
  background-size: 22px 22px;
  background-position: -1px -1px;
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 40%, transparent 78%);
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 40%, transparent 78%);
}

/* The rail's scroll bar (app-shell.tsx: nav-scroll). */
.nav-scroll {
  scrollbar-width: thin;
  scrollbar-color: transparent transparent;
  scrollbar-gutter: stable;
}
.nav-scroll:hover,
.nav-scroll:focus-within {
  scrollbar-color: hsl(0 0% 100% / 0.22) transparent;
}
.nav-scroll::-webkit-scrollbar {
  width: 6px;
}
.nav-scroll::-webkit-scrollbar-track {
  background: transparent;
}
.nav-scroll::-webkit-scrollbar-thumb {
  background: transparent;
  border-radius: 9999px;
}
.nav-scroll:hover::-webkit-scrollbar-thumb,
.nav-scroll:focus-within::-webkit-scrollbar-thumb {
  background: hsl(0 0% 100% / 0.22);
}

/* Reduced motion, honoured globally. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
