/*
 * Skipper — hand-authored layout styles.
 * Built on top of tokens.css; do not hard-code colors here.
 */

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

body {
  font-family: var(--md-sys-typescale-font-family);
  background: var(--md-sys-color-background);
  color: var(--md-sys-color-on-background);
  min-height: 100dvh;
}

/* ── Header ────────────────────────────────────────────────────────────────── */

.sk-header {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.sk-header__title {
  font-size: 20px;
  font-weight: 600;
  flex: 1;
}

.sk-header__meta {
  font-size: 14px;
  opacity: 0.85;
}

/* ── Preview banner ────────────────────────────────────────────────────────── */

.sk-banner {
  background: var(--md-sys-color-tertiary-container);
  color: var(--md-sys-color-on-tertiary-container);
  padding: 8px 20px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-align: center;
  display: none;
}

.sk-banner--visible { display: block; }

/* ── Inning nav (coach only) ────────────────────────────────────────────────── */

.sk-inning-nav {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 6px 20px;
  background: var(--md-sys-color-surface-container-high);
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.sk-inning-nav--visible { display: flex; }

.sk-inning-nav__btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--md-sys-color-primary);
  font-size: 18px;
  padding: 4px 10px;
  border-radius: 4px;
  line-height: 1;
}

.sk-inning-nav__btn:disabled {
  color: var(--md-sys-color-outline);
  cursor: default;
}

.sk-inning-nav__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--md-sys-color-on-surface);
  min-width: 120px;
  text-align: center;
}

/* ── Split layout ──────────────────────────────────────────────────────────── */

.sk-split {
  display: grid;
  grid-template-columns: minmax(160px, 220px) 1fr;
  gap: 0;
  height: calc(100dvh - 56px);  /* subtract header */
}

/* On narrow screens: defense on top, batting below */
@media (max-width: 640px) {
  .sk-split {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    height: auto;
  }
  .sk-panel--defense { order: 1; }
  .sk-panel--batting { order: 2; }

  /* Defense panel: natural height (field drives it), no clipping */
  .sk-panel--defense,
  .sk-field-wrap {
    overflow: visible;
  }
  .sk-field-wrap { flex: none; }

  /*
   * Switch field from height-based to width-based sizing.
   * width: 100% fills the panel; aspect-ratio derives the height.
   * The page scrolls vertically past the field to the batting order below.
   */
  .sk-field {
    width: 100%;
    height: auto;
  }

  /* Batting panel: content height, page scroll handles overflow */
  .sk-panel--batting { overflow: visible; }
  .sk-panel__body    { overflow: visible; flex: none; }
}

/* ── Panel ─────────────────────────────────────────────────────────────────── */

.sk-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--md-sys-color-outline-variant);
  position: relative;
}

.sk-panel:last-child { border-right: none; }

.sk-panel__heading {
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface-variant);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 8px 16px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.sk-panel__body {
  overflow-y: auto;
  flex: 1;
  padding: 8px 0;
}

/* ── Row ────────────────────────────────────────────────────────────────────  */

.sk-row {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  gap: 12px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.sk-row:last-child { border-bottom: none; }

.sk-row__slot {
  font-size: 22px;
  font-weight: 700;
  color: var(--md-sys-color-primary);
  min-width: 32px;
  text-align: right;
}

.sk-row__pos {
  font-size: 14px;
  font-weight: 700;
  color: var(--md-sys-color-primary);
  min-width: 32px;
}

.sk-row__name {
  font-size: 16px;
  font-weight: 500;
  flex: 1;
}

.sk-row__jersey {
  font-size: 14px;
  color: var(--md-sys-color-on-surface-variant);
  min-width: 36px;
  text-align: right;
}

/* Bench rows */
.sk-row--bench .sk-row__name {
  color: var(--md-sys-color-on-surface-variant);
}

/* ── Section divider ────────────────────────────────────────────────────────  */

.sk-divider {
  background: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface-variant);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 6px 16px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

/* ── State screens ──────────────────────────────────────────────────────────  */

.sk-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 60dvh;
  padding: 32px;
  text-align: center;
  color: var(--md-sys-color-on-surface-variant);
}

.sk-state__icon {
  font-family: 'Material Symbols Outlined';
  font-size: 48px;
  color: var(--md-sys-color-outline);
}

.sk-state__title {
  font-size: 20px;
  font-weight: 500;
  color: var(--md-sys-color-on-background);
}

.sk-state__sub {
  font-size: 14px;
}

/* ── Baseball field ─────────────────────────────────────────────────────────  */

/* Wrapper: fills remaining panel height, centres the field horizontally */
.sk-field-wrap {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  justify-content: center;
}

/*
 * Field: sized by height (fills the panel), width derived from the SVG aspect
 * ratio (400 × 350). max-width: 100% clamps it if the panel is narrow.
 */
.sk-field {
  position: relative;
  height: 100%;
  aspect-ratio: 400 / 350;
  max-width: 100%;
  overflow: hidden;
  flex-shrink: 0;
}

/* Large ghost inning number — watermark over the field grass */
.sk-field__inning-bg {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(120px, 45cqw, 220px);
  font-weight: 900;
  color: #fff;
  opacity: 0.2;
  pointer-events: none;
  user-select: none;
  line-height: 1;
  z-index: 0;
}

/* SVG covers the full field div and acts as the background */
.sk-field__svg {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Player chip */
.sk-field__player {
  position: absolute;
  transform: translate(-50%, -50%);
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  border-radius: 16px;
  padding: 2px 7px;
  text-align: center;
  white-space: nowrap;
  box-shadow: 0 1px 4px rgba(0,0,0,0.5);
  line-height: 1.3;
  min-width: 52px;
  max-width: 88px;
  z-index: 1;
}

.sk-field__pos {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.05em;
  opacity: 0.7;
  display: block;
}

.sk-field__name {
  font-size: 11px;
  font-weight: 600;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sk-field__jersey {
  font-size: 9px;
  font-weight: 500;
  opacity: 0.7;
  display: block;
}

/* Bench names overlaid in the bottom-left corner of the field */
.sk-bench-overlay {
  position: absolute;
  bottom: 10px;
  left: 10px;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 8px;
  padding: 5px 10px 6px;
  z-index: 2;
}

.sk-bench-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
  margin-bottom: 2px;
}

.sk-bench-name {
  font-size: 11px;
  font-weight: 500;
  color: #fff;
  white-space: nowrap;
  line-height: 1.5;
}

/* ── Share page specifics ───────────────────────────────────────────────────  */

.sk-share-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  padding: 20px;
  max-width: 960px;
  margin: 0 auto;
}

.sk-card {
  background: var(--md-sys-color-surface);
  border: 1px solid var(--md-sys-color-outline-variant);
  border-radius: var(--md-sys-shape-corner-medium);
  overflow: hidden;
}

.sk-card__header {
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 8px 14px;
}
