:root {
  --bg: #0b0d10;
  --surface: #15181d;
  --border: #262a31;
  --text: #f4f4f2;
  --muted: #9aa0a8;
  --accent: #ffe11a;
  --accent-ink: #0b0d10;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, sans-serif;
  line-height: 1.5;
}

.container { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 20px; }
.muted { color: var(--muted); }

.hero {
  padding: 64px 0 48px;
  background: radial-gradient(ellipse at 80% 0%, #1c2026 0%, var(--bg) 70%);
}
.kicker {
  display: inline-block; background: var(--accent); color: var(--accent-ink);
  font-weight: 800; font-size: 13px; letter-spacing: 3px; text-transform: uppercase;
  padding: 6px 12px; border-radius: 4px;
}
h1 { font-size: clamp(56px, 12vw, 104px); font-weight: 900; letter-spacing: -3px; line-height: 1; margin: 18px 0 0; }
h1 span { color: var(--accent); }
.lede { font-size: 20px; color: #c9ccd1; max-width: 620px; margin: 18px 0 0; }

.steps { list-style: none; counter-reset: step; padding: 0; margin: 32px 0 0; display: grid; gap: 14px; max-width: 680px; }
.steps li { counter-increment: step; display: flex; gap: 14px; color: #c9ccd1; }
.steps li::before {
  content: counter(step); flex: none; width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid var(--accent); color: var(--accent); font-weight: 800;
  display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.steps b { color: var(--text); }

h2 { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; margin: 0; }
section { padding: 40px 0; }
.section-head { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; margin-bottom: 20px; }

input {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; font: inherit; width: 100%;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
#search { max-width: 280px; }

.courses { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 20px; }
.card.past { opacity: 0.6; }
.card h3 { margin: 0; font-size: 22px; font-weight: 800; }
.card .meta { color: var(--muted); font-size: 14px; margin-top: 2px; }
.code-row { display: flex; align-items: center; gap: 10px; margin: 16px 0; }
.code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 22px; font-weight: 700;
  letter-spacing: 2px; color: var(--accent); background: #0f1114; border: 1px dashed #3a3f47;
  border-radius: 8px; padding: 6px 12px;
}
.card table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.card th { text-align: left; color: var(--muted); font-weight: 600; padding: 4px 0; }
.card td { padding: 4px 0; border-top: 1px solid var(--border); }
.card td:not(:first-child), .card th:not(:first-child) { text-align: right; }
.card .rule { font-size: 13px; color: var(--muted); margin: 12px 0 0; }

button {
  font: inherit; font-weight: 700; border-radius: 8px; padding: 10px 16px; cursor: pointer;
  background: transparent; color: var(--text); border: 1px solid #3a3f47;
}
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.copy { padding: 6px 12px; font-size: 14px; }

.toggle { display: inline-flex; gap: 8px; align-items: center; margin-top: 18px; color: var(--muted); font-size: 14px; }
.toggle input { width: auto; }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.runs-grid { display: grid; grid-template-columns: 90px 1fr 1fr; gap: 8px 12px; align-items: center; }
.col-head { font-size: 13px; color: var(--muted); font-weight: 600; }
.run-name { font-weight: 700; font-size: 14px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }

footer { padding: 32px 20px 48px; font-size: 13px; border-top: 1px solid var(--border); }

@media (max-width: 520px) {
  .row { grid-template-columns: 1fr; }
  #search { max-width: none; }
}

/* Course tool */
.tool { padding-top: 48px; padding-bottom: 48px; }
.tool-title { font-size: 36px; margin-top: 16px; }
.tool-form { display: grid; gap: 16px; max-width: 720px; margin-top: 24px; }
.tool label, .output-label { display: grid; gap: 6px; font-size: 14px; font-weight: 600; color: #c9ccd1; }
textarea {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; font: inherit; width: 100%; resize: vertical;
}
#output { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; }
textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
fieldset { border: 1px solid var(--border); border-radius: 12px; padding: 16px; display: grid; gap: 12px; margin: 0; }
legend { font-weight: 800; padding: 0 6px; }
.runs-grid.three { grid-template-columns: repeat(3, 1fr); }
.small { font-size: 13px; margin: 0; }
code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.9em; color: var(--accent); }
.preview { max-width: 720px; margin: 24px 0; }
.preview-table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.preview-table th { text-align: left; color: var(--muted); font-weight: 600; padding: 6px 8px 6px 0; }
.preview-table td { padding: 6px 8px 6px 0; border-top: 1px solid var(--border); }
.preview-table tr.mismatch td { color: #ff8a80; }
.notice { background: #2a1f0f; border: 1px solid #5c4415; border-radius: 10px; padding: 12px 14px; color: #f3d48b; font-size: 14px; }
.notice ul { margin: 6px 0; padding-left: 18px; }
.output-label { max-width: 720px; }
.button-link { color: var(--muted); align-self: center; font-size: 14px; }
.badge {
  display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: 0.5px;
  padding: 3px 8px; border-radius: 999px; margin-left: 8px; vertical-align: middle;
}
.badge.estimated { background: #2a1f0f; color: #f3d48b; border: 1px solid #5c4415; }
.badge.measured { background: #13261a; color: #8fe0a6; border: 1px solid #22553a; }

@media (max-width: 520px) {
  .runs-grid.three { grid-template-columns: 1fr; }
}

/* Map tracer */
.tool.wide { max-width: 1280px; }
.tracer { display: grid; grid-template-columns: 300px 1fr; gap: 24px; margin: 28px 0; align-items: start; }
.tool-steps { margin: 0; padding-left: 20px; display: grid; gap: 22px; }
.tool-steps li { display: grid; gap: 8px; }
.tool-steps li::marker { color: var(--accent); font-weight: 800; }
.inline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.inline button { padding: 7px 12px; font-size: 14px; }
button.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
label.compact { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
label.compact input { width: 90px; }
.map-area { min-width: 0; }
#map { width: 100%; height: auto; border: 1px solid var(--border); border-radius: 12px; cursor: crosshair; background: var(--surface); }
.mode-hint { margin: 0 0 10px; font-weight: 600; color: var(--accent); min-height: 1.5em; }

@media (max-width: 900px) {
  .tracer { grid-template-columns: 1fr; }
}

/* Card animations and course previews */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes march { to { stroke-dashoffset: -60; } }
.reveal { animation: rise 0.5s ease both; animation-delay: calc(var(--i, 0) * 70ms); }
.card { position: relative; cursor: pointer; transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease; }
.card:hover { transform: translateY(-4px); border-color: #3a3f47; box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35); }
.card:hover .flow { animation: march 1.2s linear infinite; }
.mini-map { position: absolute; top: 16px; right: 16px; width: 92px; height: 56px; opacity: 0.9; }
.card h3 { padding-right: 100px; }
.view-course { display: inline-block; margin-top: 14px; font-weight: 700; color: var(--accent); text-decoration: none; }
.view-course:hover { text-decoration: underline; }

/* Course page */
.course-page { padding-top: 32px; padding-bottom: 48px; }
.back { color: var(--muted); text-decoration: none; font-size: 15px; }
.course-head h1 { font-size: clamp(44px, 9vw, 72px); font-weight: 900; letter-spacing: -2px; margin: 14px 0 4px; }
.course-head .code-row { flex-wrap: wrap; }
.map-card { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 22px; margin: 28px 0; --i: 1; }
.map-top { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.run-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.run-picker button { width: 40px; height: 40px; padding: 0; border-radius: 10px; font-weight: 800; }
.run-picker button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.map-wrap { position: relative; margin-top: 16px; background: #0f1114; border-radius: 14px; border: 1px solid var(--border); }
#map { display: block; width: 100%; height: auto; max-height: 460px; }
.lap-flash {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%) scale(0.8); opacity: 0; pointer-events: none;
  background: var(--accent); color: var(--accent-ink); font-weight: 900; letter-spacing: 3px; padding: 8px 18px; border-radius: 999px;
}
@keyframes flash { 0% { opacity: 0; transform: translateX(-50%) scale(0.8); } 20% { opacity: 1; transform: translateX(-50%) scale(1.08); } 100% { opacity: 0; transform: translateX(-50%) scale(1); } }
.lap-flash.show { animation: flash 0.9s ease; }
.map-controls { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin-top: 14px; }
.map-status { margin: 0; font-weight: 600; color: #d7dade; }
.segments { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 8px; }
.segments li { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); color: var(--muted); font-size: 15px; transition: background 0.2s, color 0.2s; }
.segments li.done { color: #c9ccd1; }
.segments li.now { color: var(--text); border-color: var(--accent); background: #1d1b10; }
.segments b { color: inherit; }
.lap-pill { display: inline-block; background: var(--accent); color: var(--accent-ink); font-weight: 900; font-size: 12px; letter-spacing: 2px; padding: 2px 8px; border-radius: 999px; }
.lap-pill.out { background: #4fc3f7; }
.table-wrap { overflow-x: auto; }
.runs-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; margin-top: 12px; }
.runs-table th { text-align: left; color: var(--muted); font-weight: 600; padding: 8px 10px 8px 0; font-size: 14px; }
.runs-table td { padding: 10px 10px 10px 0; border-top: 1px solid var(--border); cursor: pointer; }
.runs-table tr.selected td { color: var(--accent); font-weight: 700; }

@media (prefers-reduced-motion: reduce) {
  .reveal, .card:hover .flow, .lap-flash.show { animation: none; }
  .card, .card:hover { transition: none; transform: none; }
}

/* Official course map */
.map-credit { margin: 8px 2px 0; font-size: 13px; color: var(--muted); }
.map-image { image-rendering: auto; }

/* Store button */
.button-primary {
  display: inline-block; margin-top: 24px; background: var(--accent); color: var(--accent-ink);
  font-weight: 800; padding: 12px 20px; border-radius: 10px; text-decoration: none;
}
.button-primary[hidden] { display: none; }

/* Buttons side by side: store + setup guide */
.button-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; align-items: center; }
.button-row .button-primary { margin-top: 0; }
.button-secondary {
  display: inline-block; color: var(--accent); font-weight: 800; padding: 11px 19px; border-radius: 10px;
  border: 1.5px solid var(--accent); text-decoration: none;
}

/* Hover and press animations (mouse and trackpad only; touch screens skip hover) */
.button-primary, .button-secondary, button {
  transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease,
              color 0.18s ease, border-color 0.18s ease, filter 0.18s ease;
}
.button-primary { position: relative; overflow: hidden; }
.button-primary::after {
  /* Light sweep across the button on hover */
  content: ""; position: absolute; top: 0; bottom: 0; left: -60%; width: 40%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  transform: skewX(-20deg); pointer-events: none; opacity: 0;
}
.button-secondary .arrow { display: inline-block; transition: transform 0.18s ease; }

@media (hover: hover) and (pointer: fine) {
  .button-primary:hover, button.primary:hover {
    transform: translateY(-2px); filter: brightness(1.04);
    box-shadow: 0 8px 22px rgba(255, 225, 26, 0.28), 0 2px 6px rgba(0, 0, 0, 0.4);
  }
  .button-primary:hover::after { opacity: 1; animation: sweep 0.7s ease forwards; }
  .button-secondary:hover {
    background: var(--accent); color: var(--accent-ink); transform: translateY(-2px);
    box-shadow: 0 8px 22px rgba(255, 225, 26, 0.22);
  }
  .button-secondary:hover .arrow { transform: translateX(4px); }
  button:not(.primary):not([aria-selected="true"]):not(.active):hover {
    border-color: var(--accent); color: var(--accent); transform: translateY(-1px);
  }
}
.button-primary:active, .button-secondary:active, button:active { transform: translateY(0) scale(0.97); box-shadow: none; }
.button-primary:focus-visible, .button-secondary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
@keyframes sweep { from { left: -60%; } to { left: 120%; } }

@media (prefers-reduced-motion: reduce) {
  .button-primary, .button-secondary, button, .button-secondary .arrow { transition: none; }
  .button-primary:hover, .button-secondary:hover, button:hover, .button-secondary:hover .arrow,
  .button-primary:active, .button-secondary:active, button:active { transform: none; }
  .button-primary:hover::after { animation: none; opacity: 0; }
}
