/* ================================================================
   FILM Markets — Base (Reset + Global + Utilities)
   Depends on: tokens.css
   ================================================================ */

@layer base {

  /* ── Reset ── */
  *, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
  }

  html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
  }

  body {
    font-family: var(--ff-sans);
    font-size: var(--fs-base);
    line-height: var(--lh-base);
    color: var(--t-1);
    background-color: var(--bg-0);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color var(--dur-base), color var(--dur-base);

    /* Subtle grid texture */
    background-image:
      repeating-linear-gradient(
        90deg,
        rgba(148, 163, 184, 0.025) 0,
        rgba(148, 163, 184, 0.025) 1px,
        transparent 1px,
        transparent 80px
      ),
      repeating-linear-gradient(
        0deg,
        rgba(148, 163, 184, 0.02) 0,
        rgba(148, 163, 184, 0.02) 1px,
        transparent 1px,
        transparent 80px
      );
  }

  /* ── Tabular figures — critical for financial data ── */
  body {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1, "ss01" 1;
  }

  /* ── Scrollbar — dark terminal style ── */
  ::-webkit-scrollbar { width: 6px; height: 6px; }
  ::-webkit-scrollbar-track { background: var(--bg-1); }
  ::-webkit-scrollbar-thumb {
    background: var(--bd-3);
    border-radius: var(--r-1);
  }
  ::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, 0.4); }

  /* ── Focus ring — accessible ── */
  :focus-visible {
    outline: 2px solid var(--bd-focus);
    outline-offset: 2px;
    border-radius: var(--r-1);
  }

  /* ── Selection ── */
  ::selection {
    background: rgba(96, 165, 250, 0.25);
    color: var(--t-0);
  }

  /* ── Typography base ── */
  h1, h2, h3, h4, h5, h6 {
    font-family: var(--ff-display);
    font-weight: 700;
    color: var(--t-0);
    line-height: var(--lh-tight);
    letter-spacing: var(--ls-tight);
  }

  a {
    color: var(--info);
    text-decoration: none;
    transition: color var(--dur-fast);
  }
  a:hover { color: var(--t-0); }

  img, video, canvas, svg { display: block; max-width: 100%; }

  iframe { border: none; }

  button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
  }

  input, textarea, select {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
  }

  /* ── Reduced motion ── */
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
      scroll-behavior: auto !important;
    }
  }

  /* ── Skip link ── */
  .skip-link {
    position: absolute;
    top: -100%;
    left: var(--s-4);
    background: var(--alert);
    color: #000;
    padding: var(--s-2) var(--s-4);
    font-size: var(--fs-sm);
    font-weight: 700;
    letter-spacing: var(--ls-wide);
    text-transform: uppercase;
    border-radius: var(--r-3);
    z-index: var(--z-toast);
    transition: top var(--dur-fast);
  }
  .skip-link:focus { top: var(--s-2); }

  /* ══════════════════════════════════════════
     UTILITY CLASSES
     ══════════════════════════════════════════ */

  /* ── Numeric display — always mono + tabular ── */
  .num {
    font-family: var(--ff-mono);
    font-size: var(--fs-tabular);
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
    letter-spacing: 0;
  }

  /* ── Price change direction ── */
  .up   { color: var(--up-text);  }
  .down { color: var(--down-text); }
  .flat { color: var(--flat); }

  .bg-up   { background: var(--up-bg);   }
  .bg-down { background: var(--down-bg); }
  .bg-flat { background: var(--flat-bg); }

  /* ── Price flash animations ── */
  @keyframes flash-up {
    0%   { background: var(--up-bg); box-shadow: var(--sh-glow-up); }
    100% { background: transparent; box-shadow: none; }
  }
  @keyframes flash-down {
    0%   { background: var(--down-bg); box-shadow: var(--sh-glow-down); }
    100% { background: transparent; box-shadow: none; }
  }
  .flash-up   { animation: flash-up   var(--dur-flash) var(--ease-out) forwards; }
  .flash-down { animation: flash-down var(--dur-flash) var(--ease-out) forwards; }

  /* ── Text utilities ── */
  .text-0 { color: var(--t-0); }
  .text-1 { color: var(--t-1); }
  .text-2 { color: var(--t-2); }
  .text-3 { color: var(--t-3); }
  .text-mono { font-family: var(--ff-mono); }
  .text-display { font-family: var(--ff-display); }
  .text-micro { font-size: var(--fs-micro); }
  .text-xs    { font-size: var(--fs-xs); }
  .text-sm    { font-size: var(--fs-sm); }
  .text-md    { font-size: var(--fs-md); }
  .text-upper { text-transform: uppercase; letter-spacing: var(--ls-wider); }
  .text-right { text-align: right; }
  .text-center { text-align: center; }
  .truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* ── Layout ── */
  .flex       { display: flex; }
  .flex-col   { display: flex; flex-direction: column; }
  .items-center { align-items: center; }
  .items-start  { align-items: flex-start; }
  .justify-between { justify-content: space-between; }
  .justify-end     { justify-content: flex-end; }
  .gap-1 { gap: var(--s-1); }
  .gap-2 { gap: var(--s-2); }
  .gap-3 { gap: var(--s-3); }
  .gap-4 { gap: var(--s-4); }
  .flex-1 { flex: 1; }
  .flex-shrink-0 { flex-shrink: 0; }

  /* ── Display ── */
  .hidden  { display: none !important; }
  .sr-only {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  /* ── Shimmer loading skeleton ── */
  @keyframes shimmer {
    from { background-position: -200% 0; }
    to   { background-position:  200% 0; }
  }
  .skel {
    background: linear-gradient(
      90deg,
      var(--bg-2) 25%,
      var(--bg-3) 50%,
      var(--bg-2) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.4s ease-in-out infinite;
    border-radius: var(--r-1);
  }
  .skel-text   { height: 12px; }
  .skel-title  { height: 16px; }
  .skel-block  { height: 48px; }

  /* ── Scrollable container ── */
  .scroll-y {
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--bd-3) var(--bg-1);
  }

}
