/* =====================================================
   Side Rail (Sidenav) + Horizontal Calendar Rail
   F1 Tracker — 2026-05-17
   ===================================================== */

/* --- Scoped tokens shared by both components --- */
/* Light theme (default) */
.sidenav,
.calendar-rail {
  --sn-bg:     #f5f2ec;
  --sn-paper:  #ede9e2;
  --sn-bg2:    #f0ece4;
  --sn-ink:    #1a1714;
  --sn-mute:   #766e65;
  --sn-line:   #d5d0c8;
  --sn-accent: #e10600;
  --sn-sprint: #6b3fd4;
  --sn-good:   #1a9657;
}

/* Dark theme override */
[data-theme="dark"] .sidenav,
[data-theme="dark"] .calendar-rail {
  --sn-bg:     #0e0b07;
  --sn-paper:  #1c1811;
  --sn-bg2:    #14110b;
  --sn-ink:    #f0ece2;
  --sn-mute:   #9d9387;
  --sn-line:   #2a2620;
  --sn-accent: #FF3A1F;
  --sn-sprint: #8b5cff;
  --sn-good:   #27c97a;
}

/* =====================================================
   App shell — grid switch at >=1280px
   ===================================================== */
.app-shell {
  display: block; /* mobile / tablet: top app bar remains, no grid */
}

@media (min-width: 1280px) {
  .app-shell.has-nav {
    display: grid;
    grid-template-columns: 260px 1fr;
    min-height: 100vh;
  }
  /* Hide the existing top app bar; the side rail replaces it. */
  .app-shell.has-nav > .top-app-bar { display: none; }
}

/* The side rail is hidden on small viewports. */
.sidenav { display: none; }

@media (min-width: 1280px) {
  .sidenav {
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    grid-column: 1;
    grid-row: 1 / -1;
    overflow-y: auto;
    background: var(--sn-bg);
    color: var(--sn-ink);
    border-right: 1px solid var(--sn-line);
    font-family: 'Inter', system-ui, sans-serif;
    z-index: 10;
  }
}

/* =====================================================
   Section 1 — Logo
   ===================================================== */
.sn-logo {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 24px 22px 22px;
  border-bottom: 1px solid var(--sn-line);
  text-decoration: none;
  color: var(--sn-ink);
}
.sn-logo-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--sn-accent);
  box-shadow: 0 0 14px var(--sn-accent);
  flex-shrink: 0;
}
.sn-logo-text {
  font-family: 'Fraunces', serif;
  font-weight: 400;
  font-size: 26px;
  letter-spacing: -0.02em;
  line-height: 1;
}
.sn-logo-text em {
  font-style: italic;
  font-weight: 300;
  color: var(--sn-accent);
  margin: 0 4px;
}

/* =====================================================
   Section 2 — Season progress
   ===================================================== */
.sn-progress {
  padding: 18px 22px;
  border-bottom: 1px solid var(--sn-line);
}
.sn-progress-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--sn-mute);
  margin: 0 0 8px;
}
.sn-progress-bar {
  height: 4px;
  background: var(--sn-line);
  border-radius: 2px;
  overflow: hidden;
}
.sn-progress-fill {
  height: 100%;
  background: var(--sn-accent);
  border-radius: 2px;
}
.sn-progress-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--sn-mute);
}

/* =====================================================
   Section 3 — Main nav
   ===================================================== */
.sn-nav {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 8px 0;
  scrollbar-gutter: stable; /* reserve scrollbar space always — prevents layout shift */
}
.sn-nav-group {
  display: block;
}
.sn-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 42px;
  padding: 0 22px;
  border-left: 2px solid transparent;
  color: var(--sn-mute);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  width: 100%;
  background: none;
  border-top: none;
  border-right: none;
  border-bottom: none;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
}
.sn-nav-chevron {
  margin-left: auto;
  font-size: 16px;
  line-height: 1;
  transition: transform 0.2s;
  display: inline-block;
}
.sn-nav-group.open .sn-nav-chevron {
  transform: rotate(90deg);
}
.sn-nav-item:hover {
  color: var(--sn-ink);
  background: var(--sn-paper);
}
/* Open group button matches hover state — makes expanded state clear */
.sn-nav-group.open > .sn-nav-group-btn {
  color: var(--sn-ink);
  background: var(--sn-paper);
}
.sn-nav-item.active {
  color: var(--sn-ink);
  background: var(--sn-paper);
  border-left-color: var(--sn-accent);
}
.sn-nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  font-size: 14px;
  line-height: 1;
}
.sn-nav-item.active .sn-nav-icon {
  color: var(--sn-accent);
}
.sn-nav-count {
  margin-left: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--sn-line);
}
.sn-nav-item.active .sn-nav-count {
  color: var(--sn-accent);
}

/* Collapsible sub-nav — animated with max-height transition */
.sn-subnav {
  overflow: hidden;
  max-height: 0;
  background: var(--sn-bg2);
  transition: max-height 0.22s ease;
}
.sn-nav-group.open .sn-subnav {
  max-height: 400px; /* generous cap for any submenu height */
  border-top: 1px solid var(--sn-line);
  border-bottom: 1px solid var(--sn-line);
  padding: 8px 0;
}
.sn-sublink {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 22px 6px 52px;
  font-size: 12.5px;
  color: var(--sn-mute);
  text-decoration: none;
}
.sn-sublink::before {
  content: '';
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--sn-line);
  flex-shrink: 0;
}
.sn-sublink:hover { color: var(--sn-ink); }
.sn-sublink.active { color: var(--sn-ink); }
.sn-sublink.active::before { background: var(--sn-accent); }

/* =====================================================
   Section 4 — Next race card
   ===================================================== */
.sn-next {
  margin: 12px 16px;
  padding: 14px;
  background: var(--sn-paper);
  border: 1px solid var(--sn-line);
  border-left: 3px solid var(--sn-accent);
}
.sn-next-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--sn-accent);
  margin: 0 0 6px;
}
.sn-next-title {
  font-family: 'Fraunces', serif;
  font-weight: 500;
  font-size: 18px;
  line-height: 1.1;
  color: var(--sn-ink);
  margin: 0 0 4px;
}
.sn-next-loc {
  font-size: 11px;
  color: var(--sn-mute);
  margin: 0 0 8px;
}
.sn-next-countdown {
  font-family: 'Archivo', sans-serif;
  font-weight: 800;
  font-size: 22px;
  color: var(--sn-accent);
  font-feature-settings: 'tnum';
  font-variant-numeric: tabular-nums;
}

/* =====================================================
   Section 5 — User footer
   ===================================================== */
.sn-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid var(--sn-line);
}
.sn-user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--sn-accent);
  color: #fff;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}
.sn-user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--sn-ink);
}
.sn-user-role {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--sn-mute);
  text-transform: uppercase;
}

/* =====================================================
   Calendar rail (schedule page)
   ===================================================== */
.calendar-rail {
  padding: 40px 0 22px;
  border-bottom: 1px solid var(--sn-line);
  margin-bottom: 32px;
  color: var(--sn-ink);
}
.cr-header {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: end;
  gap: 24px;
  padding: 0 56px;
  margin-bottom: 22px;
}
.cr-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.18em;
  color: var(--sn-mute);
  text-transform: uppercase;
  margin: 0 0 8px;
}
.cr-title {
  font-family: 'Fraunces', serif;
  font-weight: 400;
  font-size: 54px;
  letter-spacing: -0.02em;
  line-height: 1;
  margin: 0;
}
.cr-title em {
  font-style: italic;
  font-weight: 300;
  color: var(--sn-accent);
}

/* Filter pills */
.cr-filters {
  display: inline-flex;
  border: 1px solid var(--sn-line);
}
.cr-filter {
  padding: 8px 14px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sn-mute);
  background: transparent;
  border: 0;
  border-right: 1px solid var(--sn-line);
  cursor: pointer;
}
.cr-filter:last-child { border-right: 0; }
.cr-filter.active {
  background: var(--sn-accent);
  color: #fff;
}

/* Mini stats */
.cr-stats {
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 20px;
}
.cr-stat-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--sn-mute);
  margin: 0 0 4px;
}
.cr-stat-value {
  font-family: 'Archivo', sans-serif;
  font-weight: 800;
  font-size: 22px;
  color: var(--sn-ink);
  font-variant-numeric: tabular-nums;
}

/* Rail track */
.cr-track {
  display: flex;
  gap: 14px;
  padding: 20px 56px 16px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding-left: 56px;
}
.cr-track::-webkit-scrollbar { height: 6px; }
.cr-track::-webkit-scrollbar-thumb { background: var(--sn-line); }

/* Cards */
.cr-card {
  min-width: 230px;
  flex-shrink: 0;
  height: 380px;
  background: var(--sn-paper);
  border: 1px solid var(--sn-line);
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  scroll-snap-align: start;
  border-radius: 2px;
  text-decoration: none;
  color: inherit;
  position: relative;
}
.cr-card.done    { opacity: 0.42; }
.cr-card.done:hover { opacity: 1; border-color: var(--sn-mute); }
.cr-card.future:hover { border-color: var(--sn-mute); }
.cr-card.next {
  min-width: 420px;
  height: 420px;
  border-color: var(--sn-accent);
  background: var(--sn-bg2);
  box-shadow: inset 0 0 0 1px rgba(255, 58, 31, 0.18);
}

/* "SIRADAKI YARIŞ" tab on next card */
.cr-next-tab {
  position: absolute;
  top: 0;
  left: 18px;
  transform: translateY(-50%);
  background: var(--sn-accent);
  color: #fff;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  padding: 4px 10px;
}

/* Card content */
.cr-card-round {
  font-family: 'Archivo', sans-serif;
  font-weight: 800;
  font-size: 54px;
  line-height: 0.85;
  color: var(--sn-ink);
}
.cr-card-tick {
  position: absolute;
  top: 18px;
  right: 16px;
  width: 18px;
  height: 18px;
  color: var(--sn-good);
  font-size: 18px;
  line-height: 1;
}
.cr-card-sprint {
  position: absolute;
  top: 18px;
  right: 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--sn-sprint);
  border: 1px solid var(--sn-sprint);
  padding: 2px 6px;
}
.cr-card-date {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--sn-mute);
  margin: 14px 0 6px;
}
.cr-card-gp {
  font-family: 'Fraunces', serif;
  font-weight: 500;
  font-size: 22px;
  line-height: 1.1;
  margin: 0 0 4px;
}
.cr-card-gp em { font-style: italic; }
.cr-card-city {
  font-size: 11.5px;
  color: var(--sn-mute);
  margin: 0 0 12px;
}
.cr-card-city strong { color: var(--sn-ink); font-weight: 600; }

/* Track placeholder */
.cr-card-track {
  height: 64px;
  border: 1px dashed var(--sn-line);
  background: repeating-linear-gradient(
    -45deg,
    transparent 0 6px,
    rgba(157, 147, 135, 0.08) 6px 7px
  );
  margin-bottom: 12px;
}
.cr-card.next .cr-card-track {
  height: 90px;
  background: repeating-linear-gradient(
    -45deg,
    transparent 0 6px,
    rgba(255, 58, 31, 0.10) 6px 7px
  );
  border-color: rgba(255, 58, 31, 0.35);
}

/* Podium (done) */
.cr-podium {
  margin-top: auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.cr-podium-slot {
  border-left: 2px solid var(--sn-line);
  padding: 4px 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.1em;
}
.cr-podium-slot:first-child { border-left-color: var(--sn-accent); }
.cr-podium-slot strong {
  color: var(--sn-ink);
  font-weight: 700;
  display: block;
  margin-top: 2px;
}

/* Future row (FP1/Race times) */
.cr-future-times {
  margin-top: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--sn-mute);
}

/* Next card body — 2 columns */
.cr-next-body {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 14px;
  margin-top: auto;
}
.cr-sessions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
}
.cr-sess {
  display: flex;
  justify-content: space-between;
  padding: 4px 6px;
  border-left: 2px solid var(--sn-line);
  color: var(--sn-mute);
}
.cr-sess.is-race {
  background: var(--sn-accent);
  color: #fff;
  border-left-color: #fff;
}
.cr-sess-time { font-variant-numeric: tabular-nums; }

/* Countdown 4-cell grid */
.cr-countdown {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}
.cr-cd-cell {
  border: 1px solid var(--sn-accent);
  padding: 8px 4px;
  text-align: center;
}
.cr-cd-num {
  font-family: 'Archivo', sans-serif;
  font-weight: 800;
  font-size: 26px;
  color: var(--sn-accent);
  font-variant-numeric: tabular-nums;
  display: block;
}
.cr-cd-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--sn-mute);
}

/* "Sıradaki 5" filter hides cards outside the window via the data attribute */
.calendar-rail[data-filter="next5"] .cr-card.done { display: none; }
.calendar-rail[data-filter="next5"] .cr-card.future.cr-out-of-window { display: none; }

/* Focus ring (a11y) */
.sn-nav-item:focus-visible,
.sn-sublink:focus-visible,
.cr-card:focus-visible,
.cr-filter:focus-visible {
  outline: 2px solid var(--sn-accent);
  outline-offset: 2px;
}

/* --- Calendar rail mobile --- */
@media (max-width: 768px) {
  .cr-header {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 0 16px;
  }
  .cr-track {
    padding: 16px 16px 12px;
    scroll-padding-left: 16px;
  }
  .cr-title {
    font-size: 32px;
  }
  .cr-filters {
    align-self: flex-start;
  }
}

@media (max-width: 480px) {
  .cr-title {
    font-size: 24px;
  }
  .cr-card.next {
    min-width: calc(100vw - 48px);
    height: auto;
    min-height: 340px;
  }
  .cr-stats {
    gap: 8px;
  }
}

/* =====================================================
   F — Mobile Bottom Nav (drill-down)
   ===================================================== */

.nf-wrap {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
}

@media (max-width: 768px) {
  .nf-wrap { display: block; }
}

/* Race Pill */
.nf-pill {
  background: var(--ink);
  color: var(--paper);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
}
.nf-pill-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.nf-pulse {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  animation: nfPulse 1.4s infinite ease-in-out;
}
@keyframes nfPulse { 0%,100%{opacity:1} 50%{opacity:.25} }
.nf-pill-lbl {
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 600;
  display: block;
}
.nf-pill-gp {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 300;
  font-size: 13px;
  line-height: 1.2;
  margin-top: 1px;
  letter-spacing: -.01em;
  color: var(--paper);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nf-pill-right {
  text-align: right;
  flex-shrink: 0;
}
.nf-pill-countdown {
  font-family: var(--font-number);
  font-weight: 700;
  font-size: 17px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
  color: var(--paper);
}
.nf-pill-countdown b { color: var(--accent); }
.nf-pill-kala {
  font-family: var(--font-mono);
  font-size: 8px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--faint);
  margin-top: 2px;
}

/* Drawer */
.nf-drawer {
  background: var(--paper);
  border-top: 1px solid var(--line);
  max-height: 60vh;
  overflow-y: auto;
}
.nf-dh {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 14px 16px 10px;
  border-bottom: 2px solid var(--ink);
  position: sticky;
  top: 0;
  background: var(--paper);
}
.nf-dh-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 400;
  color: var(--ink);
}
.nf-dh-title em {
  font-style: italic;
  font-weight: 300;
  color: var(--accent);
}
.nf-dh-close {
  background: none;
  border: 1px solid var(--line);
  padding: 4px 10px;
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--mute);
  cursor: pointer;
  border-radius: 0;
  white-space: nowrap;
}
.nf-dh-close:hover { color: var(--ink); border-color: var(--ink); }

.nf-grp {
  border-bottom: 1px solid var(--line2);
}
.nf-grp-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px 6px;
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--mute);
  font-weight: 600;
}
.nf-grp-count {
  color: var(--faint);
  font-weight: 400;
}
.nf-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 13px 16px;
  border-top: 1px solid var(--line2);
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
  min-height: 44px;
}
.nf-item:hover { background: var(--paper2); }
.nf-item-chev {
  color: var(--mute);
  font-size: 18px;
  line-height: 1;
  margin-left: 8px;
}

/* Tab Strip */
.nf-tabs {
  background: var(--paper);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.nf-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  background: none;
  border: none;
  color: var(--mute);
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: .18em;
  text-transform: uppercase;
  font-weight: 600;
  padding: 11px 4px 10px;
  position: relative;
  cursor: pointer;
  min-height: 44px;
  border-radius: 0;
  -webkit-tap-highlight-color: transparent;
}
.nf-tab-glyph {
  font-size: 15px;
  line-height: 1;
  display: flex;
  align-items: center;
  gap: 2px;
}
.nf-tab-label {
  display: block;
  white-space: nowrap;
}
.nf-caret {
  font-size: 9px;
  color: var(--faint);
  letter-spacing: 0;
  margin-left: 1px;
}

/* Active tab state */
.nf-tab.active {
  color: var(--ink);
}
.nf-tab.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 22px;
  height: 2px;
  background: var(--accent);
}
.nf-tab.active .nf-tab-glyph {
  color: var(--accent);
}

/* Dark theme adjustments */
[data-theme="dark"] .nf-pill {
  background: #1c1811;
}
[data-theme="dark"] .nf-drawer {
  background: var(--paper);
}
[data-theme="dark"] .nf-dh {
  background: var(--paper);
}
[data-theme="dark"] .nf-item:hover {
  background: var(--paper2);
}
