/* ============================================================================
   coin-terminal-ui — drop-in theme
   Extracted verbatim from apitokens.rent (Next.js + Tailwind v4), 2026-08-24.
   Values are byte-faithful to the source. Do not "improve" them.

   USAGE A — Tailwind v4 project:
     @import "tailwindcss";
     @import "./theme.css";
     ...gives you bg-bg, bg-surface, text-dim, border-line, text-positive, etc.

   USAGE B — plain CSS, no build step:
     <link rel="stylesheet" href="theme.css">
     ...the :root block + @layer components work standalone. You lose the
     Tailwind utilities, so write layout with your own CSS or inline styles.
   ========================================================================= */

/* --- Fonts -----------------------------------------------------------------
   Source uses Inter (sans) + JetBrains Mono (mono) via next/font.
   Self-host or use the CDN line below. The mono font is NOT optional — every
   number in this design system is monospaced.                              */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=JetBrains+Mono:wght@400;500&display=swap");

/* --- Tokens (Tailwind v4) ------------------------------------------------ */
@theme {
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* The elevation ladder. Each rung is a few points lighter. Never skip one. */
  --color-bg:          #111113;
  --color-surface:     #16171a;
  --color-surface-2:   #1d1e21;
  --color-surface-3:   #26272b;

  /* Borders. line == surface-3 by design: a border and a raised panel read as
     the same weight, which is why the UI can be this dense without noise. */
  --color-line:        #26272b;
  --color-line-strong: #34353a;

  /* Text ladder: primary -> secondary -> tertiary. */
  --color-text:        #f2f2f4;
  --color-dim:         #9295a0;
  --color-dimmer:      #63656e;

  /* Status only. Never decoration, never chrome. Apple system colors. */
  --color-positive:    #30d158;
  --color-danger:      #ff453a;
  --color-warn:        #ff9f0a;
  --color-info:        #0a84ff;
}

/* --- Tokens (standalone fallback) ---------------------------------------- */
/* Harmless duplication when Tailwind is present; required when it is not. */
:root {
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --color-bg: #111113;
  --color-surface: #16171a;
  --color-surface-2: #1d1e21;
  --color-surface-3: #26272b;
  --color-line: #26272b;
  --color-line-strong: #34353a;
  --color-text: #f2f2f4;
  --color-dim: #9295a0;
  --color-dimmer: #63656e;
  --color-positive: #30d158;
  --color-danger: #ff453a;
  --color-warn: #ff9f0a;
  --color-info: #0a84ff;
}

/* --- Base ---------------------------------------------------------------- */
html {
  /* Keep iOS text inflation from resizing labels independently of the scaled
     broadcast. A percentage preserves intentional browser pinch zoom. */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background: var(--color-bg);
  overflow-x: hidden;
}

body {
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 13px;          /* the whole aesthetic starts here */
  line-height: 1.45;
  letter-spacing: -0.008em; /* global optical tightening */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

::selection { background: #0a84ff59; }

/* --- Components ---------------------------------------------------------- */
@layer components {

  /* Numerals -------------------------------------------------------------
     Any digit a user might compare, scan, or watch change goes in one of
     these three. Tabular figures stop numbers jittering on live update. */
  .tnum {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1, "zero" 1;
  }
  .num {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    text-align: right;
  }
  .figure {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 17px;
    font-weight: 500;
    line-height: 1.1;
    letter-spacing: -0.02em;
  }

  /* Type scale ----------------------------------------------------------- */
  .label {
    font-size: 10px;
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--color-dimmer);
  }
  .h1 { font-size: 19px; font-weight: 600; line-height: 1.2; letter-spacing: -0.025em; }
  .h2 { font-size: 15px; font-weight: 600; letter-spacing: -0.02em; }
  .h3 { font-size: 13px; font-weight: 600; letter-spacing: -0.012em; }

  .prose-tight {
    max-width: 68ch;
    color: var(--color-dim);
    line-height: 1.55;
  }
  .prose-tight strong { color: var(--color-text); font-weight: 500; }

  /* Cards ---------------------------------------------------------------- */
  .card {
    background: var(--color-surface);
    border: 1px solid var(--color-line);
    border-radius: 10px;
  }
  .card-hover { transition: background 0.12s, border-color 0.12s; }
  .card-hover:hover {
    background: var(--color-surface-2);
    border-color: var(--color-line-strong);
  }

  /* Buttons -------------------------------------------------------------- */
  .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 5px 9px;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: -0.008em;
    white-space: nowrap;
    color: var(--color-text);
    background: var(--color-surface-2);
    border: 1px solid var(--color-line-strong);
    border-radius: 7px;
    cursor: pointer;
    transition: background 0.12s, border-color 0.12s, opacity 0.12s;
  }
  .btn:hover:not(:disabled) { background: var(--color-surface-3); }
  .btn:disabled { opacity: 0.4; cursor: not-allowed; }

  /* The single loud element. One per view, ideally one per screen. */
  .btn-primary {
    background: #fff;
    border-color: #fff;
    color: #0e0e10;
    font-weight: 600;
  }
  .btn-primary:hover:not(:disabled) { background: #e6e6ea; border-color: #e6e6ea; }

  .btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--color-dim);
  }
  .btn-ghost:hover:not(:disabled) { background: var(--color-surface-2); color: var(--color-text); }

  .btn-lg { padding: 7px 14px; font-size: 13px; border-radius: 9px; }
  .btn-xs { padding: 3px 7px; font-size: 11px; border-radius: 6px; gap: 3px; }

  /* Inputs --------------------------------------------------------------- */
  .field {
    width: 100%;
    padding: 5px 9px;
    font-family: inherit;
    font-size: 12.5px;
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-line);
    border-radius: 7px;
    outline: none;
    transition: border-color 0.12s, box-shadow 0.12s;
  }
  .field:focus {
    border-color: var(--color-info);
    box-shadow: 0 0 0 2px #0a84ff33;
  }
  .field::placeholder { color: var(--color-dimmer); }

  /* Segmented control ------------------------------------------------------
     Time ranges (1D/7D/30D/90D) and view switchers. Toggle with
     data-active="true|false", not a class — keeps the JS trivial.          */
  .segmented {
    display: inline-flex;
    gap: 2px;
    padding: 2px;
    background: var(--color-surface);
    border: 1px solid var(--color-line);
    border-radius: 8px;
  }
  .segment {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    font-size: 12px;
    font-weight: 500;
    color: var(--color-dim);
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
  }
  .segment:hover { color: var(--color-text); }
  .segment[data-active="true"] { background: var(--color-surface-3); color: var(--color-text); }

  /* Dropdown menu -------------------------------------------------------- */
  .menu {
    position: absolute;
    z-index: 40;
    min-width: 200px;
    padding: 4px;
    background: var(--color-surface-2);
    border: 1px solid var(--color-line-strong);
    border-radius: 10px;
    box-shadow: 0 1px 2px #00000080, 0 12px 32px -8px #000000bf;
  }
  .menu-item, a.menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 5px 8px;
    font-size: 12.5px;
    font-weight: 450;
    text-align: left;
    color: var(--color-dim);
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.1s, color 0.1s;
  }
  .menu-item:hover { background: var(--color-surface-3); color: var(--color-text); }
  .menu-item[data-active="true"] { color: var(--color-text); }
  .menu-label {
    padding: 6px 8px 3px;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--color-dimmer);
  }
  .menu-sep { height: 1px; margin: 4px 0; background: var(--color-line); }

  /* Chip — tiny metadata pill (context length, run count, tags) ----------- */
  .chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 5px;
    font-size: 10px;
    font-weight: 500;
    white-space: nowrap;
    color: var(--color-dim);
    background: var(--color-surface-3);
    border-radius: 4px;
  }

  /* Link — underline is a border, so it can animate to info-blue ---------- */
  .link {
    color: var(--color-text);
    text-decoration: none;
    border-bottom: 1px solid var(--color-line-strong);
    transition: border-color 0.12s, color 0.12s;
  }
  .link:hover { color: var(--color-info); border-color: var(--color-info); }

  /* Live dot — the "it is running" signal --------------------------------- */
  .pulse {
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: var(--color-positive);
    animation: pulse 2.6s ease-in-out infinite;
  }
  .pulse-idle { background: var(--color-dimmer); animation: none; }

  /* Data table ----------------------------------------------------------- */
  .data-table {
    width: 100%;
    font-size: 12.5px;
    border-collapse: separate;
    border-spacing: 0;
  }
  .data-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 6px 10px;
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    text-align: left;
    white-space: nowrap;
    color: var(--color-dimmer);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-line);
  }
  .data-table td {
    padding: 5px 10px;
    white-space: nowrap;
    color: var(--color-text);
    border-bottom: 1px solid var(--color-line);
  }
  .data-table tbody tr:last-child td { border-bottom: none; }
  .data-table tbody tr:hover td { background: var(--color-surface-2); }

  /* Scroll containers — thin, tinted, never default chrome ---------------- */
  .scroll-x { overflow-x: auto; scrollbar-width: thin; scrollbar-color: var(--color-line-strong) transparent; }
  .scroll-y { overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--color-line-strong) transparent; }

  /* Motion — short, cheap, never bouncy ---------------------------------- */
  .slide-in { animation: slide-in 0.22s cubic-bezier(0.2, 0.7, 0.3, 1) both; }
  .fade     { animation: fade 0.18s both; }
  .pop      { animation: pop 0.13s cubic-bezier(0.2, 0.7, 0.3, 1) both; transform-origin: top; }

  /* Terminal caret — put on the last word of a hero line ----------------- */
  .caret::after {
    content: "";
    display: inline-block;
    width: 0.5em;
    height: 1em;
    margin-left: 1px;
    vertical-align: text-bottom;
    background: var(--color-text);
    animation: blink 1s steps(2, start) infinite;
  }
}

/* --- Keyframes ----------------------------------------------------------- */
@keyframes pulse    { 50% { opacity: 0.5; } }
@keyframes slide-in { 0% { transform: translateX(100%); } }
@keyframes fade     { 0% { opacity: 0; } }
@keyframes pop      { 0% { opacity: 0; transform: translateY(-4px) scale(0.98); } }
@keyframes blink    { to { visibility: hidden; } }
@keyframes spin     { to { transform: rotate(360deg); } }

/* --- Skeleton helper (standalone only; Tailwind gives you animate-pulse) - */
.skeleton {
  border-radius: 4px;
  background: var(--color-surface-3);
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
