/* ═══════════════════════════════════════════════════════════════════════════
   shared_style.css — PokemonKali iRacing 群赛站点 共享主题样式

   此文件被 race_analyzer.py (报告生成) 和 server/rebuild_index.py (网站首页)
   同时引用。修改此文件即可统一更新报告和网站的视觉主题。

   ⚠️ 修改此文件后需：
   1. 推送 GitHub (iracing-website-dev 自动完成)
   2. 部署到 hkserver (deploy_site.sh 自动同步)
   3. 本地生成报告时自动读取最新版本 (同仓库，无需额外操作)
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --accent: #e8510a;
  --accent-hover: #d94706;
  --accent-light: #fff5f0;
  --accent-dark: #bf3a00;
  --accent-rgb: 232, 81, 10;
  --text: #1a1a2e;
  --text-secondary: #6b7280;
  --text-muted: #94a3b8;
  --border: #e5e7eb;
  --border-strong: #cbd5e1;
  --bg: #fafafa;
  --bg-alt: #f3f4f6;
  --card-bg: #ffffff;
  --green: #10b981;
  --red: #ef4444;
  --orange: #f59e0b;
  --purple: #7c3aed;
  --header-bg: #0f0f23;
  --header-text: #e2e8f0;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --radius-sm: 7px;
  --radius-md: 11px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 8px 28px rgba(15, 23, 42, 0.09);
  --shadow-lg: 0 18px 56px rgba(15, 23, 42, 0.18);
  --focus-ring: 0 0 0 3px rgba(var(--accent-rgb), 0.25);
  --content-width: 1200px;
  --touch-target: 44px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 150px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #fafafa 0%, #f0f0f5 100%);
  line-height: 1.5;
  max-width: var(--content-width);
  margin: 0 auto;
  min-height: 100vh;
  accent-color: var(--accent);
}

button, input, select, textarea { font: inherit; }
button, [role="button"], a { -webkit-tap-highlight-color: transparent; }
button:not(:disabled), [role="button"]:not([aria-disabled="true"]) { cursor: pointer; }
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  box-shadow: var(--focus-ring);
}
::selection { color: #fff; background: var(--accent); }

/* Shared primitives */
.ui-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.ui-btn {
  min-height: var(--touch-target);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card-bg);
  color: var(--text);
  font-weight: 700;
  transition: transform .18s var(--ease-out), border-color .18s, background .18s, color .18s;
}
.ui-btn:hover { border-color: var(--accent); color: var(--accent); transform: translateY(-1px); }
.ui-btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.ui-btn-primary:hover { background: var(--accent-hover); color: #fff; }
.ui-field {
  min-height: var(--touch-target);
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card-bg);
  color: var(--text);
  transition: border-color .18s, box-shadow .18s;
}
.ui-field:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus-ring); }
.ui-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--bg-alt);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
}
.ui-empty, .ui-loading {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-secondary);
}

/* Shared overlays, notices and mobile data cards */
.ui-overlay {
  position: fixed;
  inset: 0;
  z-index: 11000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 15, 35, .7);
  backdrop-filter: blur(7px);
}
.ui-dialog {
  width: min(440px, 100%);
  padding: 24px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--radius-xl);
  background: #17172c;
  color: #e2e8f0;
  box-shadow: var(--shadow-lg);
}
.ui-dialog h2 { margin-bottom: 8px; color: #fff; font-size: 20px; }
.ui-dialog p { color: #a8b3c7; line-height: 1.7; }
.ui-dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.ui-toast-region {
  position: fixed;
  z-index: 12000;
  right: 20px;
  bottom: 20px;
  display: grid;
  gap: 8px;
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}
.ui-toast {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: #172033;
  color: #fff;
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--accent);
  animation: uiToastIn .25s var(--ease-out);
}
.ui-toast.success { border-left-color: var(--green); }
.ui-toast.error { border-left-color: var(--red); }
.ui-toast.warning { border-left-color: var(--orange); }
@keyframes uiToastIn { from { opacity: 0; transform: translateY(8px); } }

.mobile-data-list { display: none; }
.mobile-data-card {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card-bg);
  box-shadow: var(--shadow-sm);
}
.mobile-data-card + .mobile-data-card { margin-top: 10px; }
.mobile-data-card dl { display: grid; grid-template-columns: minmax(80px, auto) 1fr; gap: 7px 12px; }
.mobile-data-card dt { color: var(--text-muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.mobile-data-card dd { min-width: 0; color: var(--text); font-size: 13px; overflow-wrap: anywhere; }
.mobile-data-card dd a { color: var(--accent-dark); }
.mobile-data-more {
  min-height: 40px;
  width: 100%;
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-alt);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
}
.ui-data-dialog { max-height: min(720px, calc(100dvh - 40px)); overflow: auto; background: var(--card-bg); color: var(--text); }
.ui-data-dialog-head { position: sticky; z-index: 1; top: -24px; display: flex; align-items: center; gap: 12px; margin: -24px -24px 18px; padding: 18px 20px; border-bottom: 1px solid var(--border); background: var(--card-bg); }
.ui-data-dialog-head h2 { flex: 1; margin: 0; color: var(--text); }
.ui-data-close { width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--bg-alt); color: var(--text); font-size: 26px; line-height: 1; }
.ui-data-details { display: grid; grid-template-columns: minmax(90px, auto) 1fr; gap: 0; }
.ui-data-details dt, .ui-data-details dd { padding: 10px 0; border-bottom: 1px solid var(--border); }
.ui-data-details dt { padding-right: 14px; color: var(--text-muted); font-size: 11px; font-weight: 800; }
.ui-data-details dd { min-width: 0; overflow-wrap: anywhere; color: var(--text); font-size: 13px; }
.ui-scroll-hint { display: none; margin: 0 0 6px; color: var(--text-muted); font-size: 11px; text-align: right; transition: opacity .2s; }
.ui-scroll-hint.seen { opacity: 0; }
html.ui-dialog-open, html.ui-dialog-open body { overflow: hidden; }

.mobile-bottom-nav { display: none; }
.report-overview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
  padding: 18px 20px;
}
.report-overview h2 { margin: 7px 0 2px; font-size: 19px; }
.report-overview p { color: var(--text-secondary); font-size: 12px; }
.report-overview nav { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.report-overview a {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px;
  color: var(--accent-dark); background: var(--accent-light); text-decoration: none;
  font-size: 12px; font-weight: 700;
}

/* ── Shared Header Pattern (gradient bg + checkerboard + rainbow strip) ── */
.header-base {
  background:
    linear-gradient(135deg, rgba(15,15,35,0.82) 0%, rgba(26,26,62,0.78) 30%, rgba(22,33,62,0.82) 100%),
    url('/bg/header_bg.png') center/cover no-repeat;
  color: var(--header-text);
  position: relative;
}
.header-base::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-conic-gradient(#ffffff08 0% 25%, transparent 0% 50%) 0 0 / 28px 28px;
  pointer-events: none;
}
.header-base::after {
  content: "";
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--orange), var(--purple), var(--green));
}

@media (max-width: 640px) {
  html { scroll-padding-top: 112px; }
  body { overflow-wrap: anywhere; }
  body.has-mobile-nav { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  input, select, textarea { font-size: 16px !important; }
  button, [role="button"], summary { touch-action: manipulation; }
  .ui-overlay {
    align-items: flex-end;
    padding: max(12px, env(safe-area-inset-top)) 0 0;
  }
  .ui-dialog {
    width: 100%;
    max-height: calc(100dvh - max(12px, env(safe-area-inset-top)));
    padding: 22px 16px calc(18px + env(safe-area-inset-bottom));
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    overflow: auto;
  }
  .ui-data-dialog-head { top: -22px; margin: -22px -16px 16px; padding: 12px 16px; }
  .ui-data-details { grid-template-columns: minmax(76px, auto) 1fr; }
  .ui-scroll-hint { display: block; }
  .mobile-bottom-nav {
    position: fixed;
    z-index: 9000;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(62px, 1fr);
    width: min(100%, var(--content-width));
    padding: 6px max(8px, env(safe-area-inset-left)) calc(6px + env(safe-area-inset-bottom));
    border-top: 1px solid rgba(255,255,255,.1);
    background: rgba(15, 15, 35, .96);
    box-shadow: 0 -8px 24px rgba(15,23,42,.2);
    backdrop-filter: blur(14px);
  }
  .mobile-bottom-nav button {
    min-height: 52px;
    padding: 5px 4px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: #94a3b8;
    font-size: 10px;
    font-weight: 700;
  }
  .mobile-bottom-nav button.active { color: #fff; background: rgba(var(--accent-rgb), .22); }
  .mobile-bottom-nav .tab-icon { display: block; width: 17px; height: 17px; margin: 0 auto 3px; background: currentColor; }
  .mobile-data-list { display: block; }
  table[data-mobile-cards="true"] { display: none; }
  .mobile-data-card { padding: 13px; }
  .ui-dialog-actions { flex-direction: column-reverse; }
  .ui-dialog-actions .ui-btn { width: 100%; }
  .ui-toast-region { right: 16px; bottom: 84px; }
  .report-overview { align-items: stretch; flex-direction: column; padding: 15px; }
  .report-overview nav { justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
