/* ==========================================================================
   LAN Media Library — OLED design tokens
   Loaded after style.css. All pages (library / login / watch / share /
   external admin) share this file so one product = one palette and one type
   stack.

   Direction: "quiet night library". Pure-black canvas (OLED), graphite
   surfaces that step up in tiny increments, hairline borders instead of
   shadows, and a single green accent reserved for availability + action.
   ========================================================================== */

:root {
  color-scheme: dark;

  /* Surfaces — OLED: canvas is true black, elevation is a whisper. */
  --bg: #000000;
  --surface-1: #08080a;
  --surface-2: #0e0e11;
  --surface-3: #141417;
  --surface-4: #1a1a1f;
  --surface-hover: #1d1d22;
  --surface-inset: #0b0b0e;
  --overlay: rgba(0, 0, 0, 0.72);

  /* Lines — structure without glare. */
  --line: rgba(255, 255, 255, 0.08);
  --line-soft: rgba(255, 255, 255, 0.05);
  --line-strong: rgba(255, 255, 255, 0.16);
  --line-accent: rgba(166, 225, 111, 0.42);

  /* Text — four levels. */
  --text: #f2f3f5;
  --text-2: #d0d3d9;
  --text-3: #a2a7b0;
  --muted: #8a8f99;
  --disabled: #5d6169;

  /* Accent — one green. Meaning: available / primary action / active. */
  --accent: #a6e16f;
  --accent-strong: #b9f083;
  --accent-ink: #0a1004;
  --accent-soft: rgba(166, 225, 111, 0.12);
  --accent-softer: rgba(166, 225, 111, 0.07);

  /* Semantic — desaturated for dark surfaces. */
  --danger: #ff8d85;
  --danger-soft: rgba(255, 122, 114, 0.12);
  --danger-line: rgba(255, 122, 114, 0.38);
  --warning: #f0c15c;
  --warning-soft: rgba(240, 193, 92, 0.12);
  --success: #8fe0a8;
  --focus-ring: #c9edaa;

  /* Type */
  --font-sans: "Yu Gothic UI", "Hiragino Sans", "Noto Sans JP", "Meiryo",
    system-ui, sans-serif;
  --font-mono: "Cascadia Mono", "Consolas", "SFMono-Regular", monospace;
  --text-xs: 11px;
  --text-sm: 12px;
  --text-md: 13px;
  --text-lg: 14px;
  --text-xl: 16px;
  --text-2xl: 20px;
  --text-3xl: 26px;

  /* Space + radius */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --radius-1: 7px;
  --radius-2: 9px;
  --radius-3: 12px;
  --radius-4: 16px;
  --radius-pill: 999px;

  /* Motion — felt, never watched. */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --dur-fast: 120ms;
  --dur-base: 180ms;
  --dur-slow: 220ms;

  /* Elevation — dark mode leans on borders, not shadows. */
  --shadow-popover: 0 18px 48px rgba(0, 0, 0, 0.72);
  --shadow-dialog: 0 24px 80px rgba(0, 0, 0, 0.82);

  /* Layout */
  --topbar-h: 76px;
  --topbar-h-mobile: 62px;
  --sidebar-w: 250px;
}

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

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: 1.5;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* The legacy sheet paints a radial gradient; OLED wants true black. */
body {
  background-image: none;
  background-color: var(--bg);
}

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

/* Thin, low-glare scrollbars. */
* {
  scrollbar-width: thin;
  scrollbar-color: #2a2a30 transparent;
}
*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
*::-webkit-scrollbar-thumb {
  background: #26262c;
  border: 2px solid var(--bg);
  border-radius: var(--radius-pill);
}
*::-webkit-scrollbar-thumb:hover {
  background: #35353d;
}
*::-webkit-scrollbar-track {
  background: transparent;
}

h1,
h2,
h3,
p {
  text-wrap: pretty;
}
h1,
h2,
h3 {
  text-wrap: balance;
}

h1 {
  color: var(--text);
  font-size: var(--text-3xl);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.15;
}
h2 {
  color: var(--text);
  font-size: var(--text-xl);
  font-weight: 600;
  letter-spacing: -0.01em;
}

a {
  color: var(--accent);
}

/* Numbers that change should not move the layout. */
.media-updated,
.media-duration,
.media-date,
.media-format,
.result-count,
.fact,
.page-label,
#page-label,
#timeline-current,
#timeline-duration {
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   Focus — one visible ring, distinct from the green "selected" fill.
   -------------------------------------------------------------------------- */

:where(button, summary, select, a, input, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-1);
}

input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
  outline-offset: 3px;
}

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

button,
summary,
select,
input,
a,
.icon-button,
.media-row,
.media-card,
.folder-card,
.tree-line,
.tree-label,
.profile-option,
.toast {
  transition-property:
    background-color, border-color, color, opacity, transform, box-shadow;
  transition-duration: var(--dur-fast);
  transition-timing-function: var(--ease-out);
}

.media-card {
  transition-duration: var(--dur-base);
}

/* Press feedback: the UI heard you. */
button:not(:disabled):active,
summary:active,
.media-card:active {
  transform: scale(0.97);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }

  button:not(:disabled):active,
  summary:active,
  .media-card:active {
    transform: none;
  }
}

/* --------------------------------------------------------------------------
   Shared control primitives used by every page.
   -------------------------------------------------------------------------- */

/* Minimum touch target. Extended invisibly when the visual is smaller. */
.tap-target {
  position: relative;
  min-width: 44px;
  min-height: 44px;
}
.tap-target::after {
  content: "";
  position: absolute;
  inset: 50% 50%;
  width: max(100%, 44px);
  height: max(100%, 44px);
  transform: translate(-50%, -50%);
}
