/* Play Designer — team playbook viewer. Night-game palette from the app:
   navy surfaces, turf green, chalk white, coach orange as the accent. */

:root {
  color-scheme: light dark;
  --navy: #0b1422;
  --navy-raised: #131e30;
  --orange: #f56e1a;
  --orange-press: #d95d10;
  --orange-ink: #b84a08;
  --orange-wash: rgba(245, 110, 26, 0.13);
  --turf: #338045;
  --gold: #ffcc1f;
  --bg: #f1f2f6;
  --surface: #ffffff;
  --text: #0b1422;
  --muted: #5b6474;
  --hairline: rgba(11, 20, 34, 0.1);
  --shadow: 0 1px 2px rgba(11, 20, 34, 0.06), 0 3px 10px rgba(11, 20, 34, 0.05);
  --seg-on: #0b1422;
  --seg-on-text: #ffffff;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-round: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --gutter-l: max(16px, env(safe-area-inset-left));
  --gutter-r: max(16px, env(safe-area-inset-right));
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #070c15;
    --surface: #131e30;
    --text: #f5f2eb;
    --muted: #97a1b2;
    --hairline: rgba(255, 255, 255, 0.09);
    --shadow: none;
    --orange-ink: #ff9a5c;
    --orange-wash: rgba(245, 110, 26, 0.18);
    --seg-on: #f5f2eb;
    --seg-on-text: #0b1422;
  }
}

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

[hidden] {
  display: none !important;
}

html {
  background: var(--navy);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 var(--font);
  -webkit-font-smoothing: antialiased;
}

main {
  flex: 1 0 auto;
  width: 100%;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button:disabled {
  cursor: default;
}

:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 2px;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: currentColor;
}

/* ---------------------------------------------------------------- header */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  padding: calc(env(safe-area-inset-top) + 10px) var(--gutter-r) 10px var(--gutter-l);
  background: var(--navy);
  color: #fff;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.07);
}

.mark {
  width: 34px;
  height: 34px;
  flex: none;
  display: block;
}

.titles {
  flex: 1;
  min-width: 0;
}

.titles h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meta {
  margin: 2px 0 0;
  font-size: 13px;
  line-height: 1.25;
  color: rgba(255, 255, 255, 0.64);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meta .fmt {
  color: var(--orange);
  font-weight: 700;
}

[data-view="play"] .titles h1 {
  font-size: 16px;
}

.back {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 1px;
  height: 40px;
  margin-left: -8px;
  padding: 0 10px 0 2px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
}

.back .icon {
  width: 24px;
  height: 24px;
}

.back:active {
  background: rgba(255, 255, 255, 0.1);
}

.counter {
  flex: none;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
  color: rgba(255, 255, 255, 0.8);
  font: 700 14px/1 var(--font-round);
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------- states */

.state {
  max-width: 480px;
  margin: 0 auto;
  padding: 64px 24px 48px;
  text-align: center;
}

.state h2 {
  margin: 0 0 10px;
  font-size: 22px;
  line-height: 1.25;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.state p {
  margin: 0 auto 22px;
  color: var(--muted);
  text-wrap: pretty;
}

.state-icon {
  width: 76px;
  height: 76px;
  margin: 0 auto 20px;
  display: grid;
  place-items: center;
  border-radius: 24px;
  background: var(--orange-wash);
  color: var(--orange);
}

.state-icon .icon {
  width: 38px;
  height: 38px;
}

.spinner {
  width: 34px;
  height: 34px;
  margin: 0 auto 16px;
  border: 3px solid var(--hairline);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.slow {
  font-size: 14px;
  opacity: 0;
  animation: reveal 0.3s ease 6s forwards;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 46px;
  padding: 0 24px;
  border: 0;
  border-radius: 23px;
  background: var(--orange);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
}

.btn:active {
  background: var(--orange-press);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes reveal {
  to {
    opacity: 1;
  }
}

/* ------------------------------------------------------------------ list */

.wrap {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 var(--gutter-r) 0 var(--gutter-l);
}

.list-tools {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 0 14px;
}

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  margin: 0;
  padding: 0 14px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--hairline);
  color: var(--muted);
}

.search:focus-within {
  box-shadow: inset 0 0 0 2px var(--orange);
}

.search input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font: 16px var(--font);
  -webkit-appearance: none;
  appearance: none;
}

.search input::placeholder {
  color: var(--muted);
  opacity: 1;
}

.chips {
  display: flex;
  gap: 7px;
  margin: 0 calc(-1 * var(--gutter-r)) 0 calc(-1 * var(--gutter-l));
  padding: 2px var(--gutter-r) 2px var(--gutter-l);
  overflow-x: auto;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--hairline);
  font-size: 14px;
  font-weight: 600;
}

.chip-count {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.chip[aria-pressed="true"] {
  background: var(--orange);
  box-shadow: none;
  color: #fff;
}

.chip[aria-pressed="true"] .chip-count {
  color: rgba(255, 255, 255, 0.85);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  padding-bottom: 28px;
}

.card {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--hairline), var(--shadow);
  text-align: left;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.card:active {
  transform: scale(0.97);
}

@media (hover: hover) {
  .card:hover {
    box-shadow: 0 0 0 1px var(--hairline), 0 8px 22px rgba(11, 20, 34, 0.14);
  }
}

.thumb {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--turf);
}

.thumb svg {
  display: block;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 8px 10px 9px;
}

.card-num {
  flex: none;
  font: 900 15px/1.25 var(--font-round);
  font-variant-numeric: tabular-nums;
}

.card-name {
  min-width: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.empty {
  margin: 0;
  padding: 48px 16px;
  color: var(--muted);
  text-align: center;
}

/* Coaches with the app can pull the playbook in. Deliberately quiet. */
.import {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 8px 0 32px;
  text-align: center;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  height: 44px;
  padding: 0 20px 0 14px;
  border-radius: 22px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--hairline), var(--shadow);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.btn-secondary .icon {
  width: 24px;
  height: 24px;
}

.btn-secondary:active {
  background: var(--hairline);
}

.import-note {
  max-width: 30em;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  text-wrap: balance;
}

.import-note a {
  color: var(--orange-ink);
  font-weight: 600;
  text-decoration: none;
}

/* ------------------------------------------------------------------ play */

.play-view {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
}

.play-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px var(--gutter-r) 12px var(--gutter-l);
}

.play-num {
  flex: none;
  display: grid;
  place-items: center;
  min-width: 46px;
  height: 46px;
  padding: 0 8px;
  border-radius: 13px;
  background: var(--orange);
  color: #fff;
  font: 900 22px/1 var(--font-round);
  font-variant-numeric: tabular-nums;
}

.play-titles {
  min-width: 0;
}

.play-titles h2 {
  margin: 0;
  font-size: 21px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: -0.015em;
  overflow-wrap: anywhere;
}

.play-titles h2:focus {
  outline: none;
}

.play-sub {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.3;
}

.stage {
  position: relative;
  overflow: hidden;
  background: var(--turf);
  cursor: pointer;
  touch-action: pan-y pinch-zoom;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.stage svg {
  display: block;
  width: 100%;
  height: 100%;
}

.stage svg.enter-next {
  animation: enter-next 0.22s ease-out;
}

.stage svg.enter-prev {
  animation: enter-prev 0.22s ease-out;
}

.stage svg.bump-next {
  animation: bump-next 0.28s ease-out;
}

.stage svg.bump-prev {
  animation: bump-prev 0.28s ease-out;
}

@keyframes enter-next {
  from {
    transform: translateX(32px);
    opacity: 0.2;
  }
}

@keyframes enter-prev {
  from {
    transform: translateX(-32px);
    opacity: 0.2;
  }
}

@keyframes bump-next {
  40% {
    transform: translateX(-14px);
  }
}

@keyframes bump-prev {
  40% {
    transform: translateX(14px);
  }
}

.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px var(--gutter-r) 12px var(--gutter-l);
}

.round {
  flex: none;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--hairline);
  color: var(--text);
}

.round .icon {
  width: 24px;
  height: 24px;
}

.round:disabled {
  opacity: 0.35;
}

.round:not(:disabled):active {
  background: var(--hairline);
}

.animate {
  flex: 1;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 46px;
  padding: 0 12px;
  border: 0;
  border-radius: 23px;
  background: var(--orange);
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 3px 10px rgba(245, 110, 26, 0.3);
}

.animate:active {
  background: var(--orange-press);
}

.animate .icon {
  width: 22px;
  height: 22px;
}

.speed {
  flex: none;
  display: flex;
  padding: 3px;
  border-radius: 23px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--hairline);
}

.speed button {
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 20px;
  background: transparent;
  color: var(--muted);
  font: 800 14px/1 var(--font-round);
}

.speed button[aria-pressed="true"] {
  background: var(--seg-on);
  color: var(--seg-on-text);
}

.details {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 2px var(--gutter-r) 32px var(--gutter-l);
}

.legend {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.legend .icon {
  width: 18px;
  height: 18px;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  padding: 5px 11px;
  border-radius: 999px;
  background: var(--orange-wash);
  color: var(--orange-ink);
  font-size: 13px;
  font-weight: 700;
}

.notes {
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--hairline);
}

.notes h3 {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.notes p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* ---------------------------------------------------------------- footer */

.foot {
  padding: 22px var(--gutter-r) calc(22px + env(safe-area-inset-bottom)) var(--gutter-l);
  background: var(--navy);
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
}

.foot a {
  color: inherit;
  text-decoration: none;
}

.foot strong {
  color: var(--orange);
}

/* Two tidy lines on phones instead of a ragged wrap. */
@media (max-width: 519px) {
  .foot .dash {
    display: none;
  }

  .foot .tagline {
    display: block;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.55);
  }

  .foot .tagline::first-letter {
    text-transform: uppercase;
  }
}

@media (hover: hover) {
  .foot a:hover {
    color: #fff;
  }
}

/* ---------------------------------------------------------------- larger */

@media (min-width: 720px) {
  /* Line the header up with the centered content below it. */
  .topbar {
    padding-left: max(var(--gutter-l), calc(50% - 544px));
    padding-right: max(var(--gutter-r), calc(50% - 544px));
  }

  [data-view="play"] .topbar {
    padding-left: max(var(--gutter-l), calc(50% - 434px));
    padding-right: max(var(--gutter-r), calc(50% - 434px));
  }

  .animate {
    flex: 0 1 240px;
  }

  #prev {
    margin-right: auto;
  }

  #next {
    margin-left: auto;
  }

  .list-tools {
    flex-direction: row-reverse;
    align-items: center;
    padding-top: 20px;
  }

  .search {
    flex: none;
    width: 320px;
  }

  .chips {
    flex: 1;
    margin: 0;
    padding: 2px 0;
  }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 16px;
  }

  .play-head {
    padding-top: 22px;
  }

  .stage {
    margin: 0 var(--gutter-r) 0 var(--gutter-l);
    border-radius: 16px;
  }

  .controls {
    padding-top: 14px;
  }
}

@media (max-width: 359px) {
  .controls {
    gap: 6px;
  }

  .round {
    width: 40px;
    height: 40px;
  }

  .speed button {
    width: 33px;
  }

  .animate {
    font-size: 15px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .stage svg,
  .card {
    animation: none !important;
    transition: none !important;
  }
}
