/* League Hub styles: layout.css. The shared frame (header, rail, bottom bar), theme menu, page header and schedule summary tiles.
   Files load in this order: tokens.css, base.css, components.css, layout.css, pages.css, admin.css, refinements.css (App.razor). Later files override earlier ones; see docs/DESIGN-SYSTEM.md. */

.app-shell {
  display: grid;
  grid-template-columns: 176px minmax(0, 1fr);
  grid-template-rows: auto 1fr auto;
  gap: 0 clamp(18px, 2vw, 28px);
  max-width: var(--layout-max);
  min-height: 100vh;
  margin: 0 auto;
  padding-inline: var(--layout-gutter);
}
.app-header, .app-footer { grid-column: 1 / -1; }
.app-header { grid-row: 1; background: transparent; border-bottom: 1px solid var(--t-border); box-shadow: none; }
.app-header .header-inner {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) minmax(0, 330px) auto;
  align-items: center;
  gap: 12px clamp(12px, 1.5vw, 20px);
  padding: 14px 0;
}
.app-header .brand, .app-header .brand:hover {
  gap: 9px;
  color: var(--t-foreground);
  font-size: clamp(1.08rem, 2.2vw, 1.35rem);
}
.app-header .brand-mark { inline-size: clamp(30px, 4vw, 38px); block-size: clamp(30px, 4vw, 38px); color: var(--t-link); flex: none; }
.main-nav { grid-column: 2; justify-content: flex-end; }
.mobile-more, .mobile-section-nav { display: none; }
.main-nav a { border-radius: var(--radius-md); padding-inline: 9px; color: var(--t-muted); font-size: var(--fs-md); }
.main-nav a.active { background: var(--t-accent-soft); color: var(--t-accent-soft-text); box-shadow: inset 0 -2px var(--t-accent); }
.main-nav a:hover:not(.active) { background: var(--t-panel-raised); color: var(--t-foreground); }
.theme-picker { grid-column: -2; position: relative; margin: 0; --mk-control-h: 40px; }
@media (pointer: coarse) { .theme-picker { --mk-control-h: 44px; } }
@media (pointer: coarse) { .theme-trigger { width: 44px; height: 44px; } }
.header-search { grid-column: 3; position: relative; display: flex; min-width: 0; gap: 6px; margin: 0; }
.header-search input { width: 100%; min-width: 0; padding: 0 10px; border-radius: var(--radius-md); }
.header-search-results {
  position: absolute;
  inset: calc(100% + 6px) 0 auto;
  max-height: min(23rem, 50dvh);
  overflow: auto;
  overscroll-behavior: contain;
  padding: 6px;
  border: 1px solid var(--t-border);
  border-radius: var(--panel-radius);
  background: var(--t-panel);
  box-shadow: var(--panel-shadow);
}
.header-search:not(:focus-within) .header-search-results { display: none; }
.header-search-results ul { list-style: none; margin: 0; padding: 0; }
.header-search-results a { display: grid; gap: 2px; padding: 8px 10px; border-radius: var(--radius-md); overflow-wrap:break-word; }
.header-search-results a:hover, .header-search-results a:focus-visible { background: var(--t-panel-raised); text-decoration: none; }
.header-search-results a:focus-visible { outline-offset: -2px; }
.header-search-results strong { color: var(--t-foreground); }
.header-search-results small, .header-search-status { color: var(--t-muted); font-size: var(--fs-md); }
.header-search-status { margin: 0; padding: 5px 10px; }
.header-search-all { font-size: var(--fs-md); font-weight: 650; }
.import-notice {
  position: fixed;
  z-index: 850;
  inset: auto max(16px, env(safe-area-inset-right)) 16px auto;
  max-width: calc(100vw - 32px);
  pointer-events: none;
}
.import-notice-message {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--t-border);
  border-radius: var(--radius-lg);
  background: var(--t-panel-raised);
  color: var(--t-foreground);
  box-shadow: var(--panel-shadow);
  font-size: var(--fs-md);
}
.import-notice-spinner {
  width: 14px;
  height: 14px;
  flex: none;
  border: 2px solid var(--t-accent);
  border-inline-end-color: transparent;
  border-radius: 50%;
  animation: import-notice-spin .8s linear infinite;
}
@keyframes import-notice-spin { to { transform: rotate(1turn); } }
@media (prefers-reduced-motion: reduce) { .import-notice-spinner { animation: none; } }
.league-rail {
  grid-column: 1;
  grid-row: 2;
  position: sticky;
  top: 16px;
  align-self: start;
  max-height: calc(100vh - 32px);
  overflow: auto;
  margin-block: clamp(20px, 3vw, 36px);
  padding: 6px;
  border: 1px solid var(--t-border);
  border-radius: var(--panel-radius);
  background: var(--t-panel);
}
.rail-links { display: grid; gap: 3px; }
.rail-links a {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 9px;
  border-radius: var(--radius-md);
  color: var(--t-muted);
  font-size: var(--fs-md);
  font-weight: 650;
}
.rail-links a:hover, .mobile-bottom-nav a:hover {
  background: var(--t-panel-raised);
  color: var(--t-foreground);
  text-decoration: none;
}
.rail-links a.active, .rail-group.active .rail-group-link, .mobile-bottom-nav a.active, .mobile-more a.active {
  background: var(--t-accent-soft);
  color: var(--t-accent-soft-text);
  font-weight: 750;
}
/* More button: active state is neutral (white on dark themes, black on light) instead of the red accent glow. */
.mobile-more a.active { background: var(--t-panel-raised); color: var(--t-foreground); }
.rail-links a:focus-visible, .rail-group-toggle:focus-visible { outline: 2px solid var(--t-accent); outline-offset: -2px; }

/* A nav group's link (navigate) and its disclosure toggle (expand/collapse the subnav) are
   siblings, not nested, so neither hides a separately-focusable control inside the other. */
.rail-group { display: flex; align-items: stretch; border-radius: var(--radius-md); }
.rail-group .rail-group-link { flex: 1; border-radius: var(--radius-md) 0 0 var(--radius-md); }
.rail-group-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 36px;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  background: none;
  color: inherit;
  cursor: pointer;
}
.rail-group-toggle:hover { background: var(--t-panel-raised); }
.rail-group-chevron {
  width: 6px;
  height: 6px;
  border: solid currentColor;
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(-45deg);
}
.rail-group-toggle[aria-expanded="true"] .rail-group-chevron { transform: rotate(45deg); }
.rail-subnav { margin: 3px 0 5px 16px; padding-inline-start: 5px; border-inline-start: 1px solid var(--t-border); }
.rail-subnav a { min-height: 36px; font-size: var(--fs-sm); overflow-wrap: break-word; }
.rail-subnav[hidden] { display: none; }
.section-nav { margin: 0 0 16px; padding: 0 12px; border: 1px solid var(--t-border); border-radius: var(--radius-md); background: var(--t-panel); }
.stats-section-nav { position:sticky; inset-block-start:0; z-index:5; }
.stats-section-nav > nav { max-block-size:35vh; overflow:auto; }
.section-nav > summary { padding-block: 10px; cursor: pointer; font-weight: 650; }
.section-nav-links { display: flex; flex-wrap: wrap; gap: 6px 12px; padding-bottom: 8px; }
.section-nav-links a { padding: 8px 4px; }
.section-nav-links a.active, .admin-navigation a.active { color: var(--t-link); font-weight: 750; }
.admin-navigation-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); gap: 12px; margin: 8px 0 18px; }
.admin-navigation-groups section { padding: 12px; border: 1px solid var(--t-border); border-radius: var(--radius-md); background: var(--t-panel); }
.admin-navigation-groups h2 { margin: 0 0 8px; }
.admin-navigation-groups ul { list-style: none; margin: 0; padding: 0; }
.admin-navigation-groups a { display: block; padding-block: 6px; }
.connection-form fieldset { display: grid; gap: 8px; min-width: 0; }
.connection-form legend { font-weight: 750; color: var(--t-foreground); }
.connection-form :is(input, textarea) {
  width: 100%;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--t-border);
  border-radius: var(--radius-md);
  background: var(--t-panel-raised);
  color: var(--t-foreground);
  font: inherit;
}
.connection-form .check-label { display: flex; align-items: center; gap: 10px; }
.connection-form input[type="checkbox"] { width: auto; flex: none; padding: 0; }
.connection-form .picker-actions input[type="search"] { width: auto; min-width: 200px; }
.nav-icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.app-main {
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
  padding: clamp(20px, 3vw, 36px) 0 clamp(36px, 5vw, 64px);
  overflow-wrap: anywhere;
}
.app-footer { background: transparent; }
.app-main :where(img, video) { max-width: 100%; height: auto; }
.app-main h1 { font-size: clamp(1.85rem, 1.35rem + 2vw, 2.9rem); font-weight: 800; }
.app-main h2 { font-size: clamp(1.15rem, 1rem + .5vw, 1.5rem); }
.app-main :where(h1, h2, h3) { line-height: 1.2; }
/* Page header: one compact banner on every page, in the size of the Home header, with the theme gradient and the dartboard watermark. */
.page-title-row {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-height: 9.2rem;
  margin-bottom: 20px;
  padding: 18px clamp(16px, 3vw, 28px);
  border: 1px solid var(--t-border);
  border-radius: var(--panel-radius);
  background: linear-gradient(115deg, var(--t-panel), var(--t-accent-soft));
  box-shadow: var(--panel-shadow);
}
.page-title-row::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset-block-start: 50%;
  inset-inline-end: 0;
  width: clamp(180px, 36vw, 250px);
  aspect-ratio: 1;
  transform: translate(8%, -50%);
  background: var(--t-link);
  -webkit-mask: url("../dartboard.svg") center / contain no-repeat;
  mask: url("../dartboard.svg") center / contain no-repeat;
  opacity: .2;
  pointer-events: none;
}
.page-title-row > * { position: relative; min-width: 0; }
/* The text takes the space beside the page's buttons and only drops them to their own line when it would get narrower than 22rem. */
.page-title-row > :first-child { flex: 1 1 22rem; }
.page-title-row .eyebrow { display: block; margin: 0 0 4px; }
.page-title-row .sub { margin-bottom: 0; }
/* flex-shrink 1 (not 0) lets this shrink below its natural width and, with flex-wrap, spill its own buttons onto a
   second line instead of overflowing the header when there are several of them (e.g. Import Status's four). */
.page-title-links { display: flex; flex-wrap: wrap; gap: 8px; flex: 0 1 auto; }
.page-title-row > :first-child:has(+ .page-title-links) { flex-basis: 12rem; }
.page-title-row .btn, .app-header .header-search .btn {
  min-block-size: var(--control-h);
  padding: var(--sp-1) var(--sp-2);
  border-radius: var(--radius-lg);
  font-size: var(--fs-sm);
  line-height: 1.25;
}
@media (min-width: 801px) and (pointer: fine) {
  .page-title-row .btn {
    position: relative;
    min-block-size: var(--control-h-compact);
  }
  /* Extend the hit area above and below the smaller pill. */
  .page-title-row .btn::after {
    content: "";
    position: absolute;
    inset: calc(-1.5 * var(--sp-1)) 0;
  }
}
@media (max-width: 640px) {
  .page-title-row { min-height: 7.5rem; padding: 14px 16px; }
  .page-title-row::before { width: 156px; transform: translate(18%, -50%); }
}
.eyebrow { text-transform: uppercase; }
.btn, .main-nav a, .rail-links a, .mobile-bottom-nav a, .home-shortcuts a, .calendar-event,
.calendar-agenda-event { transition: background-color .16s ease, border-color .16s ease, color .16s ease; }
.schedule-calendar, .source-table-wrap, .favorite-card, .favorite-manager, .metric-card, .stat, .filters, .empty { border-radius: var(--panel-radius); }
.schedule-calendar, .source-table-wrap { box-shadow: var(--panel-shadow); }
.stat, .metric-card { min-width: 0; border-top-color: var(--t-border); }
.metric-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); }
.stat b, .metric-card strong { color: var(--t-foreground); font-variant-numeric: tabular-nums; }
.empty { padding: clamp(16px, 2.5vw, 28px); }
.calendar-month-label input { min-width: 0; }
.calendar-day-number { min-width: 0; }
.calendar-day-hint { display: none; }
.calendar-grid { grid-auto-rows: minmax(9rem, auto); }
.next-match-line { display: flex; flex-wrap: wrap; column-gap: .65rem; row-gap: .15rem; }
.next-match-line time { white-space: nowrap; }
.leaderboard-table th:first-child, .leaderboard-table td:first-child {
  min-width: 0;
  width: 1%;
  padding-inline: 10px;
  white-space: nowrap;
}
.profile-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.search-record { position: relative; display: flex; flex-direction: column; min-width: 0; }
.search-record:has(.favorite-pin) .explore-result { padding-inline-end: 60px; }
.search-record .favorite-pin { position: absolute; inset-block-start: 8px; inset-inline-end: 8px; }
/* Icon-only buttons beside a record's name: the favorite pin and the share button look alike. */
.favorite-pin, .icon-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  flex: none;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--t-foreground);
}
.favorite-pin:hover, .favorite-pin[aria-pressed="true"], .icon-button:hover {
  color: var(--t-link);
}
/* An empty pin message takes no room, so icons beside the pin sit evenly. */
.favorite-pin-note:empty { display: none; }
.favorite-record-link {
  display: inline-grid;
  grid-template-columns: minmax(0, auto) auto;
  align-items: center;
  vertical-align: baseline;
  max-inline-size: 100%;
  min-inline-size: 0;
  overflow-wrap: anywhere;
}
.favorite-record-link .favorite-pin { min-width: 32px; min-height: 32px; width: 32px; height: 32px; }
.favorite-record-link .favorite-pin svg { width: 16px; height: 16px; }
.favorite-record-link .favorite-pin-note { grid-column: 1 / -1; }
.favorite-manager .league-search-form { margin-inline: 0; }
/* Schedule summary tiles */
.match-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.match-stats .stat { padding: clamp(10px, 1.6vw, 20px); }
.match-stats .stat b { font-size: clamp(1.4rem, 1.1rem + 1.1vw, 2rem); }
@media (max-width: 1180px) {
  .app-header .header-inner { grid-template-columns: auto minmax(0, 1fr) auto; }
  .header-search { grid-row: 2; grid-column: 1 / -1; }
  .theme-picker { grid-row: 1; }
}
@media (max-width: 800px) {
  .import-notice { bottom: calc(74px + env(safe-area-inset-bottom)); }
  .app-shell { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .league-rail, .main-nav { display: none; }
  .app-header .header-inner { grid-template-columns: minmax(0, 1fr) max-content auto; }
  .mobile-more { display: block; grid-column: 3; grid-row: 1; }
  .mobile-more a { display: grid; justify-items: center; align-content: center; min-width: 44px; min-height: 44px; border-radius: var(--radius-md); color: var(--t-muted); font-size: var(--fs-sm); }
  .mobile-section-nav { display: block; }
  .app-main { grid-column: 1; }
  .theme-picker { grid-column: 2; grid-row: 1; }
  .header-search input { font-size: 16px; }
  /* The scope switcher sits between the brand row and the search box on phones. */
  .scope-switch { grid-row: 2; grid-column: 1 / -1; }
  .header-search { grid-row: 3; }
  .mobile-bottom-nav {
    position: fixed;
    z-index: 900;
    inset: auto 0 0;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(0, 1fr);
    gap: 2px;
    padding: 6px max(8px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    background: var(--t-panel);
    border-top: 1px solid var(--t-border);
    box-shadow: 0 -4px 16px var(--t-glass-shadow);
  }
  .mobile-bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start; /* icons line up even when one label ("My Leagues") wraps to two lines */
    gap: 3px;
    min-height: 50px;
    padding: 5px 2px;
    border-radius: var(--radius-md);
    color: var(--t-muted);
    font-weight: 650;
    text-align: center;
    text-decoration: none;
  }
  .mobile-bottom-nav .nav-label { max-width: 100%; line-height: 1.2; white-space: normal; }
}
@media (max-width: 480px) {
  .app-header .header-inner { column-gap: 8px; }
  .app-header .brand { gap: 6px; }
  .app-header .brand-mark { inline-size: 25px; block-size: 25px; }
}
@media (max-width: 480px) {
  .calendar-event, .calendar-more, .calendar-event-hint { display: none; }
  .calendar-day-hint { display: inline; }
  .calendar-grid { grid-auto-rows: minmax(52px, auto); }
  .calendar-day { display: grid; min-height: 52px; }
  .calendar-day-number { flex-direction: column; justify-content: start; gap: 2px; padding-block: 4px; }
  .calendar-day-number:focus-visible { outline-offset: -2px; }
  .calendar-agenda-heading { flex-wrap: wrap; }
}
