/* =============================================================
   layout.css — Shared layout system, grid, components
   A Love Letter to the Web
   ============================================================= */

/* ── Page Shell ─────────────────────────────────────────────── */
.page {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── Page Header ────────────────────────────────────────────── */
.page-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--z-overlay);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--content-padding);
  background: oklch(8% 0.01 265 / 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
}

.page-header__logo {
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.02em;
}

.page-header__nav {
  display: flex;
  align-items: center;
  gap: var(--space-xl);
}

.page-header__nav a {
  font-size: var(--text-sm);
  color: var(--color-muted);
  transition: color var(--duration-base) var(--ease-out);
}

.page-header__nav a:hover {
  color: var(--color-text);
}

/* ── Trophy icon (Layer 2 / Task 9) ─────────────────────────── */
.trophy-icon {
  font-size: 1rem;
  text-decoration: none;
  margin-left: 4px;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 200ms ease, transform 150ms ease;
}
.trophy-icon:hover { background: oklch(1 0 0 / 0.08); transform: translateY(-2px); }
.trophy-icon:focus-visible { outline: 2px solid oklch(0.75 0.2 290); outline-offset: 2px; }
/* Suppress underline animation that .anim-underline carries (trophy is icon-only). */
.page-header__nav .trophy-icon::after,
.zone-nav-top .trophy-icon::after,
.zone-nav-bar .trophy-icon::after {
  content: none !important;
}

/* ── Sections ───────────────────────────────────────────────── */
.section-full {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl) var(--content-padding);
}

.section-content {
  max-width: var(--content-width);
  width: 100%;
  margin-inline: auto;
  padding: var(--space-2xl) var(--content-padding);
}

/* ── Grid Systems ───────────────────────────────────────────── */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr));
  gap: var(--space-lg);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  gap: var(--space-lg);
}

/* ── Split Pane ─────────────────────────────────────────────── */
.split-pane {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
  align-items: start;
}

@media (max-width: 768px) {
  .split-pane {
    grid-template-columns: 1fr;
  }
}

/* ── Card ───────────────────────────────────────────────────── */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  transition:
    transform var(--duration-slow) var(--ease-out),
    box-shadow var(--duration-slow) var(--ease-out),
    border-color var(--duration-base) var(--ease-out);
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 16px 48px oklch(0% 0 0 / 0.4);
  border-color: var(--color-primary);
}

.card__title {
  font-size: var(--text-md);
  font-weight: 600;
  margin-bottom: var(--space-sm);
}

.card__body {
  font-size: var(--text-sm);
  color: var(--color-muted);
  line-height: 1.7;
}

/* ── Code Block ─────────────────────────────────────────────── */
.code-block {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  background: oklch(6% 0.01 265);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  overflow-x: auto;
  line-height: 1.7;
  white-space: pre;
}

/* Syntax highlighting */
.code-block .keyword   { color: oklch(70% 0.18 285); }
.code-block .property  { color: oklch(72% 0.15 220); }
.code-block .value     { color: oklch(75% 0.18 145); }
.code-block .string    { color: oklch(75% 0.18 85);  }
.code-block .comment   { color: var(--color-muted); font-style: italic; }
.code-block .selector  { color: oklch(72% 0.15 30);  }
.code-block .function  { color: oklch(70% 0.18 200); }

/* ── Zone Nav ───────────────────────────────────────────────── */
.zone-nav {
  position: fixed;
  bottom: var(--space-xl);
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-overlay);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  background: oklch(12% 0.015 265 / 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
}

.zone-nav a {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-muted);
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-pill);
  transition:
    color var(--duration-base) var(--ease-out),
    background var(--duration-base) var(--ease-out);
}

.zone-nav a:hover,
.zone-nav a[aria-current="page"] {
  color: var(--color-text);
  background: var(--color-border);
}

/* ── Mobile Breakpoint ──────────────────────────────────────── */
@media (max-width: 768px) {
  .page-header__nav {
    gap: var(--space-md);
  }

  .section-full {
    padding: var(--space-xl) var(--content-padding);
  }

  .card {
    padding: var(--space-lg);
  }

  .zone-nav {
    bottom: var(--space-md);
    left: var(--content-padding);
    right: var(--content-padding);
    transform: none;
  }
}

@media (max-width: 375px) {
  .page-header__nav {
    gap: var(--space-sm);
  }

  .page-header__nav a {
    font-size: var(--text-xs);
  }

  .zone-nav {
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-md);
  }

  .zone-nav a {
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--text-xs);
  }
}

/* ── Main-content stacking (Layer 1 / Task 5) ────────────────
   The .ambient-bg uses position: fixed with z-index: 0, creating
   its own stacking context. Positioned elements with z-index 0
   paint above non-positioned in-flow content, so we must bump
   main content into its own positioned stacking layer above it. */
#main-content {
  position: relative;
  z-index: 1;
}
