/* =============================================================
   RaceTales Design System
   main.css — shared tokens, typography, layout, components
   ============================================================= */

/* ── Custom Properties ─────────────────────────────────────── */
:root {
  /* Color palette */
  --bg:          #0a0a0b;
  --bg-card:     #16161b;
  --bg-elevated: #1e1e26;
  --bg-overlay:  rgba(10, 10, 11, 0.92);

  --text:        #f0ede8;
  --text-muted:  #9d9890;
  --text-dim:    #5c5855;

  --gold:        #c9a96e;
  --gold-hover:  #dfc28a;
  --border:      rgba(255, 255, 255, 0.08);
  --border-hover:rgba(255, 255, 255, 0.18);

  /* Adventure accent colors */
  --canyon:         #d4845a;
  --canyon-dim:     rgba(212, 132, 90, 0.15);
  --chamonix:       #7aadca;
  --chamonix-dim:   rgba(122, 173, 202, 0.15);
  --sanjuans:       #7faa6c;
  --sanjuans-dim:   rgba(127, 170, 108, 0.15);
  --bloodroot:        #b85968;
  --bloodroot-dim:    rgba(184, 89, 104, 0.15);
  --switzerland:      #7b9eb5;
  --switzerland-dim:  rgba(123, 158, 181, 0.15);

  /* Typography */
  --font-serif:  'Playfair Display', Georgia, 'Times New Roman', serif;
  --font-sans:   'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --size-xs:     0.75rem;
  --size-sm:     0.875rem;
  --size-base:   1rem;
  --size-lg:     1.125rem;
  --size-xl:     1.25rem;
  --size-2xl:    1.5rem;
  --size-3xl:    1.875rem;
  --size-4xl:    2.25rem;
  --size-5xl:    3rem;
  --size-6xl:    4rem;

  /* Spacing */
  --space-1:     0.25rem;
  --space-2:     0.5rem;
  --space-3:     0.75rem;
  --space-4:     1rem;
  --space-5:     1.25rem;
  --space-6:     1.5rem;
  --space-8:     2rem;
  --space-10:    2.5rem;
  --space-12:    3rem;
  --space-16:    4rem;
  --space-20:    5rem;
  --space-24:    6rem;

  /* Layout */
  --container:   1200px;
  --nav-height:  64px;

  /* Borders */
  --radius-sm:   4px;
  --radius:      8px;
  --radius-lg:   12px;
  --radius-xl:   16px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm:   0 1px 3px rgba(0,0,0,0.4);
  --shadow:      0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:   0 8px 32px rgba(0,0,0,0.6);
  --shadow-xl:   0 16px 64px rgba(0,0,0,0.7);

  /* Transitions */
  --ease:        cubic-bezier(0.4, 0, 0.2, 1);
  --duration:    200ms;
  --duration-slow: 400ms;
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--size-base);
  line-height: 1.6;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, video {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

ul, ol {
  list-style: none;
}

/* ── Typography ─────────────────────────────────────────────── */
h1, h2, h3 {
  font-family: var(--font-serif);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

h4, h5, h6 {
  font-family: var(--font-sans);
  font-weight: 600;
  line-height: 1.3;
}

.label {
  font-size: var(--size-xs);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ── Layout Utilities ───────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--space-6);
}

@media (min-width: 768px) {
  .container {
    padding: 0 var(--space-8);
  }
}

@media (min-width: 1024px) {
  .container {
    padding: 0 var(--space-12);
  }
}

/* ── Login Gate ─────────────────────────────────────────────── */
#login-gate {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: var(--space-8);
  transition: opacity var(--duration-slow) var(--ease);
}

#login-gate.hidden {
  opacity: 0;
  pointer-events: none;
}

.gate-inner {
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.gate-logo {
  font-family: var(--font-serif);
  font-size: var(--size-4xl);
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  margin-bottom: var(--space-2);
}

.gate-logo span {
  color: var(--gold);
}

.gate-tagline {
  font-size: var(--size-sm);
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: var(--space-12);
}

.gate-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.gate-input-wrap {
  position: relative;
}

.gate-input {
  width: 100%;
  padding: var(--space-4) var(--space-5);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--size-base);
  text-align: center;
  letter-spacing: 0.15em;
  outline: none;
  transition: border-color var(--duration) var(--ease);
}

.gate-input::placeholder {
  color: var(--text-dim);
  letter-spacing: 0.08em;
}

.gate-input:focus {
  border-color: var(--gold);
}

.gate-input.error {
  border-color: #e05c5c;
  animation: shake 0.4s var(--ease);
}

.gate-btn {
  padding: var(--space-4) var(--space-6);
  background: var(--gold);
  color: var(--bg);
  font-family: var(--font-sans);
  font-size: var(--size-sm);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-radius: var(--radius);
  transition: background var(--duration) var(--ease), transform var(--duration) var(--ease);
}

.gate-btn:hover {
  background: var(--gold-hover);
  transform: translateY(-1px);
}

.gate-btn:active {
  transform: translateY(0);
}

.gate-error {
  font-size: var(--size-sm);
  color: #e05c5c;
  min-height: 1.4em;
  transition: opacity var(--duration) var(--ease);
}

.gate-grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-size: 200px;
}

/* ── Navigation ─────────────────────────────────────────────── */
#nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--nav-height);
  background: rgba(10, 10, 11, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  transition: background var(--duration) var(--ease);
}

.nav-inner {
  height: 100%;
  display: flex;
  align-items: center;
}

.nav-logo {
  font-family: var(--font-serif);
  font-size: var(--size-xl);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  flex-shrink: 0;
}

.nav-logo span {
  color: var(--gold);
}

/* ── Hero ───────────────────────────────────────────────────── */
#hero {
  padding-top: var(--nav-height);
  min-height: 60vh;
  display: flex;
  align-items: center;
  position: relative;
  overflow: hidden;
  background: linear-gradient(
    to bottom,
    rgba(10,10,11,0) 0%,
    var(--bg) 100%
  ), var(--bg);
}

.hero-content {
  padding: var(--space-16) 0 var(--space-12);
  position: relative;
  z-index: 1;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--size-xs);
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: var(--space-5);
}

.hero-eyebrow::before {
  content: '';
  display: inline-block;
  width: 24px;
  height: 1px;
  background: var(--gold);
}

.hero-title {
  font-size: clamp(var(--size-4xl), 8vw, var(--size-6xl));
  color: var(--text);
  max-width: 14ch;
  margin-bottom: var(--space-6);
}

.hero-title em {
  font-style: italic;
  color: var(--gold);
}

.hero-desc {
  font-size: var(--size-lg);
  color: var(--text-muted);
  max-width: 48ch;
  line-height: 1.7;
  margin-bottom: var(--space-10);
}

.hero-scroll-hint {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--size-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  animation: scroll-fade 2s var(--ease) infinite;
}

.hero-scroll-hint::after {
  content: '';
  display: inline-block;
  width: 1px;
  height: 40px;
  background: linear-gradient(to bottom, var(--text-dim), transparent);
}

/* ── Section headers ────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: var(--space-8);
  gap: var(--space-4);
}

.section-eyebrow {
  font-size: var(--size-xs);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: var(--space-2);
}

.section-title {
  font-family: var(--font-serif);
  font-size: clamp(var(--size-2xl), 4vw, var(--size-4xl));
  color: var(--text);
  line-height: 1.2;
}

/* ── Calendar ───────────────────────────────────────────────── */
#calendar-section {
  padding: var(--space-20) 0;
  border-top: 1px solid var(--border);
}

.calendar-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
}

.cal-nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: color var(--duration) var(--ease), background var(--duration) var(--ease);
}

.cal-nav-btn:hover {
  color: var(--text);
  background: var(--border);
}

.cal-month-label {
  font-family: var(--font-serif);
  font-size: var(--size-xl);
  font-weight: 600;
  color: var(--text);
}

.calendar-days-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
}

.calendar-days-header span {
  padding: var(--space-3) var(--space-2);
  text-align: center;
  font-size: var(--size-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.cal-day {
  position: relative;
  min-height: 80px;
  padding: var(--space-2);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  transition: background var(--duration) var(--ease);
}

.cal-day:nth-child(7n) {
  border-right: none;
}

.cal-day.empty {
  background: rgba(0,0,0,0.2);
}

.cal-day.today .cal-day-num {
  background: var(--gold);
  color: var(--bg);
  border-radius: var(--radius-full);
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.cal-day-num {
  font-size: var(--size-sm);
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cal-day.other-month .cal-day-num {
  color: var(--text-dim);
}

.cal-event {
  margin-top: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity var(--duration) var(--ease), transform var(--duration) var(--ease);
}

.cal-event:hover {
  opacity: 0.85;
  transform: translateY(-1px);
}

.cal-event.canyon   { background: var(--canyon);   color: var(--bg); }
.cal-event.chamonix { background: var(--chamonix); color: var(--bg); }
.cal-event.sanjuans { background: var(--sanjuans); color: var(--bg); }
.cal-event.future   { opacity: 0.6; font-style: italic; }

/* Mobile: tighter cells */
@media (max-width: 480px) {
  .cal-day {
    min-height: 52px;
    padding: var(--space-1);
  }

  .cal-event {
    font-size: 9px;
    padding: 1px 3px;
  }

  .calendar-days-header span {
    font-size: 10px;
    padding: var(--space-2) var(--space-1);
  }
}

/* ── Adventure Preview Overlay ──────────────────────────────── */
#adventure-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-slow) var(--ease);
}

#adventure-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.overlay-card {
  position: relative;
  z-index: 1;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  max-width: 480px;
  width: 100%;
  transform: translateY(16px) scale(0.97);
  transition: transform var(--duration-slow) var(--ease);
}

#adventure-overlay.visible .overlay-card {
  transform: translateY(0) scale(1);
}

.overlay-close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  color: var(--text-muted);
  transition: color var(--duration) var(--ease), background var(--duration) var(--ease);
}

.overlay-close:hover {
  color: var(--text);
  background: var(--border);
}

.overlay-accent {
  width: 40px;
  height: 3px;
  border-radius: var(--radius-full);
  margin-bottom: var(--space-5);
}

.overlay-label {
  font-size: var(--size-xs);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

.overlay-title {
  font-family: var(--font-serif);
  font-size: var(--size-2xl);
  color: var(--text);
  margin-bottom: var(--space-3);
  line-height: 1.25;
}

.overlay-meta {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}

.overlay-meta-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--size-sm);
  color: var(--text-muted);
}

.overlay-desc {
  font-size: var(--size-sm);
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: var(--space-6);
}

.overlay-coming-soon {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: var(--size-xs);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.overlay-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  background: var(--gold);
  color: var(--bg);
  font-family: var(--font-sans);
  font-size: var(--size-sm);
  font-weight: 600;
  letter-spacing: 0.06em;
  border-radius: var(--radius);
  transition: background var(--duration) var(--ease), transform var(--duration) var(--ease);
}

.overlay-btn:hover {
  background: var(--gold-hover);
  transform: translateY(-1px);
}

/* ── Adventure Cards Grid ───────────────────────────────────── */
#adventures-section {
  padding: var(--space-20) 0;
  border-top: 1px solid var(--border);
}

.adventures-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-6);
}

@media (min-width: 640px) {
  .adventures-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .adventures-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.adventure-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color var(--duration) var(--ease), transform var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
  position: relative;
}

.adventure-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-4px);
  box-shadow: var(--shadow-xl);
}

.adventure-card-thumb {
  width: 100%;
  height: 220px;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.adventure-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 600ms var(--ease);
}

.adventure-card:hover .adventure-card-thumb img {
  transform: scale(1.05);
}

.adventure-card-thumb-gradient {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
}

.adventure-card-thumb-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60%;
  background: linear-gradient(to top, var(--bg-card), transparent);
}

.adventure-card-body {
  padding: var(--space-5) var(--space-6);
  flex: 1;
  display: flex;
  flex-direction: column;
}

.adventure-card-year {
  font-size: var(--size-xs);
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: var(--space-2);
}

.adventure-card-title {
  font-family: var(--font-serif);
  font-size: var(--size-xl);
  color: var(--text);
  margin-bottom: var(--space-2);
  line-height: 1.3;
}

.adventure-card-location {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--size-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-4);
}

.adventure-card-desc {
  font-size: var(--size-sm);
  color: var(--text-muted);
  line-height: 1.65;
  flex: 1;
  margin-bottom: var(--space-5);
}

.adventure-card-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--size-sm);
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: var(--space-2) 0;
  border-bottom: 1px solid transparent;
  transition: border-color var(--duration) var(--ease);
  align-self: flex-start;
}

.adventure-card-link:hover {
  border-bottom-color: currentColor;
}

.adventure-card-link svg {
  transition: transform var(--duration) var(--ease);
}

.adventure-card-link:hover svg {
  transform: translateX(3px);
}

/* Per-adventure accent theming */
.adventure-card.canyon  .adventure-card-year,
.adventure-card.canyon  .adventure-card-link { color: var(--canyon); }
.adventure-card.chamonix .adventure-card-year,
.adventure-card.chamonix .adventure-card-link { color: var(--chamonix); }
.adventure-card.sanjuans .adventure-card-year,
.adventure-card.sanjuans .adventure-card-link { color: var(--sanjuans); }
.adventure-card.bloodroot .adventure-card-year,
.adventure-card.bloodroot .adventure-card-link { color: var(--bloodroot); }
.adventure-card.switzerland .adventure-card-year,
.adventure-card.switzerland .adventure-card-link { color: var(--switzerland); }

.adventure-card.canyon       { --card-accent: var(--canyon-dim); }
.adventure-card.chamonix     { --card-accent: var(--chamonix-dim); }
.adventure-card.sanjuans     { --card-accent: var(--sanjuans-dim); }
.adventure-card.bloodroot    { --card-accent: var(--bloodroot-dim); }
.adventure-card.switzerland  { --card-accent: var(--switzerland-dim); }

.adventure-card::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  opacity: 0;
  background: var(--card-accent);
  pointer-events: none;
  transition: opacity var(--duration) var(--ease);
}

.adventure-card:hover::after {
  opacity: 1;
}

/* ── Footer ─────────────────────────────────────────────────── */
#footer {
  padding: var(--space-12) 0;
  border-top: 1px solid var(--border);
  margin-top: var(--space-8);
}

.footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  text-align: center;
}

.footer-logo {
  font-family: var(--font-serif);
  font-size: var(--size-lg);
  font-weight: 700;
  color: var(--text);
}

.footer-logo span {
  color: var(--gold);
}

.footer-tagline {
  font-size: var(--size-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* ── Animations ─────────────────────────────────────────────── */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-8px); }
  40%       { transform: translateX(8px); }
  60%       { transform: translateX(-5px); }
  80%       { transform: translateX(5px); }
}

@keyframes scroll-fade {
  0%, 100% { opacity: 0.4; }
  50%       { opacity: 0.9; }
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-up {
  opacity: 0;
  animation: fade-up 0.7s var(--ease) forwards;
}

.fade-up:nth-child(1) { animation-delay: 0.1s; }
.fade-up:nth-child(2) { animation-delay: 0.2s; }
.fade-up:nth-child(3) { animation-delay: 0.3s; }

/* Intersection Observer reveal */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-elevated);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

/* ── Selection ──────────────────────────────────────────────── */
::selection {
  background: rgba(201, 169, 110, 0.3);
  color: var(--text);
}
