@import url("../../assets/tokens.css");

/* ---------------------------------------------------------------------------
   MIGRATION SHIM.

   Every colour, font, spacing and focus value now comes from
   shared/tokens.css (copied here by tools/sync_tokens.py). The names below
   map this stylesheet's original vocabulary onto the shared semantic tokens so
   the rest of the file did not have to be rewritten. New code must use the
   semantic names directly; this block is a bridge, not an API.
   --------------------------------------------------------------------------- */
:root {
  --bg-canvas:    var(--surface-canvas);
  --bg-card:      var(--surface-raised);
  --bg-card-hover:var(--surface-hover);
  --bg-elevated:  var(--surface-overlay);
  --text-muted:   var(--text-tertiary);
  --primary:      var(--brand);
  --primary-hover:var(--brand-hover);
  --primary-glow: var(--brand-glow);
  --success:      var(--status-ok);
  --warning-bg:      var(--status-warn-bg);
  --warning-border:  var(--status-warn-border);
  --warning-text:    var(--status-warn);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

    body {
      background: var(--bg-canvas);
      color: var(--text-primary);
      font-family: 'Rubik', sans-serif;
      min-height: 100vh;
      display: flex;
      flex-direction: column;
      line-height: 1.5;
      transition: background-color 0.2s ease, color 0.2s ease;
    }

    .theme-icon-moon { display: none; }
    [data-theme="light"] .theme-icon-sun { display: none; }
    [data-theme="light"] .theme-icon-moon { display: inline-block !important; }
    @media (prefers-color-scheme: light) {
      :where(:root:not([data-theme="dark"])) .theme-icon-sun { display: none; }
      :where(:root:not([data-theme="dark"])) .theme-icon-moon { display: inline-block !important; }
    }

    /* Header, navigation buttons, and system pill are provided by components.css */

    main {
      flex: 1;
      display: flex;
      flex-direction: column;
      min-height: calc(100vh - var(--header-height));
      min-height: calc(100dvh - var(--header-height));
      max-width: 1120px;
      margin: 0 auto;
      padding: clamp(48px, 8vh, 92px) 24px 60px;
      width: 100%;
    }

    .hero {
      text-align: center;
      margin-bottom: 36px;
    }

    .hero h1 {
      font-size: 2.6rem;
      font-weight: 800;
      letter-spacing: -0.03em;
      margin-bottom: 12px;
      color: var(--text-primary);
    }

    .hero p {
      font-size: 1.05rem;
      color: var(--text-secondary);
      max-width: 680px;
      margin: 0 auto;
      line-height: 1.6;
    }

    .legal-card {
      background: var(--warning-bg);
      border: 1px solid var(--warning-border);
      border-radius: 10px;
      padding: 14px 18px;
      margin-bottom: 36px;
      font-size: 0.88rem;
      color: var(--text-secondary);
      display: flex;
      align-items: center;
      gap: 14px;
    }

    .legal-icon {
      color: var(--warning-text);
      flex-shrink: 0;
      display: flex;
      align-items: center;
      justify-content: center;
    }

    .section-title {
      font-size: 1.15rem;
      font-weight: 700;
      letter-spacing: -0.01em;
      margin: 32px 0 16px;
      display: flex;
      align-items: center;
      gap: 8px;
      color: var(--text-primary);
      font-family: 'JetBrains Mono', monospace;
    }

    .grid {
      display: grid;
      grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
      align-items: start;
      gap: 16px;
      margin-bottom: 8px;
    }

    .card {
      background: var(--bg-card);
      border: 1px solid var(--border-subtle);
      border-radius: 10px;
      padding: 18px;
      display: flex;
      flex-direction: column;
      gap: 14px;
      transition: border-color 0.15s ease, background 0.15s ease;
    }

    .card:hover {
      border-color: var(--border-focus);
      background: var(--bg-card-hover);
    }

    .card-header-row {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
    }

    .card h3 {
      font-size: 0.98rem;
      font-weight: 600;
      color: var(--text-primary);
    }

    .platform-tag {
      font-family: 'JetBrains Mono', monospace;
      font-size: 0.72rem;
      padding: 2px 7px;
      border-radius: 4px;
      background: var(--code-bg);
      border: 1px solid var(--border-subtle);
      color: var(--text-muted);
      white-space: nowrap;
    }

    .code-box {
      background: var(--code-bg);
      border: 1px solid var(--border-subtle);
      border-radius: 8px;
      padding: 10px 12px;
      font-family: 'JetBrains Mono', monospace;
      font-size: 0.80rem;
      color: var(--text-primary);
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 10px;
      word-break: break-all;
    }

    .code-box span {
      overflow-wrap: anywhere;
    }

    .copy-btn {
      background: var(--surface-inset);
      border: 1px solid var(--border-subtle);
      color: var(--text-primary);
      border-radius: 6px;
      padding: 5px 10px;
      font-size: 0.72rem;
      font-weight: 600;
      cursor: pointer;
      flex-shrink: 0;
      transition: all 0.15s ease;
      font-family: inherit;
    }

    .copy-btn:hover {
      border-color: var(--primary);
      color: var(--primary);
    }

    .copy-btn.copied {
      background: rgba(16, 185, 129, 0.15);
      border-color: var(--success);
      color: var(--success);
    }

    /* Footer — With Expanded Documentation Links */
    footer.site-footer,
    footer {
      border-top: 1px solid var(--border-subtle);
      padding: 56px 24px 36px;
      background: var(--bg-canvas);
      margin-top: 50px;
    }

    .footer-inner {
      max-width: 1200px;
      margin: 0 auto;
      display: flex;
      flex-direction: column;
      gap: 36px;
    }

    .footer-top {
      display: flex;
      justify-content: space-between;
      align-items: flex-start;
      flex-wrap: wrap;
      gap: 36px;
    }

    .footer-brand {
      max-width: 320px;
    }

    .footer-brand-title {
      display: flex;
      align-items: center;
      gap: 10px;
      font-weight: 700;
      font-size: 1.05rem;
      color: var(--text-primary);
      margin-bottom: 10px;
    }

    .footer-brand-desc {
      font-size: 0.84rem;
      color: var(--text-muted);
      line-height: 1.6;
    }

    .footer-links-group {
      display: flex;
      gap: 40px;
      flex-wrap: wrap;
    }

    .footer-col h5 {
      font-size: 0.78rem;
      font-weight: 700;
      color: var(--text-primary);
      text-transform: uppercase;
      letter-spacing: 0.06em;
      margin-bottom: 14px;
    }

    .footer-col ul {
      list-style: none;
      display: flex;
      flex-direction: column;
      gap: 8px;
      padding: 0;
      margin: 0;
    }

    .footer-col a {
      color: var(--text-muted);
      font-size: 0.84rem;
      transition: color 0.15s ease;
      text-decoration: none;
    }

    .footer-col a:hover {
      color: var(--primary);
    }

    .footer-bottom {
      padding-top: 24px;
      border-top: 1px solid var(--border-subtle);
      display: flex;
      justify-content: space-between;
      align-items: center;
      flex-wrap: wrap;
      gap: 14px;
      font-size: 0.8rem;
      color: var(--text-muted);
    }

    .footer-legal-notice {
      font-size: 0.78rem;
      color: var(--text-muted);
      max-width: 680px;
      line-height: 1.5;
    }

    @media (max-width: 768px) {
      .footer-top {
        flex-direction: column;
      }
      .footer-links-group {
        width: 100%;
        justify-content: space-between;
      }
    }

    /* Tabs Navigation */
    .tabs-nav {
      display: flex;
      gap: 8px;
      border-bottom: 1px solid var(--border-subtle);
      margin-bottom: 24px;
      flex-wrap: wrap;
    }

    .tab-btn {
      display: inline-flex;
      align-items: center;
      gap: 8px;
      padding: 10px 16px;
      font-family: inherit;
      font-size: 0.88rem;
      font-weight: 500;
      color: var(--text-muted);
      background: none;
      border: none;
      border-bottom: 2px solid transparent;
      cursor: pointer;
      margin-bottom: -1px;
      transition: color 0.15s ease, border-color 0.15s ease;
    }

    .tab-btn:hover {
      color: var(--text-primary);
    }

    .tab-btn.active, .tab-btn[aria-selected="true"] {
      color: var(--brand);
      border-bottom-color: var(--brand);
      font-weight: 600;
    }

    .tab-panel {
      display: none;
    }

    .tab-panel.active {
      display: block;
    }

    .card-desc {
      font-size: 0.85rem;
      color: var(--text-secondary);
      line-height: 1.5;
    }

    .card-footer-meta {
      display: flex;
      justify-content: flex-end;
      margin-top: -4px;
    }

    .inspect-script-link {
      font-size: 0.76rem;
      color: var(--text-muted);
      text-decoration: none;
      font-family: 'JetBrains Mono', monospace;
      transition: color 0.15s ease;
    }

    .inspect-script-link:hover {
      color: var(--brand);
      text-decoration: underline;
    }

    .header-scroll-progress {
      position: absolute;
      bottom: -1px;
      left: 0;
      height: 2px;
      background: var(--brand);
      width: 0%;
      transition: width 50ms linear;
      z-index: 1001;
    }
