/* www/style.css */

/* ===== Modern UI base ===== */
:root{
  --bg: #0b0f19;
  --panel: rgba(255,255,255,0.06);
  --panel2: rgba(255,255,255,0.08);
  --border: rgba(255,255,255,0.10);
  --text: rgba(255,255,255,0.92);
  --muted: rgba(255,255,255,0.65);
  --muted2: rgba(255,255,255,0.5);
  --shadow: 0 18px 45px rgba(0,0,0,0.45);
  --radius: 16px;
  --radius2: 22px;

  /* Spacing knobs */
  --pad-app: 22px;
  --pad-panel: 14px;
  --gap: 14px;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
  background:
    radial-gradient(1200px 700px at 20% -10%, rgba(66, 99, 235, 0.35), transparent 55%),
    radial-gradient(900px 600px at 95% 0%, rgba(26, 178, 255, 0.25), transparent 55%),
    radial-gradient(900px 700px at 10% 110%, rgba(184, 72, 255, 0.18), transparent 60%),
    var(--bg);
  color: var(--text);
}

/* ============================
   FIX: Prevent horizontal page shift (mobile)
   ============================ */

/* Kill horizontal overflow at the page level */
html, body{
  overflow-x: hidden;
  width: 100%;
}

/* Prevent accidental horizontal pan inside the filters sheet + app */
.app,
.controls,
.panel{
  max-width: 100%;
  overflow-x: hidden;
}

/* Ensure form controls never exceed container width */
input[type="text"], input[type="date"], select{
  max-width: 100%;
}

/* iOS: reduce sideways panning while allowing vertical scroll */
@media (max-width: 640px){
  .controls{
    overscroll-behavior: contain;
    touch-action: pan-y;
  }
}


a{ color:inherit; text-decoration:none; }
a:hover{ text-decoration:none; }

.app{
  max-width: 1180px;
  margin: 0 auto;
  padding: var(--pad-app) 16px 36px;
}

/* ===== Top bar ===== */
.topbar{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.brand h1{
  margin:0;
  font-size: 1.25rem;
  letter-spacing: 0.2px;
}
.brand .sub{
  margin-top:6px;
  color: var(--muted);
  font-size: 0.9rem;
}

.meta{
  text-align:right;
  display:flex;
  flex-direction:column;
  gap: 6px;
}
#status{
  font-size: 0.95rem;
  color: var(--muted);
}
#updated{
  font-size: 0.85rem;
  color: var(--muted2);
}

/* ===== Main layout ===== */
.main{
  display:grid;
  grid-template-columns: 360px 1fr;
  gap: var(--gap);
  align-items:start;
}

.panel{
  background: linear-gradient(180deg, var(--panel2), var(--panel));
  border: 1px solid var(--border);
  border-radius: var(--radius2);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.controls{
  padding: var(--pad-panel);
  position: sticky;
  top: 14px;
}

.list{
  padding: 12px;
}

/* ===== Form controls ===== */
label{
  display:block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 6px;
}

input[type="text"], input[type="date"], select{
  width:100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  outline:none;
}
input[type="text"]::placeholder{ color: rgba(255,255,255,0.45); }
select option{ color:#111; }

.stack{ display:flex; flex-direction:column; gap: 10px; }
.grid2{ display:grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3{ display:grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

.btn{
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.08);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  cursor:pointer;
  transition: transform .08s ease, background .15s ease;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap: 8px;
}
.btn:hover{ background: rgba(255,255,255,0.12); }
.btn:active{ transform: scale(0.98); }

.btn.primary{
  background: rgba(66,99,235,0.35);
  border-color: rgba(66,99,235,0.45);
}
.btn.primary:hover{ background: rgba(66,99,235,0.42); }

.checkrow{
  display:flex;
  align-items:center;
  gap: 10px;
  padding: 10px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,0.05);
}
.checkrow input{ transform: scale(1.05); }

.muted{ color: var(--muted); }

/* ===== Advanced (details) ===== */
.advanced{
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 14px;
  background: rgba(255,255,255,0.04);
  padding: 10px;
}
.advanced > summary{
  cursor: pointer;
  list-style: none;
  user-select: none;
  color: var(--text);
  font-weight: 650;
  letter-spacing: 0.2px;
}
.advanced > summary::-webkit-details-marker{ display:none; }
.advanced > summary::after{
  content: "▾";
  float: right;
  opacity: 0.75;
}
.advanced[open] > summary::after{ content: "▴"; }
.advanced-body{ margin-top: 10px; }

/* ===== Games list ===== */
#gamesList{
  list-style:none;
  padding:0;
  margin:0;
  display:flex;
  flex-direction:column;
  gap: 10px;
}

.game{
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.05);
  border-radius: var(--radius);
  padding: 12px 12px;
  transition: transform .08s ease, background .15s ease;
  position: relative;
  overflow: hidden;
}

.game:hover{
  background: rgba(255,255,255,0.08);
  transform: translateY(-1px);
}

.score{
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  letter-spacing: 0.2px;
  line-height: 1.1;
  color: rgba(255,255,255,0.95);
}

button{ font: inherit; }

button[data-fav]{
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.07);
  color: var(--text);
  cursor:pointer;
}
button[data-fav]:hover{ background: rgba(255,255,255,0.12); }

.team-link{
  border: none;
  background: transparent;
  color: var(--text);
  padding: 0;
  cursor: pointer;
}
.team-link strong{ font-weight: 700; }
.team-link:hover{ text-decoration: underline; }

.ranked-matchup{
  outline: 1px solid rgba(66,99,235,0.35);
  box-shadow: 0 0 0 4px rgba(66,99,235,0.08) inset;
}

.rank-badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  height: 22px;
  padding: 0 8px;
  margin-right: 6px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.85);
  font-size: 0.8rem;
}
.rank-badge.top5{
  background: rgba(255, 200, 0, 0.18);
  border-color: rgba(255, 200, 0, 0.28);
}

/* Divider */
.games-divider{
  padding: 10px 6px;
  margin-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.14);
  font-size: 0.78rem;
  opacity: 0.65;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

/* ===== Status line ===== */
.game .js-status{
  margin-top: 6px;
  font-size: 0.85rem;
  line-height: 1.25;
  opacity: 0.9;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  display:flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* Status badges (LIVE / FINAL) */
.status-badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.07);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.95;
}
.status-badge.live{
  border-color: rgba(66,99,235,0.45);
  background: rgba(66,99,235,0.18);
}
.status-badge.final{
  border-color: rgba(255,255,255,0.22);
  background: rgba(255,255,255,0.10);
}

/* ===== LIVE pulse ===== */
.game.is-live::before{
  content:"";
  position:absolute;
  inset:0;
  border-radius: inherit;
  pointer-events:none;
  background: rgba(255,255,255,0.08);
  opacity: 0.18;
  animation: livePulse 2.8s ease-in-out infinite;
}

@keyframes livePulse{
  0%, 100% { opacity: 0.12; }
  50%      { opacity: 0.28; }
}

/* Close games */
.game.is-close .score{
  font-weight: 800;
}

/* ===== Drawer ===== */
.drawer{
  position: fixed;
  right: 18px;
  top: 18px;
  width: min(430px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  overflow:auto;
  z-index: 50;
  border-radius: 22px;
  padding: 14px;
  background: linear-gradient(180deg, rgba(255,255,255,0.10), rgba(255,255,255,0.06));
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: 0 22px 60px rgba(0,0,0,0.55);
  backdrop-filter: blur(16px);

  will-change: transform;
  transition: transform 180ms ease;
}

.drawer.dragging{
  transition: none !important;
}

.hidden{ display:none !important; }

.drawer-header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap: 10px;
  margin-bottom: 10px;
}
#drawerTitle{
  font-size: 1.05rem;
  margin: 0;
}
#drawerClose{
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.08);
  color: var(--text);
  border-radius: 12px;
  padding: 8px 10px;
  cursor:pointer;
}

/* Drawer line layout */
.drawer .line{
  display: grid;
  grid-template-columns: 110px 1fr;
  column-gap: 12px;
  row-gap: 6px;
  margin: 6px 0;
}
.drawer .line > span:first-child{
  opacity: 0.85;
  white-space: nowrap;
}
.drawer .line > span:last-child{
  min-width: 0;
  word-break: break-word;
}
.drawer .line button{
  margin-left: 6px;
  max-width: 100%;
}

/* Mobile sheet header (hidden on desktop) */
.sheet-head{ display:none; }

/* Mobile bar container (normal flow on desktop; fixed on mobile) */
.mobilebar-in-controls{
  display:grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

/* Pills */
.pill{
  display:inline-flex;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.07);
  font-size: 0.8rem;
}

/* ============================
   FIX: Card & Drawer Text Spacing
   ============================ */
.row{
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.row > .row{
  align-items: center;
  gap: 10px;
}
.game .row > div:first-child{
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Team drawer game rows (prevent overlap) */
#teamGamesList .line{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  margin: 0;
}
#teamGamesList .line > span:first-child{
  flex: 1 1 auto;
  min-width: 0;
  white-space: normal;
  word-break: break-word;
}
#teamGamesList .line > span:last-child{
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
#teamGamesList button{
  padding: 6px 10px;
  border-radius: 10px;
}
#teamGamesList strong{
  display: inline-block;
  min-width: 62px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* --- JS-driven UI state helpers --- */
#updated.updating { opacity: 0.6; }
.score-updated { filter: brightness(1.25); }

.quick-date-active { outline: 2px solid rgba(255,255,255,0.25); }
.quick-date-disabled { opacity: 0.5; pointer-events: none; }

/* ===== Responsive ===== */
@media (max-width: 980px){
  .main{ grid-template-columns: 1fr; }
  .controls{ position: static; }
}

@media (max-width: 640px){
  :root{
    --pad-app: 14px;
    --pad-panel: 12px;
    --gap: 10px;

    /* reserve space for the fixed bottom bar */
    --mobilebar-h: 74px;
    --mobilebar-gap: 12px;
  }

  .app{
    padding: var(--pad-app) 12px calc(var(--mobilebar-h) + var(--mobilebar-gap) + env(safe-area-inset-bottom));
  }

  .topbar{
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .brand h1{ font-size: 1.1rem; }
  .brand .sub{ display:none; }
  .meta{ text-align:left; width: 100%; }

  .grid2{ grid-template-columns: 1fr; }
  .grid3{ grid-template-columns: 1fr; }

  /* Controls -> bottom sheet */
  .controls{
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 10px;
    top: auto;
    z-index: 80;

    max-height: 82vh;
    overflow: auto;

    transform: translateY(calc(100% + 14px));
    transition: transform 180ms ease;
    border-radius: 18px;
    padding-bottom: 18px;
  }

  #filtersSheet:target{
    transform: translateY(0);
  }

  .sheet-head{
    display:flex;
    align-items:center;
    justify-content:space-between;
    gap: 10px;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.10);
  }
  .sheet-title{
    font-weight: 750;
    letter-spacing: 0.2px;
  }

  .mobilebar-in-controls{
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    z-index: 70;

    padding: 10px;
    border-radius: 18px;

    background: linear-gradient(180deg, rgba(255,255,255,0.10), rgba(255,255,255,0.06));
    border: 1px solid rgba(255,255,255,0.14);
    box-shadow: 0 18px 45px rgba(0,0,0,0.55);
    backdrop-filter: blur(16px);
  }
  .mobilebar-in-controls .btn{
    padding: 12px 10px;
  }

  .advanced:not([open]) .advanced-body{ display:none; }

  .game:hover{ transform:none; }

  .drawer{
    left: 10px;
    right: 10px;
    top: auto;
    bottom: calc(var(--mobilebar-h) + var(--mobilebar-gap) + env(safe-area-inset-bottom));
    width: auto;
    max-height: calc(80vh - var(--mobilebar-h));
    border-radius: 18px;
    z-index: 75;
  }

  .game{
    padding: 12px 12px;
    border-radius: 18px;
    border-color: rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.045);
    opacity: 0.90;
    filter: saturate(0.92);
  }

  .team-link{
    font-size: 0.98rem;
    line-height: 1.25rem;
  }

  .score{
    font-size: 1.05rem;
    font-weight: 750;
  }

  .game > .row{ gap: 10px; }
  .game .row > .row{
    align-items: center !important;
    justify-content: space-between;
  }

  .js-fav{
    width: 44px;
    height: 44px;
    border-radius: 14px;
    font-size: 22px;
  }

  .game.is-live{
    opacity: 1;
    filter: none;
    border-color: rgba(66,99,235,0.35);
    background: rgba(66,99,235,0.10);
  }

  .ranked-matchup{
    opacity: 0.98;
    filter: saturate(1.02);
  }

  .game.is-close{
    opacity: 1;
    border-color: rgba(255,200,0,0.28);
    background: rgba(255,200,0,0.08);
  }

  .games-divider{ opacity: 0.55; }

  /* Mobile stacked scores: remove dash */
  .game .score{
    display:flex;
    flex-direction:column;
    align-items:flex-end;
    gap: 2px;
    line-height: 1.1;
  }
  .game .score .score-sep{ display:none; }
}

/* Optional: reduce expensive blur where users prefer it */
@media (prefers-reduced-transparency: reduce) {
  .panel,
  .drawer,
  .mobilebar-in-controls {
    backdrop-filter: none;
  }
}

/* ============================
   FIX: Mobile Filters sideways shift (Advanced open)
   iOS horizontal overflow clamp
   ============================ */

@media (max-width: 640px){

  /* Hard clamp the sheet and everything inside it */
  #filtersSheet,
  #filtersSheet *{
    max-width: 100%;
  }

  #filtersSheet{
    overflow-x: hidden;
    overscroll-behavior-x: none;
    touch-action: pan-y;
  }

  /* Flex/grid children must be allowed to shrink */
  #filtersSheet .stack,
  #filtersSheet .grid2,
  #filtersSheet .grid3,
  #filtersSheet .advanced,
  #filtersSheet .advanced-body{
    min-width: 0;
  }

  /* These flex labels are common overflow offenders */
  #filtersSheet .checkrow{
    flex-wrap: wrap;     /* allow text to wrap */
    min-width: 0;
  }
  #filtersSheet .checkrow span{
    min-width: 0;
    white-space: normal; /* allow wrapping */
    overflow-wrap: anywhere;
  }

  /* Buttons can also force overflow if they won't wrap */
  #filtersSheet .btn{
    white-space: normal;
    min-width: 0;
  }

  /* Inputs/selects: make sure they never exceed container */
  #filtersSheet input,
  #filtersSheet select{
    min-width: 0;
    max-width: 100%;
  }
}

/* ============================
   ADD: ESPN Team Logos
   (safe drop-in)
   ============================ */

.team-link{
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.team-logo{
  width: 18px;
  height: 18px;
  object-fit: contain;
  border-radius: 4px;
  background: rgba(255,255,255,0.06);
  flex: 0 0 auto;
}

@media (max-width: 640px){
  .team-logo{ width: 20px; height: 20px; }
}

/* ============================
   iOS Safari input zoom fix
   (Prevents zoom on focus by enforcing >= 16px)
   ============================ */

#filtersSheet input,
#filtersSheet select,
#filtersSheet textarea,
#filtersSheet button {
  font-size: 16px;
}

#teamSearch {
  font-size: 16px;
}

/* ============================
   Team Drawer polish (non-breaking)
   Paste at bottom of style.css
   ============================ */

/* Make drawer "line" rows align consistently (label left, action right) */
#drawer .line{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0;
}

/* Consistent small action buttons inside drawer (fav stars, etc.) */
#drawer button{
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border-radius: 10px;
  padding: 6px 10px;
  line-height: 1;
  cursor: pointer;
}

#drawer button:hover{
  background: rgba(255,255,255,0.10);
}

#drawer button:active{
  transform: translateY(0.5px);
}

/* Notes textarea in the drawer */
#drawer textarea{
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.25);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  resize: vertical;
}

/* Team results list spacing */
#drawer .team-games{
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

#drawer .team-game-row{
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
}

#drawer .team-game-row:hover{
  background: rgba(255,255,255,0.07);
}

#drawer .team-game-main{
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

#drawer .team-game-wl{
  font-weight: 800;
  min-width: 16px;
}

#drawer .team-game-score{
  font-weight: 700;
}

#drawer .team-game-opp{
  color: var(--text);
}

#drawer .team-game-sub{
  margin-top: 4px;
  font-size: 0.9em;
  color: var(--muted);
}

/* Slightly tighten section headings in drawer */
#drawer .section-title{
  font-weight: 800;
  margin-bottom: 6px;
}

/* Replace inline align-items:center on score action row */
.row.row-center{
  align-items: center;
}
/* ============================
   Close game highlight (restore)
   ============================ */

/* Keep existing bold score */
.game.is-close .score{
  font-weight: 800;
}

/* Add a visible but subtle highlight for close LIVE games */
.game.is-live.is-close{
  border-color: rgba(255,255,255,0.22);
  background: rgba(255,255,255,0.08);
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
}

/* Slight emphasis on the status line too */
.game.is-live.is-close .js-status{
  color: rgba(255,255,255,0.86);
}

/* ============================
   Close games (≤ 5) — restore tinted highlight
   Applies when JS adds .is-close
   ============================ */

/* Base: keep score bold for close games */
.game.is-close .score{
  font-weight: 800;
}

/* Close + Live: amber/gold tint like previous UI */
.game.is-live.is-close{
  /* warm tint overlay */
  background: linear-gradient(
    180deg,
    rgba(210, 170, 70, 0.16) 0%,
    rgba(210, 170, 70, 0.10) 55%,
    rgba(0, 0, 0, 0.10) 100%
  );
  border: 1px solid rgba(210, 170, 70, 0.35);
  box-shadow:
    0 12px 30px rgba(0,0,0,0.30),
    inset 0 0 0 1px rgba(210, 170, 70, 0.10);
}

/* Make sure text stays readable */
.game.is-live.is-close .muted{
  color: rgba(255,255,255,0.75);
}

/* Give the LIVE pill a slightly warmer edge on close games */
.game.is-live.is-close .status-badge.live{
  border-color: rgba(210, 170, 70, 0.55);
}

/* Optional: slightly lift the card so it “pops” in the list */
.game.is-live.is-close{
  transform: translateZ(0);
}

/* ============================
   Desktop: ensure close-game tint is not overridden
   (place at VERY bottom of style.css)
   ============================ */

/* Base (all sizes) */
#gamesList .game.is-live.is-close{
  background: linear-gradient(
    180deg,
    rgba(210, 170, 70, 0.16) 0%,
    rgba(210, 170, 70, 0.10) 55%,
    rgba(0, 0, 0, 0.10) 100%
  );
  border: 1px solid rgba(210, 170, 70, 0.35);
  box-shadow:
    0 12px 30px rgba(0,0,0,0.30),
    inset 0 0 0 1px rgba(210, 170, 70, 0.10);
}

/* Desktop-specific reinforcement (if desktop has different card styling rules) */
@media (min-width: 768px){
  #gamesList .game.is-live.is-close{
    background: linear-gradient(
      180deg,
      rgba(210, 170, 70, 0.16) 0%,
      rgba(210, 170, 70, 0.10) 55%,
      rgba(0, 0, 0, 0.10) 100%
    );
    border-color: rgba(210, 170, 70, 0.35);
  }
}



