/* App shell: sidebar on desktop, top bar + bottom navigation on phones. */
.shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr); }

.maincol { min-width: 0; display: flex; flex-direction: column; }
#app { outline: none; padding: 4px max(16px, env(safe-area-inset-right)) 48px max(16px, env(safe-area-inset-left)); width: 100%; max-width: 1920px; }   /* fills a 1920px monitor beside the sidebar; capped so 4K screens don't over-stretch */
footer { margin-top: auto; padding: 0 16px 32px; font-size: var(--fs-xs); color: var(--faint); max-width: 1920px; }

/* wordmark: a tiny pitch-line mark and the name */
.wordmark { display: inline-flex; align-items: center; gap: 9px; font-weight: 750; font-size: 15px; letter-spacing: .14em; }
.wm-mark { width: 22px; height: 15px; border: 1.5px solid var(--accent-text); border-radius: 2px; position: relative; flex: none; }
.wm-mark::before { content: ""; position: absolute; left: 50%; top: -1px; bottom: -1px; border-left: 1.5px solid var(--accent-text); }
.wm-mark::after { content: ""; position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; border: 1.5px solid var(--accent-text); border-radius: 50%; transform: translate(-50%, -50%); background: var(--surface); }

/* sidebar */
.sidebar { display: none; }

@media (min-width: 900px) {
  .shell { grid-template-columns: var(--sidebar) minmax(0, 1fr); }
  .sidebar {
    display: flex; flex-direction: column; gap: 22px;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
    padding: 22px 20px 16px; background: var(--sunk); border-right: 1px solid var(--line);
  }
  .sidebar > .wordmark { padding: 0 10px; }
  #sidenav { display: grid; gap: 18px; }
  .navgroup { display: grid; gap: 2px; }
  .navhead { font-size: var(--fs-xs); color: var(--faint); padding: 0 10px 4px; }
  #sidenav button {
    all: unset; cursor: pointer; display: flex; align-items: center; gap: 11px;
    padding: 8px 10px; border-radius: var(--r-sm); color: var(--muted); font-weight: 500;
    transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
  }

  @media (hover: hover) and (pointer: fine) { #sidenav button:hover { background: var(--raised); color: var(--fg); } }
  #sidenav button:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; }
  #sidenav button[aria-current="page"] { background: var(--accent-soft); color: var(--fg); box-shadow: inset 2px 0 0 var(--accent-text); }
  #sidenav button[aria-current="page"] .ic { color: var(--accent-text); }
  .side-foot { margin-top: auto; display: grid; gap: 8px; }
  .mobile-only { display: none !important; }
  #app, footer { padding-left: var(--gutter); padding-right: var(--gutter); }
}

/* theme toggle */
.theme-toggle {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: none; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 10px; color: var(--muted); font-size: var(--fs-sm);
  transition: border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}

@media (hover: hover) and (pointer: fine) { .theme-toggle:hover { color: var(--fg); border-color: var(--line-strong); } }
.theme-toggle.icon-only { width: 38px; height: 38px; padding: 0; justify-content: center; flex: none; }
.theme-toggle.icon-only span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* top bar: who you are and the numbers that matter right now */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 28px;
  padding: calc(14px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 14px max(16px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line); background: var(--bg);
}
.team { display: grid; gap: 2px; min-width: 0; margin-right: auto; }
.team .wordmark { font-size: 12px; margin-bottom: 6px; }
.team-name { margin: 0; font-family: var(--display); font-size: 30px; font-weight: 700; line-height: 1.05; letter-spacing: .02em; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.team .sub { font-size: var(--fs-sm); color: var(--muted); }
.score { display: flex; gap: 8px 28px; flex-wrap: wrap; margin: 0; }
.score .stat dd:first-of-type { font-family: var(--display); font-size: 28px; font-weight: 700; line-height: 1.1; letter-spacing: .01em; white-space: nowrap; }
.score .stat dt { font-size: var(--fs-label); font-weight: 600; letter-spacing: var(--ls-label); text-transform: uppercase; color: var(--faint); }

/* the deadline pill: the only yellow number in the header (armband yellow = the deadline, the captain, your selection) */
.dlpill { flex: none; }
.dlpill .deadline { font: inherit; text-align: left; color: inherit; display: flex; align-items: center; gap: 12px; padding: 8px 14px; border-radius: 12px; cursor: pointer;
  background: var(--hi-soft); border: 1px solid color-mix(in srgb, var(--hi) 40%, transparent); }
.dlpill .deadline:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.dl-cd { font-family: var(--display); font-size: 28px; font-weight: 700; line-height: 1; white-space: nowrap; color: var(--hi-text); }
.dl-txt { display: grid; gap: 2px; }
.dl-l { font-size: var(--fs-label); font-weight: 600; letter-spacing: var(--ls-label); text-transform: uppercase; color: var(--fg); }
.dlpill .stat-sub { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; }

@media (min-width: 900px) {
  .topbar { position: sticky; top: 0; z-index: 5; padding-left: var(--gutter); padding-right: var(--gutter); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); }
}

@media (max-width: 899px) {
  .topbar {
    gap: 3px 6px;
    padding: calc(4px + env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 5px max(14px, env(safe-area-inset-left));
  }
  .team { grid-template-columns: minmax(0, 1fr); flex: 1 1 0; }
  .team .wordmark, .team .sub { display: none; }
  .team-name { font-size: 21px; }
  .score { order: 4; width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .score .stat { gap: 0; }

  /* FL-207: phones put the deadline pill inline with the team name so the header stays <=100px tall without dropping any stat label */
  .dlpill { order: 1; width: auto; }
  .topbar .searchbtn { order: 2; }
  .topbar .theme-toggle { order: 3; }
  .dlpill .deadline {
    flex-direction: column; align-items: center; justify-content: center; gap: 1px;
    min-height: 40px; padding: 3px 9px; border-radius: 10px;
  }
  .dl-cd { font-size: 15px; line-height: 1.05; }
  .dl-txt { display: block; min-width: 0; }
  .dl-l { display: block; font-size: 11px; line-height: 1.05; letter-spacing: .04em; white-space: nowrap; }
  .dlpill .stat-sub { display: none; }
  .theme-toggle.icon-only { width: 40px; height: 40px; }
  .score .stat dd:first-of-type { font-size: 18px; line-height: 1.05; }
  .score .stat dt { white-space: nowrap; font-size: 11px; letter-spacing: .04em; line-height: 1.15; }
  .score .stat-sub { font-size: 11px; line-height: 1.15; }
}

@media (max-width: 360px) {
  .topbar { padding-left: max(12px, env(safe-area-inset-left)); padding-right: max(12px, env(safe-area-inset-right)); }
  .team-name { font-size: 19px; }
  .dlpill .deadline { padding: 3px 7px; }
  .score .stat-sub { white-space: normal; }
}

/* status line: data freshness and the refresh / sync actions */
.status {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px;
  padding: 10px max(16px, env(safe-area-inset-right)) 14px max(16px, env(safe-area-inset-left));
  font-size: var(--fs-sm); color: var(--muted);
}
.status:empty { display: none; }
.st-when { background: transparent; border: 0; padding: 0; cursor: pointer; font: inherit; display: inline-flex; align-items: center; gap: 8px; color: var(--fg); }
.st-note { flex: 1 1 280px; }
.st-acts { display: inline-flex; gap: 6px; }
.st-msg:empty { display: none; }
.st-msg { flex-basis: 100%; color: var(--fg); }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 22%, transparent); }

@media (min-width: 900px) { .status { padding-left: var(--gutter); padding-right: var(--gutter); } }

.st-when.stale > .ic { width: 16px; height: 16px; flex: none; color: var(--warn); }
.st-when.stale.bad > .ic { color: var(--bad); }
.st-age, .lbl-short { display: none; }

/* FL-121: on phones the status is one line. The stale banner gives way to a short warning in place of "Updated …"
   (tap it for Data health and the reason), and the buttons take short labels; their aria-label keeps the full one. */
@media (max-width: 600px) {
  .st-note { display: none; }
  .status { flex-wrap: nowrap; gap: 8px; padding-top: 8px; padding-bottom: 10px; }
  .status .health { display: none; }
  .st-when { min-width: 0; margin-right: auto; white-space: nowrap; }
  .st-when.stale .st-upd { display: none; }
  .st-when.stale .st-age { display: inline; font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
  .st-acts { flex: none; }
  .lbl-full { display: none; }
  .lbl-short { display: inline; }
  .status:has(.st-msg:not(:empty)) { flex-wrap: wrap; }
}

/* the narrowest phones: Sync drops to its icon (aria-label "Sync plan" / "Sync on") so the warning isn't cut off */
@media (max-width: 360px) { .status [data-sync] .lbl-short { display: none; } }

/* bottom navigation (phones) */
.bottomnav { display: none; }

@media (max-width: 899px) {
  .bottomnav {
    display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 35;
    background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
    padding: 6px max(6px, env(safe-area-inset-left)) calc(6px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-right));
  }
  .bottomnav button {
    all: unset; cursor: pointer; display: grid; justify-items: center; gap: 3px;
    padding: 6px 0 4px; color: var(--muted); font-size: 11.5px; font-weight: 500; border-radius: var(--r-sm);
    transition: color var(--t-fast) var(--ease);
  }
  .bottomnav .ic { width: 22px; height: 22px; }
  .bottomnav button[aria-current="page"] { color: var(--accent-text); }
  .bottomnav button[aria-current="page"] .ic { stroke-width: 2.2; }
  .bottomnav button:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
  #app { padding-bottom: calc(88px + env(safe-area-inset-bottom)); }
  footer { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
}

/* "More" sheet (phones) */
.sheet { position: fixed; inset: 0; z-index: 30; background: rgb(0 0 0 / 45%); }
.sheetbody {
  position: absolute; left: 0; right: 0; bottom: 0; display: grid; gap: 2px;
  background: var(--surface); border-top: 1px solid var(--line); border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 10px max(12px, env(safe-area-inset-left)) calc(80px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow);
}
.sheetbody button { all: unset; cursor: pointer; display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 1px 12px; align-items: center; padding: 11px 12px; border-radius: var(--r-sm); }
.sheetbody .ic { grid-row: span 2; width: 20px; height: 20px; color: var(--muted); }
.sheetbody b { font-weight: 600; }
.sheetbody span { font-size: var(--fs-sm); color: var(--muted); }
.sheetbody button:focus-visible { background: var(--raised); outline: 2px solid var(--focus); outline-offset: -2px; }

@media (hover: hover) and (pointer: fine) { .sheetbody button:hover { background: var(--raised); } }
.sheetbody [aria-current="page"] b, .sheetbody [aria-current="page"] .ic { color: var(--accent-text); }

@media (prefers-reduced-motion: no-preference) {
  .sheet:not([hidden]) .sheetbody { animation: rise-sheet var(--t) var(--ease); }
}

/* FL-180: keyframe names are global, so each file's are named for what they do (views.css has rise-intro) */
@keyframes rise-sheet { from { transform: translateY(16px); opacity: 0; } }
