/* Design tokens */
:root {
  --bg: #F8EFD8;
  --fg: #0E0F0E;
  --primary: #2F5C4A;
  --accent: #D57A2C;
  --border: #E7E3DA;
  --muted: #F4EDDF;
  --muted-foreground: #5B5A56;

  --radius: 12px;
  --shadow: 0 6px 18px rgba(0,0,0,0.04);
  --container: 1200px;

  --space-1: 8px;
  --space-2: 12px;
  --space-3: 16px;
  --space-4: 24px;
  --space-5: 32px;
  --space-6: 40px;
  --space-7: 56px;
  --space-8: 72px;
  --space-9: 88px;
  --space-10: 96px;
}

/* Base */
html { font-size: 18px; }
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Noto Sans", sans-serif;
  line-height: 1.7;
}
img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }

/* Typography */
h1 {
  font-weight: 700;
  font-size: clamp(48px, 6vw, 64px);
  line-height: 1.08;
  letter-spacing: -0.015em;
  margin: 0 0 var(--space-3);
}
h2 {
  font-weight: 700;
  font-size: clamp(32px, 4vw, 40px);
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0 0 var(--space-3);
}
h3 {
  font-weight: 600;
  font-size: clamp(24px, 3vw, 28px);
  line-height: 1.22;
  letter-spacing: -0.005em;
  margin: 0 0 var(--space-2);
}
.lead { font-size: clamp(20px, 2.2vw, 22px); line-height: 1.65; color: var(--muted-foreground); }
small { color: var(--muted-foreground); }

/* Layout */
.container { max-width: var(--container); margin: 0 auto; padding: 0 5vw; }
.section { padding: var(--space-9) 0; }
.section + .section { padding-top: var(--space-10); }
.grid { display: grid; gap: var(--space-5); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 960px) { .grid-3 { grid-template-columns: 1fr; } .grid-2 { grid-template-columns: 1fr; } }

/* Dark section variant - truly transparent */
.section-dark { background: none !important; }
.section-dark h2, .section-dark .lead, .section-dark p, .section-dark li, .section-dark small { color: var(--fg); }
.section-dark a { color: var(--primary); }

/* Surfaces */
.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-5);
}
.soft-border { border: 1px solid var(--border); border-radius: var(--radius); }

/* Fixed Sidebar */
.fixed-sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 280px;
  background: linear-gradient(135deg, #2a3f5f 0%, #1a2332 100%);
  z-index: 40;
  padding: 40px 30px;
  overflow-y: auto;
}

.fixed-sidebar::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(2px 2px at 20% 30%, white, transparent),
                    radial-gradient(2px 2px at 60% 70%, white, transparent),
                    radial-gradient(1px 1px at 50% 50%, white, transparent),
                    radial-gradient(1px 1px at 80% 10%, white, transparent),
                    radial-gradient(2px 2px at 90% 60%, white, transparent);
  background-size: 200px 200px;
  background-position: 0 0, 40px 60px, 130px 270px, 70px 100px, 140px 40px;
  opacity: 0.3;
  animation: sparkle 120s linear infinite;
  pointer-events: none;
}

@keyframes sparkle {
  from { transform: translateY(0); }
  to { transform: translateY(-200px); }
}

.fixed-sidebar .sidebar-logo {
  height: 32px;
  width: auto;
  display: block;
  margin-bottom: 48px;
  position: relative;
  z-index: 1;
}

.fixed-sidebar .sidebar-nav {
  position: relative;
  z-index: 1;
}

.fixed-sidebar .sidebar-nav a {
  display: block;
  color: rgba(255, 255, 255, 0.9);
  padding: 12px 0;
  font-size: 16px;
  font-weight: 400;
  letter-spacing: 0.01em;
  transition: color 200ms ease;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.fixed-sidebar .sidebar-nav a:hover {
  color: white;
}

.fixed-sidebar .sidebar-nav a:first-child {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Main content adjustment */
.with-sidebar {
  margin-left: 280px;
}

/* Navbar (simplified for use with sidebar) */
.navbar { display: none; }

/* Mobile adjustments */
@media (max-width: 960px) {
  .fixed-sidebar { 
    transform: translateX(-100%);
    transition: transform 220ms ease;
  }
  .fixed-sidebar.open {
    transform: translateX(0);
  }
  .with-sidebar {
    margin-left: 0;
  }
  .navbar { 
    display: block;
    position: sticky; 
    top: 0; 
    backdrop-filter: saturate(180%) blur(8px); 
    background: color-mix(in oklab, var(--bg) 86%, white); 
    border-bottom: 1px solid var(--border); 
    z-index: 50; 
  }
  .navbar-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
  .brand { display:flex; align-items:center; gap: 10px; font-weight: 700; letter-spacing: -0.01em; }
  .brand-logo { height: 28px; width: auto; display:block; }
  .mobile-toggle { display: inline-flex; align-items: center; gap: 8px; }
}

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 10px; padding: 12px 18px; border-radius: 10px; border: 1px solid transparent; font-weight: 600; cursor: pointer; transition: transform 220ms ease, background-color 220ms ease, box-shadow 220ms ease; }
.btn:focus-visible { outline: 2px solid color-mix(in oklab, var(--primary) 60%, black); outline-offset: 2px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { transform: translateY(-1px); }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-link { padding: 0; border: none; background: none; color: var(--primary); }
.btn .arrow { display: inline-block; transition: transform 220ms ease; }
.btn:hover .arrow { transform: translateX(2px); }

/* Hero */
.hero { display: grid; gap: var(--space-6); align-items: center; min-height: 56vh; position: relative; }
.hero-visual {
  background: radial-gradient(1000px 500px at 50% -10%, rgba(47,92,74,0.35), transparent),
              linear-gradient(180deg, rgba(0,0,0,0.35), rgba(0,0,0,0.15)),
              url('/public/iceberg_square.jpg') center/cover no-repeat fixed;
  color: #fff;
}
.hero-visual .lead { color: rgba(255,255,255,0.9); }
.hero-visual .btn-ghost { border-color: rgba(255,255,255,0.5); color: #fff; }
.hero-visual .brand .brand-logo { filter: drop-shadow(0 2px 6px rgba(0,0,0,0.25)); }

/* Patterns */
.kicker { text-transform: uppercase; font-weight: 700; letter-spacing: 0.12em; color: var(--muted-foreground); font-size: 12px; }
.sep { height: 1px; background: var(--border); margin: var(--space-6) 0; }

/* Editorial */
.article { max-width: 800px; margin: 0 auto; }
.article h2 { margin-top: var(--space-7); }
.article h3 { margin-top: var(--space-5); }
.article p { margin: 0 0 var(--space-4); }
.article ul { margin: 0 0 var(--space-4); padding-left: 1.5rem; }
.article li { margin: 0 0 10px; }
.article img { border-radius: var(--radius); border: 1px solid var(--border); }
.article blockquote { margin: var(--space-4) 0; padding: 8px 12px; border-left: 3px solid var(--primary); color: var(--muted-foreground); background: #fff; border-radius: 0 8px 8px 0; }
.article code { background: #fff; border: 1px solid var(--border); padding: 2px 6px; border-radius: 6px; }

/* Collapsible markdown cards */
.md-card { border: 1px solid #CFC9BB; border-radius: 12px; padding: 12px 16px; background: transparent; color: inherit; }
.md-card + .md-card { margin-top: 12px; }
.md-card-header { display:flex; align-items:center; justify-content:space-between; gap:12px; cursor:pointer; user-select:none; }
.md-card-header h3, .md-card-header h2 { margin:0; font-size: 20px; letter-spacing:-0.01em; color: var(--fg); }
.md-card .chev { transition: transform 200ms ease; color: var(--fg); }
.md-card[aria-expanded="true"] .chev { transform: rotate(90deg); }
.md-card-content { display:none; margin-top: 8px; }
.md-card[aria-expanded="true"] .md-card-content { display:block; }

/* Reveal on scroll */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity 220ms ease, transform 220ms ease; }
.reveal.visible { opacity: 1; transform: translateY(0); }

/* Accessibility helpers */
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,1px,1px); white-space: nowrap; border: 0; }
