/* ============================================================================
 * Studio by Bichachi — Shared Design System
 * ----------------------------------------------------------------------------
 * Single source of truth for the visual design system, extracted from
 * the canonical studio (index.html).
 *
 * Include this in every page BEFORE the page's local <style> block:
 *   <link rel="stylesheet" href="/static/design-tokens.css">
 *
 * Sections:
 *   1. TOKENS — colors, typography, radius, motion
 *   2. RESET + BASE — element defaults
 *   3. TYPOGRAPHY — .display-h, .eyebrow, .italic-accent
 *   4. HEADER — <header>, .logo, nav, .header-right, mobile nav
 *   5. BUTTONS — .btn-primary, .btn-secondary, .header-icon-btn
 *   6. THEME TOGGLE — .theme-toggle
 *   7. LANGUAGE SWITCHER — .lang-switcher-*
 *   8. FORM ELEMENTS — .text-input, label
 *   9. CHIPS + SEGMENTED — .chip / .chips, .seg / .segmented
 *  10. MODAL — .modal-overlay, .modal-title, .modal-close
 *  11. TOAST — .toast
 *  12. INFO PILL — .info-pill, .info-tooltip
 *  13. ANIMATIONS — keyframes
 *  14. UTILITIES — .muted, .sr-only, .mobile-only, .desktop-only
 * ========================================================================== */

/* ============================================================
 * 1. TOKENS
 * ============================================================ */
:root {
  /* Dark mode (default) — Bichachi Diamonds palette */
  --bg: #0F1A24;            /* Deep Navy — primary background */
  --surface: #19252E;       /* Secondary Navy — panels */
  --surface-2: #1F2D38;     /* Slightly elevated */
  --surface-3: #253641;     /* Highest elevation */
  --border: #243340;        /* Subtle dividers */
  --border-strong: #344552; /* Stronger borders */
  --text: #FFFFFF;          /* Pure white — primary text */
  --text-2: #EDEDED;        /* Soft light gray — secondary */
  --text-3: #8A99A8;        /* Muted — tertiary / labels */
  --accent: #7D9B6A;        /* Metallic gold — accent only */
  --accent-dim: #5F7A50;    /* Darker gold for hover / secondary */
  --accent-glow: rgba(125, 155, 106, 0.12);
  --accent-hover: #9DBB88;  /* Bright-gold hover (used on filled accent btns) */
  --error: #C8585A;
  --success: #6BAA75;
  --warn: #D4A24B;

  /* Header bg — semi-transparent navy with backdrop blur applied */
  --header-bg: rgba(15, 26, 36, 0.85);

  /* Modal overlay bg */
  --modal-overlay-bg: rgba(15, 26, 36, 0.92);

  /* Radius (intentionally tight — premium-restrained) */
  --radius: 2px;
  --radius-lg: 4px;
  --radius-pill: 100px;

  /* Typography */
  --font-display: 'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-body:    'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:    'Geist Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  --font-serif:   'Times New Roman', Times, serif;

  /* Motion */
  --t-fast: 0.15s;
  --t-base: 0.2s;
  --t-slow: 0.35s;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

[data-theme="light"] {
  --bg: #F7F5F0;            /* Warm off-white */
  --surface: #FFFFFF;
  --surface-2: #EFEDE5;
  --surface-3: #E5E1D5;
  --border: #DFD9CC;
  --border-strong: #C0B9A8;
  --text: #0F1A24;          /* Navy as text — preserves brand DNA */
  --text-2: #2C3A47;
  --text-3: #6B7783;
  --accent: #7D9B6A;        /* Slightly darker gold for contrast on light */
  --accent-dim: #5F7A50;
  --accent-glow: rgba(125, 155, 106, 0.12);
  --accent-hover: #5F7A50;
  --error: #B85450;
  --success: #4F8559;
  --warn: #A87B25;

  --header-bg: rgba(247, 245, 240, 0.88);
  --modal-overlay-bg: rgba(247, 245, 240, 0.94);
}

/* ============================================================
 * 2. RESET + BASE
 * ============================================================ */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  overflow-x: hidden;
}

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

a {
  color: var(--accent);
  text-decoration: none;
  transition: color var(--t-base);
}
a:hover { color: var(--accent-dim); }

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

html { scrollbar-gutter: stable; }

/* ============================================================
 * 3. TYPOGRAPHY
 * ============================================================ */

/* Big display heading — the studio's hero pattern.
 * Usage:  <h1 class="display-h">Your <em>account</em>.</h1>
 * The <em> inside renders gold + non-italic + weight 300. */
.display-h {
  font-family: var(--font-display);
  font-weight: 200;
  font-size: 44px;
  line-height: 1.05;
  letter-spacing: -0.025em;
  color: var(--text);
}
.display-h em {
  font-style: normal;
  color: var(--accent);
  font-weight: 300;
}

/* Small uppercase label above headings (or anywhere needing a section tag) */
.eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-3);
}

/* Inline italic-accent — when you want serif italic gold for emphasis.
 * Different from .display-h em which is non-italic. */
.italic-accent {
  font-family: var(--font-serif);
  font-style: italic;
  color: var(--accent);
}

/* ============================================================
 * 4. HEADER
 * ============================================================ */

/* The bare <header> element gets these styles automatically.
 * Pages can also use class="site-header" for non-header tags. */
header,
.site-header {
  border-bottom: 1px solid var(--border);
  padding: 18px 40px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  backdrop-filter: blur(12px);
  background: var(--header-bg);
  position: sticky;
  top: 0;
  z-index: 50;
}

/* Brand wordmark — BICHACHI + Studio with separator + gold diamond.
 * Usage:
 *   <div class="logo">BICHACHI <span class="logo-tag">Studio</span></div>
 * OR (for non-studio pages, with home link):
 *   <a class="logo" href="/">BICHACHI <span class="logo-tag">Studio</span></a>
 */
.logo {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
}
.logo:hover { color: var(--text); }
.logo::before {
  content: '\25CF';
  color: var(--accent);
  font-size: 9px;
  font-weight: normal;
  letter-spacing: normal;
}
.logo-tag {
  font-family: var(--font-body);
  font-weight: 300;
  font-size: 12px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--accent);
  border-left: 1px solid var(--border-strong);
  padding-left: 14px;
  margin-left: 4px;
}

/* Site nav (desktop, inline) */
nav {
  display: flex;
  gap: 36px;
  font-size: 13px;
}
nav a {
  color: var(--text-2);
  text-decoration: none;
  letter-spacing: 0.02em;
  transition: color var(--t-base);
  position: relative;
}
nav a:hover { color: var(--text); }
nav a.active { color: var(--text); }
nav a.active::after {
  content: '';
  position: absolute;
  bottom: -22px;
  left: 0; right: 0;
  height: 1px;
  background: var(--accent);
}

/* Right-side actions group inside the header */
.header-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Mobile nav — Gmail-style dropdown opening below a hamburger toggle */
.mobile-nav-wrapper { position: relative; }
.mobile-nav-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
  padding: 6px 0;
  display: none;
  flex-direction: column;
  z-index: 200;
}
[dir="rtl"] .mobile-nav-dropdown { right: auto; left: 0; }
.mobile-nav-dropdown.show { display: flex; }
.mobile-nav-dropdown a {
  display: block;
  padding: 10px 18px;
  color: var(--text-2);
  text-decoration: none;
  font-size: 14px;
  font-weight: 300;
  transition: background var(--t-fast), color var(--t-fast);
}
.mobile-nav-dropdown a:hover,
.mobile-nav-dropdown a:focus {
  background: var(--surface-2);
  color: var(--accent);
  outline: none;
}
.mobile-nav-dropdown a.active { color: var(--accent); }
.mobile-nav-dropdown a + a { border-top: 1px solid var(--border); }

/* Credits pill (header-right element in studio).
 *   <a class="credits" href="/packs"><b>123</b> <span>credits</span></a>  */
.credits {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-2);
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 8px;
}
a.credits {
  text-decoration: none;
  cursor: pointer;
  transition: border-color var(--t-base), color var(--t-base), background var(--t-base);
}
a.credits:hover {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(125, 155, 106, 0.06);
}
.credits b {
  color: var(--accent);
  font-weight: 500;
}

/* ============================================================
 * 5. BUTTONS
 * ============================================================ */

/* Primary CTA — gold, used for the main action on a page. */
.btn-primary {
  background: var(--accent);
  color: var(--bg);
  border: none;
  padding: 14px 28px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color var(--t-base);
  display: inline-flex;
  align-items: center;
  gap: 12px;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}
.btn-primary:disabled {
  background: var(--border-strong);
  color: var(--text-3);
  cursor: not-allowed;
  box-shadow: none;
}

/* Secondary — subdued, used alongside or instead of primary. */
.btn-secondary {
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 14px 22px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--t-base);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  backdrop-filter: blur(12px);
}
.btn-secondary:hover { background: var(--surface-3); }

/* Cost annotation that sometimes appears inside primary btn:
 *   <button class="btn-primary">Generate <span class="btn-cost">8 cr</span></button> */
.btn-cost {
  font-family: var(--font-mono);
  font-size: 12px;
  padding-left: 12px;
  border-left: 1px solid rgba(15, 26, 36, 0.3);
}

/* Icon-only header button — same visual as .theme-toggle but separate class
 * because it gets used for hamburger nav, help, sign-out, etc. */
.theme-toggle,
.header-icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-2);
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color var(--t-base), color var(--t-base);
  padding: 0;
  font-family: inherit;
}
.theme-toggle:hover,
.header-icon-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ============================================================
 * 6. THEME TOGGLE (icon swap by data-theme)
 * ============================================================ */
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="light"] .theme-toggle .icon-sun { display: block; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }

/* ============================================================
 * 7. LANGUAGE SWITCHER
 * ============================================================ */
.lang-switcher-mount { display: inline-flex; align-items: center; }
.lang-switcher { position: relative; display: inline-block; }
.lang-switcher-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 11px;
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--t-base);
}
.lang-switcher-toggle:hover {
  border-color: rgba(125, 155, 106, 0.45);
  color: var(--accent);
}
.lang-switcher-toggle[aria-expanded="true"] {
  border-color: rgba(125, 155, 106, 0.55);
  color: var(--accent);
  background: var(--accent-glow);
}
.lang-switcher-toggle svg { transition: transform var(--t-base); }
.lang-switcher-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
.lang-switcher-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 170px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.42);
  padding: 6px;
  display: none;
  z-index: 1000;
}
[dir="rtl"] .lang-switcher-menu { right: auto; left: 0; }
.lang-switcher-menu.open {
  display: block;
  animation: langMenuFade var(--t-base) var(--ease-out);
}
.lang-option {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: 0;
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: background var(--t-fast), color var(--t-fast);
}
[dir="rtl"] .lang-option { text-align: right; }
.lang-option:hover { background: rgba(125, 155, 106, 0.08); color: var(--accent); }
.lang-option.active { background: rgba(125, 155, 106, 0.10); color: var(--accent); }
.lang-option .lang-code {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-3);
  letter-spacing: 0.04em;
  min-width: 22px;
}
.lang-option:hover .lang-code,
.lang-option.active .lang-code { color: var(--accent); }
.lang-option .lang-name { font-weight: 500; }

/* ============================================================
 * 8. FORM ELEMENTS
 * ============================================================ */

/* Canonical text input — matches the studio's .text-input pattern */
.text-input,
input[type="text"].std,
input[type="email"].std,
input[type="password"].std,
input[type="tel"].std,
input[type="number"].std,
input[type="url"].std,
input[type="search"].std,
textarea.std {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 14px;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color var(--t-base);
}
.text-input:focus,
input.std:focus,
textarea.std:focus { border-color: var(--accent-dim); }
.text-input::placeholder,
input.std::placeholder,
textarea.std::placeholder { color: var(--text-3); }

/* Autofill — keep field looking the same as empty state */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 100px var(--bg) inset !important;
  -webkit-text-fill-color: var(--text) !important;
  caret-color: var(--text);
  transition: background-color 600000s 0s, color 600000s 0s;
}

/* Section title — small uppercase tracked label, sits above field groups */
.section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-3);
  margin-bottom: 14px;
}

/* ============================================================
 * 9. CHIPS + SEGMENTED
 * ============================================================ */

/* Pill chip group — for filter / option chips. */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-2);
  padding: 9px 16px;
  border-radius: var(--radius-pill);
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--t-base);
  letter-spacing: 0.005em;
}
.chip:hover {
  border-color: var(--border-strong);
  color: var(--text);
}
.chip.active {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  font-weight: 500;
}

/* Segmented card-buttons — bigger, with title + sub. */
.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.seg {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  padding: 18px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.25s;
  text-align: left;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.seg:hover {
  border-color: var(--border-strong);
  background: var(--surface-2);
}
.seg.active {
  border-color: var(--accent);
  background: var(--surface-2);
  color: var(--text);
}
.seg-title {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.005em;
}
.seg-sub {
  font-size: 11px;
  color: var(--text-3);
}

/* ============================================================
 * 10. MODAL
 * ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--modal-overlay-bg);
  backdrop-filter: blur(20px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 60px 40px;
  animation: fadeIn 0.4s;
}
.modal-overlay.active,
.modal-overlay.show { display: flex; }

.modal {
  max-width: 1200px;
  width: 100%;
  max-height: 100%;
  overflow-y: auto;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 32px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.modal-title {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 200;
  letter-spacing: -0.025em;
}
.modal-title em {
  color: var(--accent);
  font-style: normal;
  font-weight: 300;
}

.modal-close {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-2);
  padding: 8px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  font-size: 12px;
  transition: color var(--t-base), border-color var(--t-base);
}
.modal-close:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

/* ============================================================
 * 11. TOAST
 * ============================================================ */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--accent);
  color: var(--text);
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  z-index: 200;
  display: none;
  animation: slideUp 0.3s;
  box-shadow: 0 12px 40px -8px rgba(0, 0, 0, 0.6);
}
.toast.show { display: block; }

/* ============================================================
 * 12. INFO PILL + TOOLTIP
 * ============================================================ */
.info-pill {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text-2);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: help;
  transition: background var(--t-fast), color var(--t-fast);
}
.info-pill:hover,
.info-pill:focus {
  background: var(--accent);
  color: var(--bg);
  outline: none;
}

/* Inline variant — sits next to text rather than absolute-positioned */
.info-pill-inline { vertical-align: middle; margin-left: 6px; }

/* ============================================================
 * 13. ANIMATIONS
 * ============================================================ */
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes slideUp {
  from { opacity: 0; transform: translate(-50%, 16px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes pulse {
  0%, 100% { opacity: 0.4; }
  50%      { opacity: 1; }
}
@keyframes langMenuFade {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Live-preview pulsing dot */
.pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  animation: pulse 2s ease-in-out infinite;
  display: inline-block;
  margin-right: 8px;
}

/* ============================================================
 * 14. UTILITIES
 * ============================================================ */
.muted { color: var(--text-3); }
.text-accent { color: var(--accent); }
.text-error { color: var(--error); }
.text-success { color: var(--success); }
.font-mono { font-family: var(--font-mono); }
.font-display { font-family: var(--font-display); }

.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;
}

/* Responsive show/hide helpers */
.mobile-only { display: none; }
.desktop-only { display: revert; }
@media (max-width: 1024px) {
  .mobile-only { display: revert; }
  .desktop-only { display: none; }
}

/* ============================================================
 * 15. RESPONSIVE HEADER (matches studio's media query)
 * ============================================================ */
@media (max-width: 1024px) {
  header,
  .site-header {
    padding: 14px 20px;
  }
  /* Hide the desktop inline nav on small screens — pages use .mobile-only
   * hamburger inside .header-right instead. */
  header > nav { display: none; }
}

@media (max-width: 480px) {
  header,
  .site-header {
    padding: 12px 16px;
  }
  .display-h { font-size: 28px; }
  .logo-tag { display: none; }
}

/* The high-end animation layer lives in a separate, additive file so it can
 * be dropped onto any page (even ones that still carry their own inline CSS)
 * without pulling in this whole base system:
 *     <link rel="stylesheet" href="/static/studio-motion.css">
 *     <script src="/static/studio-motion.js"></script>            */
