/* ==========================================================================
   CSS custom properties — edit these to theme the dashboard
   ========================================================================== */

:root {
  /* Typography */
  --font-primary: "mlb_primary", sans-serif;
  --font-weight-medium: 500;

  /* Base palette */
  --color-bg: #fff;
  --color-text: #000;

  /* Header bar typography */
  --headbar-font-size: clamp(0.85rem, 3vw, 3rem);
  --headbar-letter-spacing: 0.05em;

  /* Win-percentage display */
  --winpct-font-size: clamp(4rem, 30vw, 20rem);

  /* Decorative dot */
  --dot-opacity: 0.4;

  /* Details / footer bar typography */
  --moredetails-font-size: clamp(0.85rem, 3vw, 3rem);
  --moredetails-letter-spacing: 0.08em;

  /* Drawer */
  --drawer-transition: 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ==========================================================================
   Base reset
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-primary);
}

html {
  /* Match header brand colour so overscroll (rubber-band / elastic scroll) areas
     show the brand background instead of white/grey.
     NOTE: CSS custom properties only inherit downward, so --color-brand-bg
     (declared on body) is not available here.  The literal #134a8e matches the
     --color-brand-bg fallback value used throughout the rest of the app. */
  background-color: #134a8e;
}

body {
  background-color: var(--color-bg);
  color: var(--color-text);

  /* Team brand colours — resolved from the dynamically loaded brand CSS.
     Fallback values apply until the brand stylesheet is available.
     The brand CSS is scoped to :root .brand--team-{id}, which matches this
     element once applyTeamBranding() adds the brand class to <body>.
     Declaring these here (not at :root) lets the --mlb-1-brand-* variables
     resolve correctly, because CSS custom properties only inherit downward. */
  --color-brand-bg:             var(--mlb-1-brand-background-main,    #134a8e);
  --color-brand-bg-support:     var(--mlb-1-brand-background-support, #0d3b7a);
  --color-brand-bg-inverse:     var(--mlb-1-brand-background-inverse, #ffffff);
  --color-brand-text:           var(--mlb-1-brand-text-primary,       #ffffff);
  --color-brand-text-secondary: var(--mlb-1-brand-text-secondary,     rgba(255, 255, 255, 0.8));
  --color-brand-text-inverse:   var(--mlb-1-brand-text-inverse,       #134a8e);
  --color-brand-icon:           var(--mlb-1-brand-icon-primary,       #ffffff);
  --color-brand-icon-inverse:   var(--mlb-1-brand-icon-inverse,       #134a8e);
  --color-brand-border:         var(--mlb-1-brand-border-decorative,  #0d3b7a);
  --color-brand-border-contrast: var(--mlb-1-brand-border-contrast,   #4c5a83);
  --color-brand-border-inverse: var(--mlb-1-brand-border-inverse,     #ffffff);
  --color-brand-decorative-1:   var(--mlb-1-brand-decorative-color-1, #134a8e);
  --color-brand-decorative-2:   var(--mlb-1-brand-decorative-color-2, #8fbce6);
  --color-brand-surface:        var(--mlb-1-brand-surface,            #134a8e);
}

main {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* ==========================================================================
   Header bar
   ========================================================================== */

.headbar {
  flex-shrink: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem 16px;
  font-size: var(--headbar-font-size);
  font-weight: var(--font-weight-medium);
  letter-spacing: var(--headbar-letter-spacing);
  text-transform: uppercase;
  color: var(--color-brand-text);
  background-color: var(--color-brand-bg);
  box-shadow: rgb(0, 0, 0) 1px 0px 5px;
}

#team-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  cursor: pointer;
  opacity: 0.8;
}
#team-btn:hover {
  opacity: 1;
}

#locate-btn {
  display: none;
  position: absolute;
  right: 16px;
  background: none;
  border: none;
  padding: 0;
  font-size: var(--headbar-font-size);
  color: inherit;
  cursor: pointer;
  opacity: 0.8;
  line-height: 1;
}
#locate-btn:hover,
#locate-btn:focus-visible {
  opacity: 1;
}
#locate-btn:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 4px;
}

/* ==========================================================================
   Win percentage block
   ========================================================================== */

.winper {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

#win-pct {
  font-size: var(--winpct-font-size);
  line-height: 1;
  color: var(--color-text);
}

/* Styled decimal dot inside win percentage */
.dot {
  opacity: var(--dot-opacity);
  font-family: var(--font-primary);
}

/* ==========================================================================
   More details bar (W / L / Runs) — full-width pinned footer
   ========================================================================== */

.moredetails {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem 16px;
  font-size: var(--moredetails-font-size);
  font-weight: var(--font-weight-medium);
  letter-spacing: var(--moredetails-letter-spacing);
  text-transform: uppercase;
  color: var(--color-brand-text-secondary);
  background-color: var(--color-brand-bg);
  box-shadow: rgb(0, 0, 0) 1px 0px 5px;
  cursor: pointer;
  transition: color 0.2s ease;
}

.moredetails:hover {
  color: var(--color-brand-text);
}

/* ==========================================================================
   Drawer Backdrop
   ========================================================================== */

.drawer-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 999;
}

.drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

/* ==========================================================================
   Stats Drawer
   ========================================================================== */

.drawer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: var(--color-brand-bg-inverse);
  border-top: 2px solid var(--color-brand-border);
  border-radius: 20px 20px 0 0;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transform: translateY(100%);
  transition: transform var(--drawer-transition);
  box-shadow: 0 -2px 20px rgba(0, 0, 0, 0.15);
  overflow: hidden;
}

.drawer.open {
  transform: translateY(0);
}

.drawer-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.drawer-header h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: var(--font-weight-medium);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--color-brand-text-inverse);
}

.drawer-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--color-brand-text-inverse);
  cursor: pointer;
  padding: 0.5rem;
  opacity: 0.7;
  transition: opacity 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.drawer-close:hover {
  opacity: 1;
}

.drawer-close::before {
  content: '✕';
}

.drawer-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
}

/* ==========================================================================
   Stats Table
   ========================================================================== */

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.stats-table tbody {
  display: block;
}

.stats-table tr {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.875rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.stats-table tr:last-child {
  border-bottom: none;
}

.stats-table td {
  padding: 0;
  text-align: left;
}

.stats-table td:first-child {
  font-weight: var(--font-weight-medium);
  color: var(--color-brand-text-inverse);
  flex: 1;
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 0.03em;
}

.stats-table td:last-child {
  font-weight: var(--font-weight-medium);
  color: var(--color-brand-surface);
  font-size: 1.1rem;
  text-align: right;
}

/* ==========================================================================
   Mobile responsiveness
   ========================================================================== */

@media (max-width: 480px) {
  .drawer {
    max-height: 85vh;
  }

  .drawer-header h2 {
    font-size: 1.25rem;
  }

  .drawer-content {
    padding: 1rem;
  }

  .stats-table {
    font-size: 0.9rem;
  }

  .stats-table td:last-child {
    font-size: 1rem;
  }
}

/* ==========================================================================
   Reduced-motion — disable springy drawer animation
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  :root {
    --drawer-transition: 0s linear;
  }
}
