/* =========================================================
   Trail Running dashboard — its own identity:
   deep forest-navy + vibrant trail orange / moss / teal / violet.
   Distinct from the parent site's navy-and-lime portfolio theme.
   ========================================================= */

:root {
    --bg-0: #07120f;          /* deepest pine */
    --bg-1: #0a1a1c;          /* forest navy */
    --ink: #eaf4ee;           /* near-white text */
    --muted: #8ea7a0;         /* muted sage */
    --line: rgba(255, 255, 255, 0.09);
    --glass: rgba(255, 255, 255, 0.045);
    --glass-2: rgba(255, 255, 255, 0.07);

    --orange: #ff7a1a;
    --moss: #9ae600;
    --teal: #19c3b1;
    --violet: #8b6cff;
    --coral: #ff5d73;
    --gold: #ffd23f;

    --radius: 20px;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--ink);
    background: var(--bg-0);
    line-height: 1.55;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ---------- Backdrop ---------- */
.backdrop { position: fixed; inset: 0; z-index: -2; background:
    radial-gradient(1200px 700px at 15% -10%, #11362f 0%, transparent 60%),
    radial-gradient(1000px 600px at 100% 0%, #1a2440 0%, transparent 55%),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-0) 70%);
}
.aurora {
    position: absolute; inset: 0;
    background:
        radial-gradient(600px 300px at 80% 12%, rgba(255,122,26,0.16), transparent 70%),
        radial-gradient(500px 280px at 12% 22%, rgba(25,195,177,0.14), transparent 70%),
        radial-gradient(520px 300px at 50% 4%, rgba(139,108,255,0.12), transparent 70%);
    filter: blur(8px);
    animation: drift 18s ease-in-out infinite alternate;
}
@keyframes drift { from { transform: translateY(-10px); } to { transform: translateY(14px); } }

.ridge { position: absolute; bottom: 0; left: 0; width: 100%; height: 42vh; min-height: 280px; }
.ridge-back  { fill: #0e2a2b; opacity: 0.7; }
.ridge-mid   { fill: #0c2122; opacity: 0.85; }
.ridge-front { fill: #081a18; }

/* ---------- Top bar ---------- */
.topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    max-width: 1100px; margin: 0 auto; padding: 22px 24px;
}
.wordmark {
    font-family: 'Sora', sans-serif; font-weight: 800; font-size: 1.4rem;
    letter-spacing: 0.02em; color: var(--ink); text-decoration: none;
    display: inline-flex; align-items: center; gap: 10px;
}
.beta-pill {
    font-family: 'Inter', sans-serif; font-weight: 600; font-size: 0.66rem;
    letter-spacing: 0.06em; text-transform: uppercase; color: var(--gold);
    border: 1px solid rgba(255,210,63,0.45); border-radius: 999px;
    padding: 3px 9px; background: rgba(255,210,63,0.08);
}
.back-link {
    color: var(--muted); text-decoration: none; font-weight: 500; font-size: 0.95rem;
    padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px;
    transition: all 0.2s ease;
}
.back-link:hover { color: var(--ink); border-color: var(--orange); background: var(--glass); }
.topbar-right { display: flex; align-items: center; gap: 9px; font-size: 0.85rem; color: var(--muted); }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 0 rgba(154,230,0,0.5); }
.live-dot.ok { background: var(--moss); animation: pulse 2s infinite; }
.live-dot.err { background: var(--coral); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(154,230,0,0.5);} 70% { box-shadow: 0 0 0 8px rgba(154,230,0,0);} 100% { box-shadow: 0 0 0 0 rgba(154,230,0,0);} }

/* ---------- Layout ---------- */
.wrap { max-width: 1100px; margin: 0 auto; padding: 10px 24px 60px; }

/* ---------- Hero ---------- */
.hero {
    display: grid; grid-template-columns: 1.3fr 0.9fr; gap: 40px; align-items: center;
    padding: 30px 0 50px;
}
.eyebrow { color: var(--orange); font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; font-size: 0.8rem; margin-bottom: 14px; }
.eyebrow-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
/* Year dropdown — minimal, orange to match the eyebrow */
.year-select {
    color: var(--orange); background: transparent; border: 1px solid rgba(255,122,26,0.5);
    border-radius: 8px; padding: 3px 8px; font-family: inherit; font-weight: 700;
    letter-spacing: 0.06em; font-size: 0.8rem; cursor: pointer;
}
.year-select:focus { outline: none; border-color: var(--orange); }
.year-select option { background: var(--bg-1); color: var(--ink); letter-spacing: normal; }
/* Km / Mi segmented toggle */
.unit-toggle { display: inline-flex; border: 1px solid rgba(255,122,26,0.5); border-radius: 999px; overflow: hidden; }
.unit-toggle button {
    background: transparent; color: rgba(255,122,26,0.7); border: none; cursor: pointer;
    font-family: inherit; font-weight: 700; font-size: 0.75rem; letter-spacing: 0.06em;
    padding: 4px 12px; transition: background 0.2s ease, color 0.2s ease;
}
.unit-toggle button.active { background: var(--orange); color: #1a1205; }

.hero h1 { font-family: 'Sora', sans-serif; font-weight: 800; font-size: clamp(2.4rem, 5vw, 3.6rem); line-height: 1.05; letter-spacing: -0.02em; }
.grad { background: linear-gradient(100deg, var(--orange), var(--gold) 45%, var(--moss)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.hero-sub { color: var(--muted); font-size: 1.05rem; max-width: 30rem; margin: 18px 0 24px; }
.hero-sub strong { color: var(--ink); }
.hero-pills { display: flex; gap: 12px; flex-wrap: wrap; }
.pill { background: var(--glass); border: 1px solid var(--line); border-radius: 999px; padding: 8px 16px; font-size: 0.9rem; color: var(--muted); }
.pill-num { color: var(--ink); font-weight: 700; font-family: 'Sora', sans-serif; }

/* ---------- Goal ring ---------- */
.ring-card {
    position: relative; display: grid; place-items: center;
    background: var(--glass); border: 1px solid var(--line); border-radius: 28px;
    padding: 26px; box-shadow: var(--shadow); backdrop-filter: blur(12px);
}
.ring { width: 100%; max-width: 260px; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: rgba(255,255,255,0.08); stroke-width: 14; }
.ring-progress {
    fill: none; stroke: url(#ringGrad); stroke-width: 14; stroke-linecap: round;
    stroke-dasharray: 603; stroke-dashoffset: 603;
    transition: stroke-dashoffset 1.6s cubic-bezier(0.22, 1, 0.36, 1);
    filter: drop-shadow(0 0 6px rgba(255,122,26,0.4));
}
.ring-center { position: absolute; text-align: center; }
.ring-pct { font-family: 'Sora', sans-serif; font-weight: 800; font-size: 2.8rem; line-height: 1; background: linear-gradient(100deg, var(--orange), var(--moss)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.ring-km { color: var(--ink); font-weight: 600; margin-top: 6px; }
.ring-tag { color: var(--muted); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.1em; margin-top: 2px; }

/* ---------- Stat cards ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 26px; }
.stat {
    position: relative; overflow: hidden;
    background: var(--glass); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 22px 20px; transition: transform 0.2s ease, border-color 0.2s ease;
}
.stat::before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 3px; background: var(--accent); opacity: 0.9; }
.stat::after { content: ''; position: absolute; top: -40px; right: -40px; width: 120px; height: 120px; border-radius: 50%; background: var(--accent); opacity: 0.10; filter: blur(8px); }
.stat:hover { transform: translateY(-4px); border-color: var(--accent); }
.stat-label { color: var(--muted); font-size: 0.85rem; font-weight: 500; margin-bottom: 10px; }
.stat-num { font-family: 'Sora', sans-serif; font-weight: 800; font-size: 2.1rem; line-height: 1; letter-spacing: -0.02em; }
.stat-num .unit { font-size: 0.95rem; font-weight: 600; color: var(--muted); margin-left: 5px; }
.stat-foot { color: var(--muted); font-size: 0.8rem; margin-top: 10px; }
.stat-foot.good { color: var(--moss); }
.stat-foot.warn { color: var(--gold); }

/* ---------- Panels ---------- */
.panel { background: var(--glass); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; margin-bottom: 22px; backdrop-filter: blur(10px); }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 18px; gap: 12px; }
.panel-head h2 { font-family: 'Sora', sans-serif; font-weight: 700; font-size: 1.25rem; }
.panel-sub { color: var(--muted); font-size: 0.85rem; }
.chart-box { position: relative; height: 300px; }

/* stats explorer dropdown */
.stat-select {
    background: var(--glass-2); color: var(--ink); border: 1px solid var(--line);
    border-radius: 10px; padding: 9px 14px; font-family: inherit; font-size: 0.9rem;
    cursor: pointer; max-width: 100%;
}
.stat-select:focus { outline: none; border-color: var(--orange); }
.stat-select option { background: var(--bg-1); color: var(--ink); }
.stat-caption { color: var(--muted); font-size: 0.85rem; margin: -6px 0 14px; min-height: 1.1em; }

/* ---------- Runs list ---------- */
.runs { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.run {
    border: 1px solid var(--line); border-radius: 14px; background: var(--glass-2);
    overflow: hidden; transition: border-color 0.2s ease;
}
.run:hover { border-color: var(--orange); }
.run-head {
    display: grid; grid-template-columns: auto 1fr auto auto auto; gap: 14px; align-items: center;
    width: 100%; padding: 14px 16px; background: none; border: none; cursor: pointer;
    font-family: inherit; color: var(--ink); text-align: left;
}
.run-badge { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; font-size: 1.1rem; background: rgba(255,122,26,0.14); }
.run-badge.trail { background: rgba(154,230,0,0.14); }
.run-badge.indoor { background: rgba(139,108,255,0.14); }
.run-main .run-name { font-weight: 600; }
.run-main .run-date { color: var(--muted); font-size: 0.82rem; }
.run-dist { font-family: 'Sora', sans-serif; font-weight: 700; font-size: 1.1rem; text-align: right; }
.run-dist span { color: var(--muted); font-size: 0.75rem; font-weight: 500; }
.run-pace { color: var(--teal); font-weight: 600; font-size: 0.92rem; text-align: right; }
.run-chev { color: var(--muted); transition: transform 0.25s ease; font-size: 0.85rem; }
.run.open .run-chev { transform: rotate(180deg); color: var(--orange); }
.run-empty { color: var(--muted); text-align: center; padding: 20px; }

/* expandable detail — height driven by JS so it never clips */
.run-detail { max-height: 0; overflow: hidden; transition: max-height 0.32s ease; }
.run-detail-inner { padding: 2px 16px 16px; }
.run-detail-date { color: var(--muted); font-size: 0.8rem; margin: 10px 0 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 14px 16px; }
.ds { display: flex; flex-direction: column; gap: 3px; }
.ds-l { color: var(--muted); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; }
.ds-v { font-family: 'Sora', sans-serif; font-weight: 700; font-size: 1.02rem; }
/* route map */
.run-map { height: 240px; margin-top: 14px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--bg-1); }
.run-map .leaflet-container { background: var(--bg-1); font-family: inherit; }
.run-map .leaflet-control-attribution { background: rgba(0,0,0,0.5); color: var(--muted); }
.run-map .leaflet-control-attribution a { color: var(--teal); }

/* ---------- Coach / chat ---------- */
.chat { display: flex; flex-direction: column; gap: 14px; max-height: 460px; overflow-y: auto; padding: 4px 2px 8px; }
.msg { display: flex; gap: 12px; align-items: flex-start; }
.msg-avatar { width: 34px; height: 34px; flex: 0 0 34px; border-radius: 10px; display: grid; place-items: center; font-size: 1.05rem; background: rgba(255,122,26,0.16); }
.msg-body { background: var(--glass-2); border: 1px solid var(--line); border-radius: 14px; padding: 12px 15px; line-height: 1.6; max-width: 80%; }
.user-msg { flex-direction: row-reverse; }
.user-msg .msg-avatar { background: rgba(25,195,177,0.18); }
.user-msg .msg-body { background: rgba(25,195,177,0.10); border-color: rgba(25,195,177,0.25); }
/* lightweight markdown rendering */
.msg-body h2, .msg-body h3 { font-family: 'Sora', sans-serif; font-size: 1.02rem; margin: 10px 0 6px; }
.msg-body p { margin: 8px 0; }
.msg-body ul { margin: 8px 0 8px 18px; }
.msg-body li { margin: 3px 0; }
.msg-body strong { color: var(--ink); }
.msg-body table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 0.9rem; }
.msg-body th, .msg-body td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--line); }
.msg-body th { color: var(--orange); font-weight: 600; }
.msg-body code { background: rgba(255,255,255,0.08); padding: 1px 5px; border-radius: 5px; font-size: 0.88em; }
.typing { color: var(--muted); font-style: italic; }
.typing span { animation: blink 1.4s infinite both; }
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.2; } 40% { opacity: 1; } }

.suggestions { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 14px; }
.chip { background: var(--glass); border: 1px solid var(--line); color: var(--muted); border-radius: 999px; padding: 7px 14px; font-size: 0.85rem; cursor: pointer; transition: all 0.2s ease; font-family: inherit; }
.chip:hover { color: var(--ink); border-color: var(--orange); background: rgba(255,122,26,0.1); }

.chat-input { display: flex; gap: 10px; }
.chat-input input { flex: 1; background: var(--glass-2); border: 1px solid var(--line); border-radius: 12px; padding: 13px 16px; color: var(--ink); font-family: inherit; font-size: 0.95rem; }
.chat-input input:focus { outline: none; border-color: var(--orange); }
.chat-input button { background: linear-gradient(100deg, var(--orange), var(--gold)); color: #1a1205; border: none; border-radius: 12px; padding: 0 22px; font-weight: 700; font-family: 'Sora', sans-serif; cursor: pointer; transition: transform 0.15s ease, opacity 0.2s ease; }
.chat-input button:hover { transform: translateY(-1px); }
.chat-input button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* ---------- Footer ---------- */
.foot { text-align: center; color: var(--muted); font-size: 0.85rem; padding: 30px 24px 50px; }
.foot a { color: var(--orange); text-decoration: none; }
.foot a:hover { text-decoration: underline; }

/* ---------- States ---------- */
.is-error .ring-pct { color: var(--coral); -webkit-text-fill-color: var(--coral); }

/* ---------- Responsive ---------- */
@media (max-width: 880px) {
    .hero { grid-template-columns: 1fr; gap: 30px; }
    .ring-card { max-width: 320px; margin: 0 auto; }
    .stats { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
    .stats { grid-template-columns: 1fr 1fr; gap: 12px; }
    .run { grid-template-columns: auto 1fr auto; }
    .run-pace { display: none; }
    .wrap { padding: 10px 16px 50px; }
}

/* ---- Beta-access gate ---- */
.tg-locked { overflow: hidden; }
.tg-has-key .beta-gate { display: none; }   /* optimistic hide for returning testers */
.beta-gate {
    position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center;
    padding: 24px; background:
        radial-gradient(900px 500px at 70% -10%, rgba(25,195,177,0.10), transparent 60%),
        radial-gradient(700px 400px at 10% 10%, rgba(255,122,26,0.09), transparent 55%),
        linear-gradient(180deg, var(--bg-0), var(--bg-1));
    -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
.beta-card {
    width: 100%; max-width: 430px; background: var(--glass); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 32px 28px; box-shadow: var(--shadow); text-align: center;
}
.beta-badge {
    display: inline-block; font-family: 'Inter', sans-serif; font-weight: 700; font-size: 0.7rem;
    letter-spacing: 0.06em; text-transform: uppercase; color: var(--gold);
    border: 1px solid rgba(255,210,63,0.45); border-radius: 999px; padding: 4px 12px;
    background: rgba(255,210,63,0.08); margin-bottom: 18px;
}
.beta-title { font-family: 'Sora', sans-serif; font-weight: 800; font-size: 1.7rem; letter-spacing: -0.02em; }
.beta-sub { color: var(--muted); margin-top: 12px; font-size: 0.98rem; line-height: 1.5; }
.beta-form { display: flex; gap: 9px; margin-top: 22px; }
.beta-form input {
    flex: 1; background: var(--glass-2); color: var(--ink); border: 1px solid var(--line);
    border-radius: 999px; padding: 12px 18px; font-family: inherit; font-size: 1rem;
}
.beta-form input:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(255,122,26,0.15); }
.beta-form button {
    background: var(--orange); color: #1a1205; border: none; border-radius: 999px; padding: 0 22px;
    font-family: 'Sora', sans-serif; font-weight: 700; font-size: 0.95rem; cursor: pointer;
    transition: filter 0.18s ease; white-space: nowrap;
}
.beta-form button:hover { filter: brightness(1.08); }
.beta-form button:disabled { opacity: 0.6; cursor: default; }
.beta-error { color: var(--coral); font-size: 0.9rem; font-weight: 600; margin-top: 14px; }
.beta-foot { color: var(--muted); font-size: 0.86rem; margin-top: 22px; }
.beta-foot a { color: var(--orange); text-decoration: none; }
.beta-foot a:hover { text-decoration: underline; }
@media (max-width: 480px) {
    .beta-form { flex-direction: column; }
    .beta-form button { padding: 12px 22px; }
}
