/*
 * navi-front's first stylesheet: tokens, the display face, base and type (spec v1.1
 * §6, "Sleeve, dark and modern"). The rest are css/components/ (buttons, forms and
 * the pieces pages share), css/shell/ (the chrome: sidebar, tab bar, glass player
 * bar, queue drawer, now-playing sheet) and css/views/ (the pages). index.html links
 * every file, this one first; none imports another, so the link order is the cascade
 * order.
 *
 * Hand-written, no framework, no build step: §9.1 says the image carries no frontend
 * artefact, so this is the source as shipped.
 *
 * CSP: style-src 'self' with no 'unsafe-inline', so there are no style attributes
 * anywhere. Views switch looks with classes and attributes ([hidden], [aria-current],
 * [aria-pressed], [data-*]); the only dynamic values (--tint, --progress, --fill) are
 * set through the CSSOM (el.style.setProperty), which the CSP allows. Nothing here
 * loads an external font or image.
 *
 * MOTION is short (<= 200 ms) and only answers something the person did, plus the
 * tint easing in when a cover has been sampled. prefers-reduced-motion turns all of
 * it off, at the bottom of this file.
 */

:root {
  color-scheme: dark;

  /* Palette, spec v1.1 §6. Contrast-checked as a set by test/theme.test.mjs, which
     reads these values from this block: change one and every pair that uses it is
     recomputed. The rules the test encodes:
       - text (--fg, --fg-muted, --accent, --danger) on any of the four grounds;
       - --line borders only on --bg (3.1:1 there, under 3:1 on the surfaces), so a
         control on a raised surface is outlined in --line-strong (or not at all);
       - the glass bar is --surface at --glass-alpha over whatever scrolls under it,
         and its text passes even over a white cover, which is what sets the alpha;
       - --tint is whatever tint.js sampled from a cover, guaranteed >= 4.5:1 for
         --fg-muted, and it is only ever mixed toward --bg. */
  --bg: #0c0c0e;
  --surface: #141417;
  --surface-2: #1b1b1f;
  --surface-3: #242429;
  --hairline: rgba(255, 255, 255, .07);
  --line: #5f5f69;
  --fg: #f5f5f4;
  --fg-muted: #a8a8b0;
  --accent: #f0b44c;
  --focus: #8fc8ff;
  --danger: #ff8a7a;
  --tint: #2a2a33;
  --glass-alpha: .86;

  /* Derived from the palette above (UI refresh), and measured by the same table.
     --line-strong is --line 60% + --fg-muted 40%, a 3:1 boundary on every surface;
     the soft grounds are --accent and --danger at 14% over --surface, for the
     current row, an active chip or badge, and an error notice. --edge (the 1px light
     edge on covers, cards and dialogs) and --scrim (the dialog backdrop) are
     decorative, like --hairline. */
  --line-strong: #7c7c85;
  --accent-hover: #f6c46a;
  --accent-soft: #332a1e;
  --danger-soft: #352525;
  --edge: rgba(255, 255, 255, .09);
  --scrim: rgba(0, 0, 0, .6);
}

:root {
  /* Type. The display face is a Latin subset of Mona Sans (OFL), renamed "Navi
     Display" because the OFL reserves its name for unmodified copies; see
     fonts/OFL.txt and internal/ui/fontsrc. It is used large, wide and heavy for
     page titles and album names. The same face at normal width and a lighter
     weight is the CHROME face: fixed English strings (nav, tabs, buttons, labels,
     small heads). Tag text (titles, artists, file names), which can be in any
     script, stays in the system stack. */
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --font-chrome: "Navi Display", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Navi Display", "Arial Black", "Helvetica Neue", system-ui, sans-serif;

  /* A major third (1.25) from a 100% root, so the user's font size wins. */
  --step--1: .8rem;
  --step-0: 1rem;
  --step-1: 1.25rem;
  --step-2: 1.563rem;
  --step-3: 1.953rem;
  --step-4: 2.441rem;
  --step-5: 3.052rem;
  --meta: .875rem;

  /* Size roles for components. Weights are four only: 400 body and meta, 500 item
     titles, nav, tabs and labels, 600 buttons, the current nav item or tab, and
     h2/h3, 800-850 display titles (theme.test.mjs pins the set). */
  --text-xs: .75rem;      /* player times, chip counts, badges */
  --text-sm: .8125rem;    /* meta, field labels, kind, table heads, chips, hints */
  --text-md: .9375rem;    /* chrome: nav, tabs, buttons, tile titles */
  --text-base: 1rem;      /* body, row titles, inputs (16px stops iOS zooming) */
  --text-lg: 1.125rem;    /* card and dialog titles, the hero byline */
  --text-xl: 1.375rem;    /* section heads */

  /* Spacing: a 4px base. */
  --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;

  /* Control heights (2.75rem, the touch target, on a coarse pointer: see below) and
     reading measures for forms and tracklists. */
  --control-h: 2.5rem;
  --control-h-sm: 2rem;
  --measure: 44rem;
  --measure-list: 50rem;

  /* Radii. Every corner in the stylesheets is one of these (theme.test.mjs). */
  --radius-xs: 4px;       /* skeleton lines, progress ends */
  --radius-sm: 6px;       /* kbd, small thumbnails */
  --radius-md: 10px;      /* covers (spec §6), buttons, inputs, rows, menus */
  --radius-lg: 14px;      /* cards and panels, upload items, the mini player, toasts */
  --radius-xl: 20px;      /* dialogs, the Home feature */
  --radius-pill: 999px;   /* the primary Play, chips, icon buttons, sliders */
  /* Older names, kept as aliases while rules still use them. */
  --radius-cover: var(--radius-md);
  --radius-control: var(--radius-md);

  /* Elevation. On near-black a shadow is invisible, so depth is a surface step plus
     an edge; shadows are only for what floats over content. Level 2: menus, toasts,
     the mini player. Level 3: dialogs (over --scrim). Covers on a tinted hero keep
     --shadow-cover, where a shadow does read. */
  --elev-2: 0 8px 24px rgba(0, 0, 0, .45);
  --elev-3: 0 24px 64px rgba(0, 0, 0, .6);
  --shadow-cover: 0 1px 2px rgba(0, 0, 0, .5), 0 12px 32px rgba(0, 0, 0, .45);

  /* Motion answers an action: colour on hover, a press, a dialog or toast arriving. */
  --motion-fast: 120ms;
  --motion: 160ms;
  --motion-slow: 200ms;
  --ease: cubic-bezier(.2, .7, .2, 1);

  --target: 2.75rem;      /* 44px minimum touch target */
  --sidebar-w: 15rem;
  --drawer-w: 22rem;
  --bar-h: 5.25rem;       /* the desktop player bar */
  --nav-h: 3.5rem;        /* the bottom tab bar on narrow screens */
  --mini-h: 4rem;         /* the mini player on narrow screens */
}

/* A finger needs the full target: every control height grows to 44px. */
@media (pointer: coarse) {
  :root {
    --control-h: var(--target);
    --control-h-sm: var(--target);
  }
}

/* The display face. Same origin, so the CSP's font-src (default-src 'self') allows
   it; `swap` shows the fallback stack at once rather than invisible headings. The
   axis ranges are the subset's own (wght 400-900, wdth 100-125). */
@font-face {
  font-family: "Navi Display";
  src: url("/fonts/navi-display.woff2") format("woff2");
  font-weight: 400 900;
  font-stretch: 100% 125%;
  font-style: normal;
  font-display: swap;
}

/* --tint eases in when a cover has been sampled, instead of snapping. Registering it
   as a <color> is what makes a custom property transitionable. */
@property --tint {
  syntax: "<color>";
  inherits: true;
  initial-value: #2a2a33;
}

/* --- Base ------------------------------------------------------------------------------ */

*, *::before, *::after { box-sizing: border-box; }

/* Author display rules (grid, flex) would otherwise beat the UA's [hidden] rule. */
[hidden] { display: none !important; }

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
  /* Keep a focused element clear of the fixed player bar (WCAG 2.4.11). */
  scroll-padding-bottom: calc(var(--bar-h) + 1rem);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-ui);
  font-size: var(--step-0);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Tag text can be one unbroken 80-character word; let it wrap rather than push
     the page sideways. */
  overflow-wrap: anywhere;
}

::selection { background: var(--accent); color: var(--bg); }

img, svg { display: block; max-width: 100%; }

.icon {
  width: 1.25rem;
  height: 1.25rem;
  flex: none;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* Headings and <main> take focus programmatically (tabindex="-1") on navigation so a
   screen reader hears the new view; they are not controls and get no ring. */
[tabindex="-1"]:focus { outline: none; }

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

/* --- Type ------------------------------------------------------------------------------- */

h1, h2, h3 { margin: 0; line-height: 1.15; }

/* Page titles: the display face, wide and heavy (spec §6). font-stretch drives the
   face's wdth axis; the system fallbacks simply ignore it. */
.display,
h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-stretch: 125%;
  font-size: clamp(2rem, 2vw + 1.4rem, 3.25rem);
  line-height: 1;
  letter-spacing: -.025em;
  margin: 0 0 var(--space-5);
  text-wrap: balance;
}

h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-stretch: 112%;
  font-size: var(--step-1);
  letter-spacing: -.01em;
}

h3 { font-family: var(--font-chrome); font-size: var(--step-0); font-weight: 600; }

p { margin: 0 0 var(--space-3); }

a { color: inherit; text-underline-offset: .2em; text-decoration-color: var(--fg-muted); }
a:hover { text-decoration-color: var(--accent); }

/* What kind of page this is ("Album", "Playlist"): small, muted, sentence case. */
.kind {
  margin: 0 0 var(--space-2);
  color: var(--fg-muted);
  font-family: var(--font-chrome);
  font-size: var(--text-sm);
  font-weight: 500;
}

.muted { color: var(--fg-muted); }
.error { color: var(--danger); }
.footnote { margin-top: var(--space-5); font-size: var(--meta); }
.lede { max-width: 40rem; }

/* Durations, track numbers, counts and sizes line up in columns, like a sleeve. */
time, kbd, .track-no, .track-time, .row-end, .album-meta, .progress, .upload-size,
.quota-text, .panel-status { font-variant-numeric: tabular-nums; }

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 1.75rem;
  padding: .0625rem .4375rem;
  font: 600 var(--text-sm)/1.5 var(--font-ui);
  color: var(--fg);
  background: var(--surface-3);
  border: 1px solid var(--hairline);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
}

/* --- Motion ----------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
