/* ============================================================
   Design tokens
   ============================================================ */
:root {
  --bg:            #1b1d21;
  --bg-raised:     #212327;
  --panel:         #24262b;
  --panel-hover:   #2a2c32;
  --border:        #33353a;
  --border-soft:   #2a2c31;

  --text:          #e6e7e9;
  --text-dim:      #9a9ca3;
  --text-faint:    #6b6d73;

  --brass:         #c98a3e;
  --brass-dim:     #8a5e2c;
  --brass-glow:    rgba(201, 138, 62, 0.18);

  --earth-land:    #2d3036;
  --earth-ocean:   #212327;
  --earth-ring:    #303338;
  --star:          #3c3f46;
  --star-bright:   #55585f;

  --radius:        10px;
  --radius-sm:     6px;

  --font-display:  'Space Grotesk', 'Segoe UI', sans-serif;
  --font-body:     'Inter', 'Segoe UI', sans-serif;
  --font-mono:     'JetBrains Mono', 'Consolas', monospace;

  --topbar-h:      56px;
  --sidebar-w-collapsed: 56px;
  --sidebar-w-expanded:  220px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

body {
  overflow-x: hidden;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--text);
  margin: 0 0 0.5em 0;
}

a { color: var(--brass); text-decoration: none; }
a:hover { text-decoration: underline; }

::selection { background: var(--brass-glow); color: var(--text); }

/* Visible keyboard focus everywhere */
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 2px;
}

/* ============================================================
   Ambient background: stars + rotating earth (decorative, inert)
   ============================================================ */
.ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.stars {
  position: absolute;
  inset: 0;
  background: transparent;
}
.stars span {
  position: absolute;
  border-radius: 50%;
  background: var(--star);
}
.stars span.bright { background: var(--star-bright); }

.earth-wrap {
  position: absolute;
  left: -22vmin;
  bottom: -22vmin;
  width: 60vmin;
  height: 60vmin;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--border-soft), 0 0 90px 10px rgba(0,0,0,0.35) inset;
  background: var(--earth-ocean);
}

.earth-sphere {
  position: absolute;
  top: 0;
  left: 0;
  width: 200%;
  height: 100%;
  animation: earth-rotate 140s linear infinite;
}

.earth-sphere svg { width: 50%; height: 100%; display: block; float: left; }

.earth-shade {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 65% 32%, rgba(255,255,255,0.05), transparent 45%),
              radial-gradient(circle at 30% 75%, rgba(0,0,0,0.45), transparent 60%);
  pointer-events: none;
}

@keyframes earth-rotate {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

/* ============================================================
   Top bar
   ============================================================ */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: rgba(27, 29, 33, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  z-index: 20;
}

.topbar-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-title .mark {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 1.5px solid var(--brass);
  position: relative;
  flex: none;
}
.topbar-title .mark::before {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 1px; height: 26px;
  background: var(--brass-dim);
  transform: translate(-50%, -50%) rotate(35deg);
  opacity: 0.6;
}

.clock {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--text-dim);
  letter-spacing: 0.03em;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.clock .date { color: var(--text-faint); font-size: 0.8rem; }

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
  position: fixed;
  top: var(--topbar-h);
  bottom: 0;
  left: 0;
  width: var(--sidebar-w-collapsed);
  background: rgba(33, 35, 39, 0.9);
  border-right: 1px solid var(--border);
  z-index: 15;
  display: flex;
  flex-direction: column;
  transition: width 0.22s ease;
  overflow: hidden;
}
.sidebar.expanded { width: var(--sidebar-w-expanded); }

.sidebar-toggle {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px 17px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--border-soft);
  color: var(--text-dim);
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.85rem;
}
.sidebar-toggle:hover { color: var(--text); background: var(--panel-hover); }
.sidebar-toggle svg { flex: none; width: 20px; height: 20px; }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 8px 0;
  overflow-y: auto;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 17px;
  color: var(--text-dim);
  white-space: nowrap;
  border-left: 2px solid transparent;
}
.sidebar-link:hover { color: var(--text); background: var(--panel-hover); text-decoration: none; }
.sidebar-link.active { color: var(--text); border-left-color: var(--brass); background: var(--brass-glow); }
.sidebar-link svg { flex: none; width: 20px; height: 20px; }
.sidebar-link .label,
.sidebar-toggle .label {
  display: inline-block;
  font-size: 0.9rem;
  opacity: 0;
  transform: translateX(calc(-1 * (var(--sidebar-w-expanded) - var(--sidebar-w-collapsed))));
  transition: opacity 0.15s ease, transform 0.22s ease;
}
.sidebar.expanded .sidebar-link .label,
.sidebar.expanded .sidebar-toggle .label {
  opacity: 1;
  transform: translateX(0);
}

/* ============================================================
   Page shell
   ============================================================ */
.page {
  position: relative;
  z-index: 1;
  margin-left: var(--sidebar-w-collapsed);
  padding-top: var(--topbar-h);
  min-height: 100vh;
  transition: margin-left 0.22s ease;
}

main {
  max-width: 920px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brass);
  margin-bottom: 10px;
}

.lede {
  color: var(--text-dim);
  font-size: 1.05rem;
  line-height: 1.6;
  max-width: 62ch;
}

/* ============================================================
   Nav cards (used on home + hub pages)
   ============================================================ */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 28px;
}

.nav-card {
  display: block;
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}
.nav-card:hover {
  text-decoration: none;
  border-color: var(--brass-dim);
  background: var(--panel-hover);
  transform: translateY(-2px);
}
.nav-card .icon { width: 26px; height: 26px; color: var(--brass); margin-bottom: 14px; }
.nav-card h3 { font-size: 1.05rem; margin-bottom: 6px; }
.nav-card p { color: var(--text-dim); font-size: 0.88rem; line-height: 1.5; margin: 0; }
.nav-card.disabled { opacity: 0.45; pointer-events: none; }
.nav-card .tag {
  display: inline-block;
  margin-top: 12px;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-faint);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ============================================================
   Recipe page
   ============================================================ */
.recipe-head {
  border-bottom: 1px solid var(--border);
  padding-bottom: 24px;
  margin-bottom: 28px;
}
.recipe-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-top: 16px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-dim);
}
.recipe-meta strong { color: var(--text); font-weight: 600; }

.recipe-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 40px;
}
@media (max-width: 720px) {
  .recipe-layout { grid-template-columns: 1fr; }
}

.ingredients h2, .steps h2 { font-size: 1rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--brass); }

.ingredients ul {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
}
.ingredients li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 0.92rem;
}
.ingredients li span.amt { color: var(--text-dim); font-family: var(--font-mono); font-size: 0.85rem; white-space: nowrap; }

.steps ol { margin: 16px 0 0; padding: 0; list-style: none; counter-reset: step; }
.steps li {
  counter-increment: step;
  position: relative;
  padding: 0 0 24px 42px;
  line-height: 1.65;
}
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0; top: -2px;
  width: 28px; height: 28px;
  border: 1px solid var(--brass-dim);
  color: var(--brass);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.8rem;
}
.steps li:last-child { padding-bottom: 0; }

.note-box {
  margin-top: 28px;
  padding: 16px 18px;
  background: var(--panel);
  border-left: 2px solid var(--brass);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-dim);
  font-size: 0.9rem;
  line-height: 1.6;
}

/* ============================================================
   Code page
   ============================================================ */
.lang-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin: 28px 0 0;
  flex-wrap: wrap;
}
.lang-tab {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  padding: 10px 16px;
  color: var(--text-dim);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
}
.lang-tab:hover { color: var(--text); }
.lang-tab.active { color: var(--brass); border-bottom-color: var(--brass); }

.code-panel { display: none; }
.code-panel.active { display: block; }

.code-block {
  position: relative;
  margin-top: 18px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.code-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-faint);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.copy-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.copy-btn:hover { color: var(--text); border-color: var(--brass-dim); }
.copy-btn.copied { color: var(--brass); border-color: var(--brass); }
.copy-btn svg { width: 13px; height: 13px; }

.code-block pre {
  margin: 0;
  padding: 18px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.6;
}
.code-block code { font-family: var(--font-mono); background: none; }

.explain {
  margin-top: 18px;
  color: var(--text-dim);
  line-height: 1.65;
  font-size: 0.94rem;
}

/* ============================================================
   Password gate
   ============================================================ */
.gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}
.gate-card {
  position: relative;
  z-index: 1;
  width: min(320px, 86vw);
  padding: 34px 30px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
}
.gate-ring {
  width: 44px; height: 44px;
  margin: 0 auto 18px;
  border-radius: 50%;
  border: 1.5px solid var(--brass);
  position: relative;
}
.gate-ring::before {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 1px; height: 58px;
  background: var(--brass-dim);
  transform: translate(-50%, -50%) rotate(35deg);
  opacity: 0.6;
}
.gate-card h2 { font-size: 1.05rem; margin-bottom: 4px; }
.gate-card p { color: var(--text-faint); font-size: 0.82rem; margin: 0 0 20px; }
.gate-card input {
  width: 100%;
  padding: 11px 12px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  text-align: center;
  letter-spacing: 0.08em;
}
.gate-card input:focus { outline: none; border-color: var(--brass); }
.gate-card button {
  width: 100%;
  margin-top: 12px;
  padding: 11px;
  background: var(--brass);
  border: none;
  border-radius: var(--radius-sm);
  color: #1b1d21;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
}
.gate-card button:hover { background: #d99a4e; }
.gate-error {
  margin-top: 12px;
  font-size: 0.8rem;
  color: #d97575;
  min-height: 1em;
}
.gate-card.shake { animation: shake 0.35s ease; }
@keyframes shake {
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 640px) {
  main { padding: 28px 16px 60px; }
  .topbar { padding: 0 14px; }
  .topbar-title span.full { display: none; }
  .clock .date { display: none; }
}
