/* Common header + race-detail countdown (spec of 2026-10-26, implemented 2026-10-27).
   Loaded last. Top page keeps the full PROBIAS logo; every lower page gets a compact bar with the
   small "P." emblem. Race detail has no logo (venue / race / deadline selector is its header). */
:root{--countdown-urgent:#ff5555;--sub-head-h:44px}

/* ===== lower pages: news / search / live / results / custom ===== */
body[data-view="news"] .layout,body[data-view="search"] .layout,body[data-view="live"] .layout,
body[data-view="results"] .layout,body[data-view="custom"] .layout{display:block;min-height:100dvh}
body[data-view="news"] .sidebar,body[data-view="search"] .sidebar,body[data-view="live"] .sidebar,
body[data-view="results"] .sidebar,body[data-view="custom"] .sidebar{
 position:static;height:auto;min-height:var(--sub-head-h);max-width:1120px;margin:0 auto;padding:7px 12px;
 display:flex;flex-direction:row;align-items:center;gap:10px;border:0;background:transparent}
body[data-view="news"] .brand,body[data-view="search"] .brand,body[data-view="live"] .brand,
body[data-view="results"] .brand,body[data-view="custom"] .brand{padding:0;gap:0;flex:0 0 auto;order:0}
body[data-view="news"] .brand-type,body[data-view="search"] .brand-type,body[data-view="live"] .brand-type,
body[data-view="results"] .brand-type,body[data-view="custom"] .brand-type{display:none}
body[data-view="news"] .brand-emblem,body[data-view="search"] .brand-emblem,body[data-view="live"] .brand-emblem,
body[data-view="results"] .brand-emblem,body[data-view="custom"] .brand-emblem{width:30px;height:30px;font-size:22px;border-radius:9px 9px 9px 3px}
body[data-view="news"] .sidebar::after,body[data-view="search"] .sidebar::after,body[data-view="live"] .sidebar::after,
body[data-view="results"] .sidebar::after,body[data-view="custom"] .sidebar::after{font-size:17px;font-weight:800;letter-spacing:.02em;color:var(--text);line-height:1.2}
body[data-view="news"] .sidebar::after{content:"ニュース"}
body[data-view="search"] .sidebar::after{content:"レース検索"}
body[data-view="live"] .sidebar::after{content:"ライブ"}
body[data-view="results"] .sidebar::after{content:"結果一覧"}
body[data-view="custom"] .sidebar::after{content:"カスタム"}
/* the date lives where it is needed: news has its own date tabs, search its own date field */
body[data-view="news"] .global-date,body[data-view="search"] .global-date,body[data-view="live"] .global-date,body[data-view="custom"] .global-date{display:none}
body[data-view="results"] .global-date{display:flex;margin:0 0 0 auto;font-size:10px}
body[data-view="results"] .global-date input{width:128px;min-height:30px}
/* the title is now in the bar; the in-page headings stay for screen readers only */
body[data-view="news"] .news-head,body[data-view="search"] #searchView>h1,body[data-view="live"] #liveView>h1,body[data-view="custom"] #customView>h1{
 position:absolute!important;width:1px!important;height:1px!important;margin:-1px!important;padding:0!important;overflow:hidden!important;clip:rect(0,0,0,0)!important;white-space:nowrap!important;border:0!important}
/* page body starts right under the bar */
body[data-view="news"] .main,body[data-view="search"] .main,body[data-view="live"] .main,body[data-view="results"] .main,body[data-view="custom"] .main{padding-top:0}
body[data-view="news"] .main>.view,body[data-view="search"] .main>.view,body[data-view="live"] .main>.view,body[data-view="results"] .main>.view,body[data-view="custom"] .main>.view{margin-top:4px}

/* ===== race detail selector bar (2026-10-27 rev.2) =====
   venue : race = 1 : 1 (result button stays at the right edge, independent). Deadline + countdown are two
   lines inside the race box, same font size (12px = readable on iPhone without zoom), no own background/border. */
body.compact-race #raceView .race-selector-bar{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr) auto;gap:6px;align-items:stretch}
body.compact-race #raceView .race-choice-venue,body.compact-race #raceView .race-choice-number{box-sizing:border-box;width:auto;min-width:0;max-width:none;margin:0}
body.compact-race #raceView .race-choice-number{display:flex;align-items:center;gap:0;background:#132337;border-radius:8px 8px 0 0}
body.compact-race #raceView .race-choice-number select{flex:0 0 46px;width:46px;max-width:46px;padding:4px 0 4px 8px;background:transparent}
body.compact-race #raceView .race-choice-number .race-choice-close{
 position:static;top:auto;right:auto;bottom:auto;left:auto;flex:1 1 auto;min-width:0;align-self:center;
 display:flex;flex-direction:column;justify-content:center;gap:1px;
 padding:0 20px 0 6px;overflow:visible;white-space:nowrap;text-overflow:clip;max-width:none;
 font-size:12px;line-height:1.2;font-weight:600;font-variant-numeric:tabular-nums;color:#9abdd5;background:none;border:0;pointer-events:none}
body.compact-race #raceView .race-choice-number .race-choice-close::after{
 content:attr(data-cd);position:static;display:block;margin:0;white-space:nowrap;
 font:inherit;line-height:inherit;color:var(--cyan,#5ae3e1);background:none;border:0;padding:0}
body.compact-race #raceView .race-choice-number .race-choice-close[data-state="urgent"]::after{color:var(--countdown-urgent)}
body.compact-race #raceView .race-choice-number .race-choice-close[data-state="closed"]::after{color:#9abdd5}
body.compact-race #raceView .race-choice-number .race-choice-close:not([data-cd])::after{content:none}
/* the old stand-alone countdown in the meta row is replaced by the one above */
#raceView .race-head-metadata .race-countdown{display:none}

/* header order: [P.] [page title] ............ [date, results only] */
body[data-view="news"] .sidebar::after,body[data-view="search"] .sidebar::after,body[data-view="live"] .sidebar::after,
body[data-view="results"] .sidebar::after,body[data-view="custom"] .sidebar::after{order:1;flex:1 1 auto;min-width:0}
body[data-view="results"] .global-date{order:2}

/* ===== results list: back + venue picker on one row, no duplicated date chip ===== */
#resultsView:not([hidden]){display:grid;grid-template-columns:auto minmax(0,1fr);column-gap:10px;align-items:center}
#resultsView>*{grid-column:1/-1}
#resultsView>#resultsBackHome{grid-column:1;grid-row:1;margin:0}
#resultsView>.results-venue-pick{grid-column:2;grid-row:1;margin:0;display:flex;align-items:center;justify-content:flex-end;gap:8px;font-size:12px}
#resultsView>.results-venue-pick select{width:auto;min-width:130px;max-width:100%;min-height:34px;padding-top:4px;padding-bottom:4px}
#resultsView>.section-top{grid-row:2;margin:8px 0 2px}
#resultsView #venueResultsTitle{font-size:20px;line-height:1.25;margin:0}
#resultsView #venueResultsDate{display:none}
#resultsView>#venueResultsStatus{grid-row:3;margin:0 0 6px;font-size:12px}
#resultsView>.panel{grid-row:4}

/* results venue picker: label and select on one line */
#resultsView>.results-venue-pick{flex-direction:row}
/* search: keep the note clear of the submit button (they overlapped) */
#searchView .search-form{margin-bottom:14px}
#searchView .search-form .btn{align-self:start;margin-bottom:2px}
/* the generic .subtext pulls itself up 13px and overlapped the control above it on these pages */
#searchView .subtext,#liveView .subtext,#customView .subtext{margin-top:10px}

/* ===== race detail rev.3: nav row (← 開催 / 前R / 次R) removed, "開催N日目" beside the race category ===== */
body.compact-race #raceView .compact-race-tools{display:none!important;margin:0!important;padding:0!important;height:0!important}
body.compact-race #raceView .race-head-metadata{justify-content:flex-start;gap:8px;flex-wrap:nowrap}
body.compact-race #raceView .race-head-metadata .race-head-distance{margin-left:auto}
body.compact-race #raceView .race-meeting-row{display:flex;align-items:baseline;gap:8px}
body.compact-race #raceView .race-meeting-row .race-meeting-name{flex:0 1 auto;min-width:0}
body.compact-race #raceView .race-head-day{flex:0 0 auto;color:#9abdd5;font-size:12px;font-weight:700;white-space:nowrap}
body.compact-race #raceView .race-head-day[hidden]{display:none}

/* ===== rev.4 (2026-10-27): one common header on EVERY screen incl. race detail =====
   [P.] PROBIAS ........ [page title / date]. The safe area is added exactly once, here (viewport-fit=cover;
   no other element pads env(safe-area-inset-top)), so the Dynamic Island / notch / status bar never covers
   the selector bar. Same height and position on every page. */
:root{--hdr-pad:7px}
body[data-view] .layout{display:block;min-height:100dvh}
body[data-view] .sidebar,body.compact-race .sidebar{
 display:flex!important;flex-direction:row;align-items:center;gap:10px;position:static;height:auto;
 min-height:var(--sub-head-h);max-width:1120px;margin:0 auto;border:0;background:transparent;
 padding:calc(env(safe-area-inset-top,0px) + var(--hdr-pad)) 12px var(--hdr-pad)}
body[data-view] .sidebar .brand{display:flex;align-items:center;padding:0;gap:8px;flex:0 0 auto;order:0}
body[data-view] .sidebar .brand-emblem{width:30px!important;height:30px!important;flex:0 0 30px!important;font-size:22px!important;border-radius:9px 9px 9px 3px}
body[data-view] .sidebar .brand-type{display:block;font-size:17px;letter-spacing:1.2px;font-weight:900;line-height:1.1}
body[data-view] .sidebar .brand-type small{display:none}
body[data-view] .sidebar .nav,body[data-view] .sidebar .sidebar-label,body[data-view] .sidebar .module,body[data-view] .sidebar .sidebar-bottom{display:none!important}
/* page title stays at the right of the bar */
body[data-view="news"] .sidebar::after,body[data-view="search"] .sidebar::after,body[data-view="live"] .sidebar::after,
body[data-view="results"] .sidebar::after,body[data-view="custom"] .sidebar::after{order:1;flex:1 1 auto;text-align:right;font-size:14px;color:#9abdd5}
body[data-view="home"] .global-date,body[data-view="results"] .global-date{display:flex;order:2;margin:0 0 0 auto;font-size:10px}
body[data-view="home"] .global-date input,body[data-view="results"] .global-date input{width:128px;min-height:30px}
body[data-view="race"] .global-date{display:none}
body[data-view] .main{padding-top:0}
body[data-view="race"] .main>.view{margin-top:2px}

/* ===== rev.4: result page = 払戻 → 着順 → スリット (no stand-alone result panel) ===== */
#resultView .result-facts-panel:first-of-type{margin-top:0}
.result-facts-panel .section-top{display:flex;align-items:baseline;gap:8px}
.result-facts-panel .section-top .result-official-link{margin-left:auto;min-height:0;padding:2px 0;border:0;background:none;font-size:11px;font-weight:600;color:#7fa9c4}
/* ===== rev.4: exhibit page order = 展示データ → スタート展示 → 気象情報 ===== */
#exhibitInfo .exhibit-block{margin-top:10px}
#exhibitInfo .exhibit-block#realtimeData{margin-top:14px}
#exhibitInfo .slit-provenance{margin-top:10px}
.weather-card{margin-top:14px;padding:10px 12px;border:1px solid #223650;border-radius:10px;background:#0f1b2d}
.weather-card h3{margin:0 0 8px;font-size:13px;font-weight:800;color:#bed5e4}
.weather-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px}
.weather-item{display:flex;justify-content:space-between;align-items:baseline;gap:6px;padding:7px 10px;border-radius:8px;background:#132337}
.weather-item span{font-size:11px;color:#9abdd5}
.weather-item strong{font-size:15px;font-variant-numeric:tabular-nums;color:var(--text)}
.weather-item small{font-size:10px;font-weight:600;margin-left:2px;color:#9abdd5}
.weather-empty{grid-column:1/-1;margin:0;font-size:12px;color:#9abdd5}
@media(max-width:400px){
 body[data-view="results"] .sidebar{flex-wrap:nowrap;gap:6px}
 body[data-view="results"] .sidebar::after{font-size:12px;flex:0 1 auto;white-space:nowrap;margin-left:2px}
 body[data-view="results"] .global-date{flex:0 0 auto;font-size:0;gap:0}
 body[data-view="results"] .global-date input{width:112px;font-size:12px}
}
