/*
 * KalyRails — restyled to match the KUSD design system (kusd.kalychain.io).
 * Palette: primary = amber (#f59e0b), backgrounds = near-black (#0a0a0a).
 * Legacy variable names (--teal, --blue, --navy, --gold) are preserved and
 * remapped to the new palette so existing HTML/inline styles keep working
 * without touching every page. System sans (Arial/Helvetica) — no web fonts.
 */
:root {
  /* Backgrounds — KUSD near-black scale */
  --navy: #0a0a0a;
  --navy-light: #1a1a1a;
  --navy-mid: #1f1f1f;
  --navy-card: #1a1a1a;

  /* Primary — KUSD amber (all legacy blue aliases now resolve to amber) */
  --teal: #f59e0b;
  --teal-glow: #fbbf24;
  --teal-dark: #d97706;
  --teal-bg: rgba(245, 158, 11, 0.08);
  --teal-border: rgba(245, 158, 11, 0.22);

  --blue: #f59e0b;
  --blue-glow: #fbbf24;
  --blue-dark: #d97706;
  --blue-bg: rgba(245, 158, 11, 0.08);
  --blue-border: rgba(245, 158, 11, 0.22);

  /* Accent — same amber family so the site reads mono-accent like KUSD */
  --gold: #f59e0b;
  --gold-glow: #fbbf24;
  --gold-bg: rgba(245, 158, 11, 0.1);
  --gold-border: rgba(245, 158, 11, 0.3);

  /* Text + borders — KUSD tokens */
  --white: #ffffff;
  --gray: #6b7280;
  --gray-light: #9ca3af;
  --border: #262626;
  --border-hover: #404040;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: Arial, Helvetica, sans-serif;
  background: var(--navy);
  color: var(--white);
  line-height: 1.7;
  overflow-x: hidden;
}
.container { max-width: 1120px; margin: 0 auto; padding: 0 24px; }

/* Nav */
nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  padding: 14px 0;
  background: rgba(10, 10, 10, 0.9);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}
nav .container { display: flex; align-items: center; justify-content: space-between; }
.logo {
  display: inline-flex; align-items: center; gap: 10px;
  font-family: Arial, Helvetica, sans-serif; font-size: 20px; font-weight: 700;
  letter-spacing: -0.5px; text-decoration: none; color: var(--white);
}
.logo img {
  width: 32px; height: 32px; object-fit: contain;
  filter: drop-shadow(0 2px 8px rgba(245, 158, 11, 0.25));
}
.logo span { color: var(--gold); }
.nav-links { display: flex; align-items: center; gap: 32px; }
.nav-links a {
  font-size: 14px; color: var(--gray-light);
  text-decoration: none; transition: color 0.2s; font-weight: 500;
}
.nav-links a:hover, .nav-links a.active { color: var(--gold); }
a.cta-nav {
  padding: 10px 24px; border-radius: 8px;
  background: var(--gold); color: #1a1400 !important;
  font-weight: 700 !important; font-size: 14px;
  text-decoration: none; transition: all 0.3s;
  box-shadow: 0 2px 12px rgba(245, 158, 11, 0.25);
}
a.cta-nav:hover {
  background: var(--gold-glow);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(245, 158, 11, 0.4);
}

/* Common elements */
.section-tag {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 12px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--gold); margin-bottom: 16px; display: block;
  font-weight: 600;
}
.hero-tag {
  display: inline-block;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 12px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--gold); border: 1px solid var(--gold-border);
  background: var(--gold-bg);
  padding: 6px 16px; border-radius: 100px; margin-bottom: 32px;
  font-weight: 600;
}
.page-hero {
  padding: 140px 0 80px;
  position: relative;
}
.page-hero::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background:
    radial-gradient(ellipse 60% 50% at 50% 0%, rgba(245, 158, 11, 0.06) 0%, transparent 70%);
  pointer-events: none;
}
.page-hero h1 {
  font-size: clamp(32px, 4.5vw, 52px);
  font-weight: 700; line-height: 1.15;
  letter-spacing: -1.5px; margin-bottom: 20px;
  max-width: 720px;
}
.page-hero h1 em { font-style: normal; color: var(--gold); }
.page-hero p { font-size: 18px; color: var(--gray-light); max-width: 580px; line-height: 1.8; }

h2 { font-size: clamp(26px, 3.5vw, 38px); font-weight: 700; letter-spacing: -0.8px; margin-bottom: 16px; }
h2 em { font-style: normal; color: var(--gold); }
h3 { font-size: 18px; font-weight: 600; letter-spacing: -0.3px; }

.section { padding: 80px 0; border-top: 1px solid var(--border); }

/* Buttons */
.btn-primary {
  display: inline-block; padding: 14px 32px; border-radius: 10px;
  background: var(--gold); color: #1a1400;
  font-weight: 700; font-size: 15px;
  text-decoration: none; transition: all 0.3s;
  border: none; cursor: pointer; text-align: center;
  box-shadow: 0 2px 12px rgba(245, 158, 11, 0.25);
}
.btn-primary:hover {
  background: var(--gold-glow);
  transform: translateY(-2px);
  box-shadow: 0 10px 32px rgba(245, 158, 11, 0.4);
}
.btn-secondary {
  display: inline-block; padding: 14px 32px; border-radius: 10px;
  background: transparent; color: var(--white);
  font-weight: 600; font-size: 15px;
  text-decoration: none; transition: all 0.3s;
  border: 1px solid var(--border-hover);
}
.btn-secondary:hover { border-color: var(--gold); color: var(--gold); }

/* Accent button — alias of primary, kept for markup compatibility */
.btn-accent {
  display: inline-block; padding: 14px 32px; border-radius: 10px;
  background: var(--gold); color: #1a1400;
  font-weight: 700; font-size: 15px;
  text-decoration: none; transition: all 0.3s;
  border: none; cursor: pointer; text-align: center;
  box-shadow: 0 2px 12px rgba(245, 158, 11, 0.25);
}
.btn-accent:hover {
  background: var(--gold-glow);
  transform: translateY(-2px);
  box-shadow: 0 10px 32px rgba(245, 158, 11, 0.4);
}

/* Cards */
.card {
  background: var(--navy-light);
  border: 1px solid var(--border);
  border-radius: 16px; padding: 36px;
  transition: all 0.35s;
}
.card:hover {
  border-color: var(--border-hover);
  transform: translateY(-3px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5), 0 0 40px rgba(245, 158, 11, 0.05);
}
.card h3 { margin-bottom: 10px; }
.card p { font-size: 15px; color: var(--gray-light); line-height: 1.7; }

/* Icon box */
.icon-box {
  width: 48px; height: 48px; border-radius: 12px;
  background: var(--gold-bg); border: 1px solid var(--gold-border);
  color: var(--gold);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 24px; font-size: 22px;
}

/* Code blocks */
.code-block {
  background: #0d0d0d;
  border: 1px solid var(--border);
  border-radius: 12px; padding: 24px 28px;
  overflow-x: auto; margin: 20px 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px; line-height: 1.8;
  color: var(--gray-light);
  white-space: pre;
}
.code-block .comment { color: #6b7280; }
.code-block .keyword { color: #c792ea; }
.code-block .string { color: #86efac; }
.code-block .func { color: var(--gold); }
.code-block .prop { color: #f78c6c; }

/* Diagram containers */
.diagram-container {
  background: var(--navy-light);
  border: 1px solid var(--border);
  border-radius: 16px; padding: 40px;
  margin: 32px 0;
}

/* Grid helpers */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }

/* Footer */
footer {
  padding: 48px 0;
  border-top: 1px solid var(--border);
}
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 40px; margin-bottom: 40px; }
.footer-brand p { font-size: 14px; color: var(--gray-light); max-width: 280px; margin-top: 12px; }
.footer-col h4 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; color: var(--gray-light); margin-bottom: 16px; }
.footer-col a { display: block; font-size: 14px; color: var(--gray-light); text-decoration: none; padding: 4px 0; transition: color 0.2s; }
.footer-col a:hover { color: var(--gold); }
.footer-bottom { border-top: 1px solid var(--border); padding-top: 24px; font-size: 13px; color: var(--gray-light); }
.footer-bottom a { color: var(--gold); text-decoration: none; }
.footer-bottom a:hover { color: var(--gold-glow); }

/* ============================================================
   Responsive — mobile-first breakpoints
   ============================================================ */

/* Mobile hamburger toggle — hidden by default (desktop) */
.nav-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--border-hover);
  color: var(--white);
  width: 42px; height: 42px;
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  line-height: 1;
  transition: border-color 0.2s, color 0.2s;
}
.nav-toggle:hover { border-color: var(--gold); color: var(--gold); }

/* ----- Tablet and small desktop (<= 900px) ----- */
@media (max-width: 900px) {
  .container { padding: 0 20px; }
  .section { padding: 60px 0; }
  h2 { font-size: clamp(24px, 5vw, 34px); }
  .page-hero { padding: 120px 0 60px !important; }
  .page-hero h1 { font-size: clamp(28px, 6.5vw, 44px); letter-spacing: -1px; }
  .page-hero p { font-size: 16px; }

  /* Nav — hamburger takes over */
  .nav-toggle { display: inline-flex; }
  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: rgba(10, 10, 10, 0.98);
    backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    padding: 8px 0;
    max-height: calc(100vh - 70px);
    overflow-y: auto;
  }
  .nav-links a {
    display: block;
    padding: 14px 24px;
    border-bottom: 1px solid var(--border);
    font-size: 15px;
  }
  .nav-links a:last-child { border-bottom: none; }
  .nav-links a.cta-nav {
    margin: 12px 24px 8px;
    text-align: center;
    padding: 12px 24px;
    box-shadow: none;
  }
  nav.open .nav-links { display: flex; }

  /* Built-in grids */
  .grid-2, .grid-3 { grid-template-columns: 1fr 1fr; gap: 20px; }
  .card { padding: 28px; }

  /* Inline-style grid overrides (for per-page hero stats, validator rows, etc.) */
  [style*="grid-template-columns:repeat(4"],
  [style*="grid-template-columns: repeat(4"],
  [style*="grid-template-columns:repeat(5"],
  [style*="grid-template-columns: repeat(5"] {
    grid-template-columns: 1fr 1fr !important;
  }
  [style*="grid-template-columns:repeat(3"],
  [style*="grid-template-columns: repeat(3"] {
    grid-template-columns: 1fr 1fr !important;
  }

  .footer-grid { grid-template-columns: 1fr 1fr; gap: 32px; }
}

/* ----- Phones (<= 640px) ----- */
@media (max-width: 640px) {
  .container { padding: 0 16px; }
  .section { padding: 48px 0; }
  h2 { font-size: clamp(22px, 6vw, 28px); }
  h3 { font-size: 17px; }
  .page-hero { padding: 100px 0 44px !important; }
  .page-hero h1 { font-size: clamp(26px, 8vw, 34px); letter-spacing: -0.5px; }
  .page-hero p { font-size: 15px; line-height: 1.75; }
  .hero-tag, .section-tag { font-size: 11px; letter-spacing: 1.5px; }

  /* Cards and containers */
  .card { padding: 24px; border-radius: 12px; }
  .diagram-container { padding: 20px; border-radius: 12px; }

  /* Buttons — tighter on phone, but do not override inline width:100% */
  .btn-primary, .btn-secondary, .btn-accent {
    padding: 13px 24px; font-size: 14px;
  }
  .btn-primary[style*="padding:18px"], .btn-primary[style*="padding: 18px"] {
    padding: 14px 28px !important; font-size: 15px !important;
  }

  /* Built-in grids collapse fully */
  .grid-2, .grid-3 { grid-template-columns: 1fr; gap: 16px; }

  /* Inline-style grids collapse fully */
  [style*="grid-template-columns:repeat"],
  [style*="grid-template-columns: repeat"] {
    grid-template-columns: 1fr !important;
  }

  /* Shrink oversized inline display numerics */
  [style*="font-size:36px"], [style*="font-size: 36px"] { font-size: 28px !important; }
  [style*="font-size:34px"], [style*="font-size: 34px"] { font-size: 26px !important; }
  [style*="font-size:32px"], [style*="font-size: 32px"] { font-size: 26px !important; }
  [style*="font-size:28px"], [style*="font-size: 28px"] { font-size: 24px !important; }

  /* Contact section dual-CTA flex row on umbrella index */
  #contact > .container > div[style*="display:flex"],
  #contact > .container > div[style*="display: flex"] {
    flex-direction: column;
    align-items: stretch;
  }
  #contact > .container > div[style*="display:flex"] > a,
  #contact > .container > div[style*="display: flex"] > a {
    width: 100%;
    text-align: center;
  }

  /* Footer — single column stack */
  .footer-grid { grid-template-columns: 1fr; gap: 28px; }
  .footer-brand p { max-width: 100%; }

  /* Logo image slightly smaller */
  .logo img { width: 28px; height: 28px; }
  .logo { font-size: 18px; }
}

/* ----- Very small phones (<= 380px) ----- */
@media (max-width: 380px) {
  .page-hero h1 { font-size: 26px; }
  .card { padding: 20px; }
  .btn-primary, .btn-secondary, .btn-accent {
    padding: 12px 20px; font-size: 13px;
  }
}

/* Animations */
@media (prefers-reduced-motion: no-preference) {
  .card, .diagram-container {
    opacity: 0; transform: translateY(16px);
    animation: fadeUp 0.5s ease forwards;
  }
  @keyframes fadeUp { to { opacity: 1; transform: translateY(0); } }
}
