/*
 * LinkCert · Nordic Glass. Frosted glass over a misty northern field; a Nordic voice: Helvetica Neue at 400 and 500,
 * an ink ladder, ink for action, and colour only in state. Light by default, polar night under prefers-color-scheme.
 *
 * The PWA's variables carry the palette. The rules further down target PWA class names (upstream may rename them),
 * each prefixed with :root so they outrank src/web/styles.css whichever loads last. The landing page links this file
 * too, so the variables and the field reach it as well.
 */
:root {
  /* The PWA's palette. "Accent" is ink: emphasis comes from ink, not hue. */
  --color-bg: #eef0f0;
  --color-surface: #ffffff;
  --color-text: #0a0a0a;
  --color-muted: #595e61;
  --color-accent: #0a0a0a;
  --color-accent-text: #ffffff;
  --color-danger: #b32b2a;
  --radius: 18px;
  --font-sans: "Helvetica Neue", Helvetica, Arial, sans-serif;

  /* Nordic Glass materials, used by the rules below. */
  --nordic-line: rgb(0 0 0 / 9%);
  --nordic-glass: rgb(255 255 255 / 72%);
  --nordic-glass-rim: rgb(255 255 255 / 92%);
  --nordic-glass-rim-low: rgb(255 255 255 / 22%);
  --nordic-glass-edge: rgb(10 20 24 / 7%);
  --nordic-blur: blur(24px) saturate(140%);
  --nordic-blur-lg: blur(40px) saturate(150%);
  --nordic-shadow-glass:
    inset 0 1px 0 var(--nordic-glass-rim), inset 0 -1px 0 var(--nordic-glass-rim-low),
    0 0 0 0.5px var(--nordic-glass-edge), 0 6px 24px rgb(20 34 40 / 7%);
  --nordic-shadow-button: inset 0 1px 0 rgb(255 255 255 / 18%), 0 1px 2px rgb(0 0 0 / 14%), 0 6px 16px rgb(0 0 0 / 10%);
  --nordic-sheen: linear-gradient(180deg, rgb(255 255 255 / 12%), rgb(255 255 255 / 0) 55%);
  /* The phone's steps besides the ink ladder (Theme.swift): icon boxes and empty tracks a step below the surface,
     chevrons a step quieter than muted, green only for state, and the one quiet hue for a warning. */
  --nordic-sunken: #e6eaea;
  --nordic-subtle: #8d9396;
  --nordic-success: #1f7a4d;
  --nordic-success-soft: #dcefe4;
  --nordic-warning: #8a5a00;
  /* The light behind the glass: fog, fjord, birch and snow. */
  --nordic-field:
    radial-gradient(80% 40% at 0% 0%, #cfdbe0 0%, rgb(207 219 224 / 0) 72%),
    radial-gradient(70% 36% at 100% 6%, #e2e0e4 0%, rgb(226 224 228 / 0) 72%),
    radial-gradient(60% 30% at 100% 52%, #d6dfe2 0%, rgb(214 223 226 / 0) 72%),
    radial-gradient(75% 36% at 100% 100%, #e9e3db 0%, rgb(233 227 219 / 0) 72%),
    radial-gradient(75% 32% at 0% 78%, #d5e0db 0%, rgb(213 224 219 / 0) 72%), var(--color-bg);
}

/* Polar night. */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --color-bg: #0c0f11;
    --color-surface: #181b1d;
    --color-text: #f2f2f0;
    --color-muted: #a3a7a9;
    --color-accent: #f2f2f0;
    --color-accent-text: #0a0a0a;
    --color-danger: #f5847c;

    --nordic-line: rgb(255 255 255 / 9%);
    --nordic-glass: rgb(26 30 33 / 72%);
    --nordic-glass-rim: rgb(255 255 255 / 18%);
    --nordic-glass-rim-low: rgb(255 255 255 / 4%);
    --nordic-glass-edge: rgb(0 0 0 / 40%);
    --nordic-shadow-glass:
      inset 0 1px 0 var(--nordic-glass-rim), inset 0 -1px 0 var(--nordic-glass-rim-low),
      0 0 0 0.5px var(--nordic-glass-edge), 0 8px 28px rgb(0 0 0 / 35%);
    --nordic-shadow-button: inset 0 1px 0 rgb(255 255 255 / 30%), 0 1px 2px rgb(0 0 0 / 40%);
    --nordic-sunken: #24292c;
    --nordic-subtle: #7b8184;
    --nordic-success: #6fcf97;
    --nordic-success-soft: rgb(111 207 151 / 16%);
    --nordic-warning: #e8b86a;
    --nordic-field:
      radial-gradient(55% 45% at 10% 0%, #173a33 0%, rgb(23 58 51 / 0) 70%),
      radial-gradient(45% 50% at 85% 0%, #1e2c3e 0%, rgb(30 44 62 / 0) 70%),
      radial-gradient(45% 60% at 0% 100%, #1b2328 0%, rgb(27 35 40 / 0) 70%),
      radial-gradient(40% 50% at 100% 100%, #241f2c 0%, rgb(36 31 44 / 0) 70%), var(--color-bg);
  }
}

/* Someone who asked for less transparency gets solid panes. */
@media (prefers-reduced-transparency: reduce) {
  :root {
    --nordic-glass: var(--color-surface);
    --nordic-blur: none;
    --nordic-blur-lg: none;
  }
}

/* ---- Field and type: hierarchy from size and space, Helvetica Neue at 400 and 500 only ------------------------ */

:root body {
  /* Fixed to the window: a page taller than the screen keeps one field, instead of the gradients starting over. */
  background: var(--nordic-field);
  background-attachment: fixed;
  line-height: 1.4;
  letter-spacing: -0.005em;
}

:root h1,
:root h2,
:root h3,
:root legend,
:root th,
:root .brand,
:root .button,
:root .chip,
:root .tab[aria-current="page"],
:root .pill,
:root .chart-title {
  font-weight: 500;
}

:root .page-title {
  font-size: 1.75rem;
  line-height: 1.18;
  letter-spacing: -0.03em;
}

:root h2,
:root legend,
:root .chart-title {
  font-size: 1.1875rem;
  line-height: 1.26;
  letter-spacing: -0.015em;
}

:root h3,
:root .brand,
:root .card-title {
  letter-spacing: -0.01em;
}

/* The Nordic overline: small, quiet, in sentence case. */
:root .eyebrow {
  font-size: 0.8125rem;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}

:root .hero-figure {
  font-weight: 400;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}

:root a {
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
}

/* ---- Glass: the bars and every card are frosted panes with a lit rim and a hairline edge ---------------------- */
/* The chat's own look (bubbles, the composer, inbox lines) is app/web/chat/chat.css. */

:root .tabbar,
:root .composer {
  border-color: var(--nordic-line);
  background: var(--nordic-glass);
  -webkit-backdrop-filter: var(--nordic-blur-lg);
  backdrop-filter: var(--nordic-blur-lg);
}

:root .panel,
:root .signin-card,
:root .card,
:root .notifications {
  border-color: transparent;
  background: var(--nordic-glass);
  box-shadow: var(--nordic-shadow-glass);
  -webkit-backdrop-filter: var(--nordic-blur);
  backdrop-filter: var(--nordic-blur);
}

/* ---- Ink: the primary button, with a glass sheen ------------------------------------------------------------- */

:root .button,
:root .chip {
  letter-spacing: -0.01em;
}

:root .button.primary {
  background-image: var(--nordic-sheen);
  box-shadow: var(--nordic-shadow-button);
}

/* A chip is a glass capsule in ink, not an outlined accent. */
:root .chip {
  border-color: var(--border);
  background: var(--nordic-glass);
  color: var(--color-text);
}

/* With ink as the accent, a disclosure needs its chevron to read as one (the PWA's summary hides the marker). */
:root .args summary {
  gap: 0.4rem;
  font-weight: 500;
}

:root .args summary::before {
  content: "";
  width: 0.45em;
  height: 0.45em;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.15s ease;
}

:root .args[open] summary::before {
  transform: rotate(45deg);
}

/* ---- The app's shell (app/web): no top bar; a glass tab bar of icons on a phone, a slim sidebar from 48rem ---- */

/* A phone's tab bar shows icons only, as the iPhone's; the label stays for screen readers. */
:root .no-top .tab-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

:root .no-top .tabbar {
  border-top-color: var(--nordic-line);
  padding-bottom: max(0.25rem, env(safe-area-inset-bottom));
}

:root .no-top .tab {
  justify-content: center;
  min-height: 3.25rem;
  color: var(--color-muted);
}

:root .no-top .tab .icon {
  box-sizing: content-box;
  width: 24px;
  height: 24px;
  padding: 4px 18px;
  border-radius: 999px;
}

:root .no-top .tab[aria-current="page"] {
  color: var(--color-text);
  font-weight: 500;
}

:root .no-top .tab[aria-current="page"] .icon {
  background: var(--nordic-sunken);
}

:root .no-top .badge {
  top: 0.15rem;
  left: calc(50% + 0.6rem);
  font-weight: 500;
}

@media (min-width: 48rem) {
  :root .no-top {
    grid-template-columns: 15rem minmax(0, 1fr);
  }

  :root .no-top .tabbar {
    padding: calc(1.25rem + env(safe-area-inset-top)) 0.75rem 1rem;
    border-top: 0;
    border-right: 1px solid var(--nordic-line);
  }

  :root .no-top .tabbar ul {
    gap: 0.125rem;
  }

  /* The logo and the app's name. */
  :root .no-top .nav-brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0 0.75rem 1.5rem;
    font-size: 1.1875rem;
    letter-spacing: -0.015em;
  }

  :root .no-top .nav-brand::before {
    content: "";
    width: 1.75rem;
    height: 1.33rem;
    background: url("assets/linkcert-mark.svg") center / contain no-repeat;
  }

  /* In the dark, the mark's ink ring turns light (the same drawing, as a data URL). */
  @media (prefers-color-scheme: dark) {
    :root .no-top .nav-brand::before {
      background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 248 188'%3E %3Cmask id='cut' maskUnits='userSpaceOnUse' x='0' y='0' width='248' height='188'%3E %3Crect x='0' y='0' width='248' height='188' fill='%23fff'/%3E %3Crect x='109' y='80' width='31' height='31' rx='6' fill='%23000' transform='rotate(45 124.5 95.5)'/%3E %3C/mask%3E %3Cg mask='url(%23cut)'%3E %3Cg transform='translate(22 6)' fill='none' stroke-width='26'%3E %3Crect x='18' y='34' width='108' height='108' rx='28' stroke='%23F2F2F0' transform='rotate(45 72 88)'/%3E %3Crect x='78' y='34' width='108' height='108' rx='28' stroke='%2318A176' transform='rotate(45 132 88)'/%3E %3C/g%3E %3C/g%3E %3C/svg%3E");
    }
  }

  :root .no-top .tab-label {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip-path: none;
  }

  :root .no-top .tab {
    justify-content: flex-start;
    gap: 0.625rem;
    min-height: 2.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: 12px;
    font-size: 1rem;
  }

  :root .no-top .tab .icon {
    width: 22px;
    height: 22px;
    padding: 0;
  }

  :root .no-top .tab:hover:not([aria-current="page"]) {
    color: var(--color-text);
  }

  :root .no-top .tab[aria-current="page"],
  :root .no-top .tab[aria-current="page"] .icon {
    background: var(--nordic-sunken);
  }

  /* The pending count reads as a quiet number beside the label, as the design's web sidebar. */
  :root .no-top .badge {
    background: none;
    color: var(--color-muted);
    font-size: 0.8125rem;
  }
}
