/* Bill Plant brand tokens + shared screen primitives.
 *
 * Hand-rolled, no build step, no third-party CSS. Mirrors
 * brand-guide.md §2-§5. Keep this file the single source of
 * truth for colour, type, and button shape.
 */

:root {
  /* Primary */
  --bp-red: #E40313;
  --bp-yellow: #FFD200;
  --bp-black: #000000;

  /* Tints */
  --bp-red-50: #F28189;
  --bp-yellow-50: #FFE980;

  /* Secondary */
  --bp-grey: #3C3C3C;
  --bp-grey-50: #9E9E9E;
  --bp-grey-10: #E0E0E0;
  --bp-blue: #87CEEB;
  --bp-green: #50E878;
  --bp-orange: #F5921E;

  /* Gradients */
  --bp-hero-gradient: linear-gradient(45deg, var(--bp-red), var(--bp-orange));

  /* Typography */
  --bp-font: gelica, Karla, Helvetica, Arial, sans-serif;

  /* Sizing — per brand-guide.md §5 */
  --bp-button-height-desktop: 72px;   /* slightly under brand 85 to keep CTA proportionate inside cards */
  --bp-button-height-mobile: 60px;    /* matches brand exactly */
  --bp-radius-pill: 9999px;
  --bp-focus-ring: 0 0 0 3px rgba(228, 3, 19, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: var(--bp-font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  color: var(--bp-black);
  background: #FFFFFF;
}

/* ---------- Layout helpers ---------- */

.bp-hero {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  text-align: center;
  color: #FFFFFF;
  background: var(--bp-hero-gradient);
}

.bp-card {
  background: #FFFFFF;
  color: var(--bp-black);
  border-radius: 24px;
  padding: 2.5rem 2rem;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.18);
  text-align: left;
}

/* ---------- Typography ---------- */

.bp-display {
  font-style: italic;
  font-weight: 700;
  font-size: clamp(2rem, 5vw, 3.25rem);
  line-height: 1.05;
  margin: 0 0 0.75rem 0;
  letter-spacing: -0.01em;
}

.bp-eyebrow {
  display: inline-block;
  background: var(--bp-yellow);
  color: var(--bp-black);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.8rem;
  padding: 0.45rem 1rem;
  border-radius: var(--bp-radius-pill);
  margin-bottom: 1.5rem;
}

.bp-lede {
  font-size: clamp(1rem, 1.5vw, 1.15rem);
  line-height: 1.5;
  margin: 0 0 1.75rem 0;
  opacity: 0.95;
}

.bp-footnote {
  font-size: 0.8rem;
  opacity: 0.85;
  line-height: 1.5;
}

/* ---------- Logo ---------- */

.bp-logo {
  display: block;
  width: clamp(140px, 22vw, 200px);
  height: auto;
  margin-bottom: 1.5rem;
}

/* ---------- Buttons ---------- */

.bp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: var(--bp-yellow);
  color: var(--bp-black);
  font-family: var(--bp-font);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0.02em;
  border: 0;
  cursor: pointer;
  padding: 0 2rem;
  height: var(--bp-button-height-desktop);
  border-radius: var(--bp-radius-pill);
  text-decoration: none;
  transition: background-color 120ms ease-out, transform 120ms ease-out;
  -webkit-appearance: none;
  appearance: none;
}

.bp-btn:hover {
  background: #E6BC00;
}

.bp-btn:focus-visible {
  background: #E6BC00;
  outline: none;
  box-shadow: var(--bp-focus-ring);
}

.bp-btn:active { transform: translateY(1px); }

.bp-btn[disabled],
.bp-btn[aria-disabled="true"] {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

.bp-btn--block {
  width: 100%;
}

.bp-btn--secondary {
  background: transparent;
  border: 1px solid var(--bp-grey);
  color: var(--bp-grey);
}

.bp-btn--secondary:hover {
  background: var(--bp-yellow);
  color: var(--bp-black);
  border-color: var(--bp-yellow);
}

.bp-btn--secondary:focus-visible {
  background: var(--bp-yellow);
  color: var(--bp-black);
  border-color: var(--bp-yellow);
  outline: none;
  box-shadow: var(--bp-focus-ring);
}

@media (max-width: 480px) {
  .bp-btn {
    height: var(--bp-button-height-mobile);
    padding: 0 1.5rem;
    font-size: 0.95rem;
  }
}

/* ---------- Form ---------- */

.bp-field {
  display: block;
  margin-bottom: 1.25rem;
}

.bp-field__label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
  color: var(--bp-grey);
}

.bp-field__input {
  display: block;
  width: 100%;
  font-family: var(--bp-font);
  font-size: 1.05rem;
  padding: 0.95rem 1.1rem;
  border: 1px solid var(--bp-grey-10);
  border-radius: 12px;
  background: #FFFFFF;
  color: var(--bp-black);
  transition: border-color 120ms ease-out, box-shadow 120ms ease-out;
  -webkit-appearance: none;
  appearance: none;
}

.bp-field__input:focus {
  outline: none;
  border-color: var(--bp-red);
  box-shadow: 0 0 0 3px rgba(228, 3, 19, 0.18);
}

.bp-error {
  display: none;
  background: #FBE3E5;
  border: 1px solid var(--bp-red-50);
  color: var(--bp-red);
  padding: 0.75rem 1rem;
  border-radius: 12px;
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}

.bp-error.is-visible { display: block; }

/* ====================================================================
 * App layout — intro / player / end screens.
 * ==================================================================== */

.app-body {
  background: #FFFFFF;
}

.app-screen {
  display: block;
}

.app-screen.is-hidden,
.is-hidden {
  display: none !important;
}

.app-screen--hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  background: var(--bp-hero-gradient);
  color: #FFFFFF;
}

.bp-card--wide {
  max-width: 560px;
  text-align: left;
}

.app-rules {
  list-style: none;
  padding: 0;
  margin: 0 0 1.75rem 0;
  display: grid;
  gap: 0.75rem;
}

.app-rules li {
  position: relative;
  padding-left: 1.5rem;
  line-height: 1.45;
  font-size: 0.95rem;
}

.app-rules li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55em;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--bp-red);
}

.app-text-link {
  background: none;
  border: 0;
  padding: 0.5rem 0.75rem;    /* keeps touch target ≥ 44 px */
  min-height: 44px;
  font: inherit;
  color: var(--bp-grey);
  text-decoration: underline;
  cursor: pointer;
  border-radius: 8px;
}

.app-text-link:hover { color: var(--bp-red); }

.app-text-link:focus-visible {
  outline: none;
  box-shadow: var(--bp-focus-ring);
  color: var(--bp-red);
}

/* ====================================================================
 * Player.
 *
 * Visually calm — per brief §7 the clip-playing screen should not
 * distract from the video. No gradient backdrop, just a dark stage.
 * ==================================================================== */

.app-screen--player {
  min-height: 100vh;
  background: #0A0A0A;
  color: #FFFFFF;
  display: flex;
  flex-direction: column;
}

.player-hud {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  background: #000000;
}

.player-hud__brand {
  display: inline-flex;
  align-items: center;
}

.player-hud__logo {
  height: 36px;
  width: auto;
}

.player-hud__progress {
  flex: 1;
  text-align: center;
  font-weight: 600;
  letter-spacing: 0.04em;
  font-size: 0.95rem;
  color: #FFFFFF;
}

.player-hud__end {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.35);
  color: #FFFFFF;
  font: inherit;
  font-size: 0.85rem;
  padding: 0.5rem 1rem;
  border-radius: var(--bp-radius-pill);
  cursor: pointer;
}

.player-hud__end:hover,
.player-hud__end:focus-visible {
  background: var(--bp-yellow);
  color: var(--bp-black);
  border-color: var(--bp-yellow);
  outline: none;
}

.player-stage {
  position: relative;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  aspect-ratio: 16 / 9;
  background: #000000;
  overflow: hidden;
}

.player-video {
  width: 100%;
  height: 100%;
  display: block;
  background: #000000;
  pointer-events: none; /* the click-capture sits on top */
}

.player-click-capture {
  position: absolute;
  inset: 0;
  cursor: crosshair;
  background: transparent;
  z-index: 2;
}

.player-countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--bp-font);
  font-style: italic;
  font-weight: 700;
  font-size: clamp(6rem, 18vw, 14rem);
  color: var(--bp-yellow);
  text-shadow: 0 8px 32px rgba(0, 0, 0, 0.65);
  pointer-events: none;
  z-index: 4;
}

.player-countdown.is-animating {
  animation: bp-countdown 1s ease-out;
}

@keyframes bp-countdown {
  0%   { transform: scale(0.6); opacity: 0; }
  20%  { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1.45); opacity: 0; }
}

.player-black {
  position: absolute;
  inset: 0;
  background: #000000;
  z-index: 5;
  pointer-events: none;
}

.player-flag-rail {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 24px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0));
  pointer-events: none;
  z-index: 3;
}

.player-flag {
  position: absolute;
  bottom: 4px;
  width: 14px;
  height: 18px;
  transform: translateX(-50%);
  background: var(--bp-red);
  clip-path: polygon(0 0, 100% 0, 100% 60%, 50% 100%, 0 60%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  animation: bp-flag-in 180ms ease-out;
}

@keyframes bp-flag-in {
  from { transform: translate(-50%, 6px); opacity: 0; }
  to   { transform: translateX(-50%); opacity: 1; }
}

@media (max-width: 600px) {
  .player-hud__logo { height: 28px; }
  .player-hud__end { font-size: 0.8rem; padding: 0.4rem 0.85rem; }
}

/* ====================================================================
 * Results screen.
 * ==================================================================== */

.results-summary {
  background: linear-gradient(45deg, var(--bp-grey-10), #FFFFFF);
  border-radius: 16px;
  padding: 1.5rem 1.25rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.results-score {
  font-family: var(--bp-font);
  font-style: italic;
  font-weight: 700;
  font-size: clamp(2.5rem, 6vw, 3.5rem);
  line-height: 1;
  margin-bottom: 0.5rem;
  color: var(--bp-black);
}

.results-score__num { color: var(--bp-red); }
.results-score__sep { margin: 0 0.25em; color: var(--bp-grey); }
.results-score__max { color: var(--bp-grey); }

.results-percent {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--bp-grey);
  margin-bottom: 0.25rem;
}

.results-passline {
  font-size: 0.85rem;
  color: var(--bp-grey);
  margin-bottom: 0.85rem;
}

.results-verdict {
  display: inline-block;
  padding: 0.5rem 1.25rem;
  border-radius: var(--bp-radius-pill);
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.results-verdict.is-pass {
  background: var(--bp-green);
  color: var(--bp-black);
}

.results-verdict.is-fail {
  background: var(--bp-red);
  color: #FFFFFF;
}

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

.results-table thead th {
  text-align: left;
  font-weight: 700;
  color: var(--bp-grey);
  padding: 0.6rem 0.5rem;
  border-bottom: 2px solid var(--bp-grey-10);
}

.results-table tbody td {
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid var(--bp-grey-10);
  color: var(--bp-black);
}

.results-table tbody tr:last-child td { border-bottom: 0; }

.results-table .results-score-cell {
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.results-table .results-anticheat {
  color: var(--bp-red);
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ====================================================================
 * Per-clip end-of-clip overlay.
 * Sits inside .player-stage and dims the video frame behind the card.
 * ==================================================================== */

.clip-end-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.72);
  z-index: 30;
  padding: 1rem;
}

.clip-end-card {
  max-width: 480px;
  width: 100%;
  padding: 1.75rem 1.5rem;
  text-align: center;
}

.clip-end-heading {
  font-size: clamp(1.5rem, 4vw, 2rem);
  margin: 0.25rem 0 1rem;
}

.clip-end-verdict {
  display: inline-block;
  padding: 0.4rem 1rem;
  border-radius: var(--bp-radius-pill);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.03em;
  margin-top: 0.25rem;
}

.clip-end-verdict.is-perfect {
  background: var(--bp-green);
  color: var(--bp-black);
  text-transform: uppercase;
  font-size: 0.95rem;
  letter-spacing: 0.05em;
}

.clip-end-verdict.is-good { color: var(--bp-black); }
.clip-end-verdict.is-missed { color: var(--bp-grey); }

.clip-end-verdict.is-zeroed {
  background: var(--bp-red);
  color: #FFFFFF;
  text-transform: uppercase;
  font-size: 0.9rem;
  letter-spacing: 0.05em;
}

.clip-end-clicks {
  color: var(--bp-grey);
  font-size: 0.9rem;
  margin-top: 0.6rem;
}

.clip-end-hazards { margin-top: 0.25rem; }

/* ====================================================================
 * Author mode (?author=1)
 * Hidden by default; revealed when document.body.dataset.mode==="author".
 * ==================================================================== */

.author-only { display: none; }

body[data-mode="author"] .author-only { display: block; }
body[data-mode="author"] .player-stage { cursor: crosshair; }

.author-timecode {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 6;
  font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
  font-size: clamp(0.95rem, 2vw, 1.15rem);
  font-weight: 600;
  color: var(--bp-yellow);
  background: rgba(0, 0, 0, 0.55);
  padding: 0.35rem 0.7rem;
  border-radius: 8px;
  pointer-events: none;
}

.author-panel {
  background: #FFFFFF;
  color: var(--bp-black);
  border-top: 1px solid var(--bp-grey-10);
  padding: 1rem 1.25rem;
  max-height: 40vh;
  overflow-y: auto;
}

.author-panel__head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.author-panel__title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--bp-grey);
  margin: 0;
  flex: 1;
}

.author-panel__btn {
  background: var(--bp-yellow);
  color: var(--bp-black);
  border: 0;
  border-radius: var(--bp-radius-pill);
  padding: 0.4rem 0.95rem;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}

.author-panel__btn:focus-visible {
  outline: none;
  box-shadow: var(--bp-focus-ring);
}

.author-panel__list {
  list-style: none;
  margin: 0;
  padding: 0;
  font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
  font-size: 0.9rem;
  color: var(--bp-grey);
  display: grid;
  gap: 0.25rem;
}

.author-panel__list li {
  display: flex;
  gap: 0.75rem;
  padding: 0.2rem 0;
  border-bottom: 1px dotted var(--bp-grey-10);
}

.author-panel__list .author-clip { color: var(--bp-red); font-weight: 700; }

/* ====================================================================
 * Accessibility / system preferences
 * ==================================================================== */

@media (prefers-reduced-motion: reduce) {
  .player-countdown,
  .player-countdown.is-animating,
  .player-flag,
  .bp-btn {
    animation: none !important;
    transition: none !important;
  }
}

@media (prefers-contrast: more) {
  .bp-field__input { border-width: 2px; border-color: var(--bp-black); }
  .player-hud__end { border-color: #FFFFFF; }
}

html { -webkit-tap-highlight-color: transparent; }

input, button, a { -webkit-tap-highlight-color: rgba(255, 210, 0, 0.35); }

/* Visible focus everywhere — fallback for any focusable element that
 * isn't styled above. Skipped on .player-click-capture by design (the
 * brief intentionally makes the playing clip non-keyboard-accessible). */
:focus-visible {
  outline: 3px solid var(--bp-red);
  outline-offset: 2px;
}

.player-click-capture:focus { outline: none; }

/* ====================================================================
 * Small-screen overrides
 * ==================================================================== */

@media (max-width: 480px) {
  .bp-card { padding: 1.75rem 1.25rem; border-radius: 18px; }
  .bp-card--wide { max-width: 100%; }
  .app-screen--hero { padding: 1.25rem 1rem; }
  .bp-display { font-size: clamp(1.75rem, 7vw, 2.5rem); }
  .results-summary { padding: 1.25rem 0.85rem; }
  .results-table { font-size: 0.85rem; }
  .results-table thead th,
  .results-table tbody td { padding: 0.5rem 0.3rem; }
}

@media (max-width: 380px) {
  .player-hud { padding: 0.6rem 0.85rem; gap: 0.6rem; }
  .player-hud__progress { font-size: 0.85rem; }
}

