/* Shared layout, navigation and dialogs. Section-specific rules live with each section. */
:root { --page-gutter: clamp(16px, 3.4vw, 48px); }
html { scroll-padding-top: 24px; }
body { min-width: 280px; }
.container { width: min(1320px, calc(100% - var(--page-gutter) * 2)); }
.site-header { position: relative; z-index: 5; }
.header-top { height: 92px; gap: 16px; }
.brand { min-width: 0; }
.site-avatar { flex-shrink: 0; }
.brand-caption { letter-spacing: .13em; }
.nav-container { position: relative; }
#primary-nav { gap: 8px; }
#primary-nav a { min-height: 48px; }
.nav-toggle { display: none; }
#main-content { min-height: calc(100svh - 240px); }
.page-heading > div { min-width: 0; }
.page-heading h1 { overflow-wrap: anywhere; }
.tabs { max-width: 100%; overflow-x: auto; scrollbar-width: thin; }
.tabs .tab { flex: 0 0 auto; white-space: nowrap; }
.site-footer { flex-wrap: wrap; padding-block: 20px; }
.resource-credits ul {padding-left:20px;}
.resource-credits li {margin:20px 0;}
.resource-credits p {color:var(--muted);overflow-wrap:anywhere;}
.resource-credits a {color:var(--accent);text-decoration:underline;text-underline-offset:3px;}
.market-svg {touch-action:pan-y;}
.history-chart {touch-action:auto;}
.theme-switch { max-width: 100%; }
.detail-dialog { width: min(980px, calc(100% - 32px)); max-width: calc(100% - 32px); max-height: calc(100vh - 40px); max-height: calc(100dvh - 40px); overscroll-behavior: contain; scrollbar-gutter: stable; padding-top: 56px; }
.dialog-toolbar { position: sticky; top: 0; display: flex; justify-content: flex-end; margin: 0 0 20px; padding: 4px 0 8px; background: var(--panel); z-index: 8; box-shadow: 0 4px 0 var(--panel); }
.detail-dialog .dialog-close { position: static; display: flex; align-items: center; justify-content: center; margin: 0; width: 44px; height: 44px; min-width: 44px; padding: 0; flex-shrink: 0; border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 50%; box-shadow: 0 2px 10px #0001; }
.dialog-close svg { display: block; width: 20px; height: 20px; pointer-events: none; }
.detail-dialog .dialog-close:hover { background: var(--panel-hover); border-color: var(--accent); }
.detail-dialog .dialog-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
#dialog-content { min-width: 0; }
.detail-dialog::backdrop { background: #06120bcc; }
.route-loading { display: flex; justify-content: center; align-items: center; gap: 12px; min-height: 280px; color: var(--muted); font-size: .9rem; }
.route-loading-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: route-pulse 1.2s ease-in-out infinite; }
.route-error { margin-top: 32px; padding: 36px; }
.route-error p { margin: 12px 0 24px; color: var(--muted); }
@keyframes route-pulse { 50% { opacity: .25; } }

@media (max-width: 1100px) and (min-width: 901px) {
  #primary-nav a { font-size: .78rem; gap: 5px; }
  #primary-nav a .icon { width: 15px; height: 15px; }
}
@media (max-width: 900px) {
  .header-top { height: 80px; }
  .site-avatar { width: 44px; height: 44px; }
  .brand { gap: 10px; }
  .nav-container { padding-block: 10px; overflow: visible; }
  .nav-toggle { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 9px; color: var(--text); background: var(--panel); font-size: .85rem; text-align: left; }
  .nav-toggle > .icon { width: 18px; height: 18px; }
  .nav-toggle [data-nav-current] { margin-left: auto; color: var(--accent); }
  .nav-toggle .nav-chevron { display:block; width:20px; height:20px; flex-shrink:0; transition:transform 160ms; }
  .nav-toggle[aria-expanded=true] .nav-chevron { transform: rotate(180deg); }
  #primary-nav { display: none; min-width: 0; padding: 10px 0 4px; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; }
  .nav-is-open #primary-nav { display: grid; }
  #primary-nav a { padding: 12px; min-height: 48px; border-radius: 8px; font-size: .85rem; justify-content: flex-start; gap: 8px; }
  #primary-nav [aria-current] { background: var(--accent-dark); }
  #primary-nav [aria-current]::after { display: none; }
  #main-content { padding-bottom: 36px; }
  .page-heading { gap: 16px; padding-block: 26px; }
  .page-heading h1 { font-size: clamp(1.65rem, 4vw, 2.4rem); }
}
@media (max-width: 480px) {
  .header-top { height: 72px; }
  .brand-caption { font-size: .65rem; letter-spacing: .04em; }
  .site-avatar { width: 38px; height: 38px; }
  .site-like-button { gap: 6px; padding: 8px 12px; }
  .site-like-status { max-width: 140px; }
  #primary-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-number { display: none; }
  .site-footer { justify-content: space-between; gap: 16px; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
  .theme-switch { order: 3; flex-basis: 100%; justify-content: center; }
  .theme-switch button { flex: 1; justify-content: center; min-height: 42px; }
  .detail-dialog { width: calc(100% - 16px); max-width: calc(100% - 16px); max-height: calc(100vh - 16px); max-height: calc(100dvh - 16px); padding: 56px 16px calc(20px + env(safe-area-inset-bottom)); border-radius: 12px; }
  .route-error { padding: 24px; }
}
@media (pointer: coarse) {
  button:not(.dealer-seat), .button, select { min-height: 44px; }
  input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .route-loading-dot { animation: none; }
  .nav-chevron { transition: none; }
}
