/*
 * Field Play-by-Play styles. See playByPlay/fieldPbp.js and the mockup at
 * mockups/field-position/index.html for the canonical look.
 *
 * The field itself is sized by aspect-ratio so it fits any panel size while
 * keeping the 120:40 (length:width) proportion; all on-field elements are
 * %-positioned so they don't depend on the pixel size.
 */

:root {
    --fp-field: #3a7d44;
    --fp-field2: #347040;
    --fp-line: rgba(255, 255, 255, .85);
    --fp-guide: rgba(255, 255, 255, .34);
    --fp-rz: rgba(255, 80, 80, .72);
    --fp-ez: rgba(255, 255, 255, .13);
    --fp-blue: #2563eb;
    --fp-red: #dc2626;
    --fp-hold: #e0a64b;
    --fp-holdbg: #fff3d6;
}

/* Panel shell — mirrors the Full PBP panel: full-tab-only, no drag resize. */
.panel-playByPlayField {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Landscape takeover — CSS overlay, NOT the Fullscreen API (which iOS Safari
   honors only on <video>, and no-ops in standalone PWA mode; iOS PWA is a
   primary runtime — see ARCHITECTURE.md § Target Platform). When the Field
   render sets <body class="fp-landscape-takeover">, the panel is pinned over
   the app chrome (header + tabbar), covering rather than hiding them — so
   switching tabs (which display:none's this panel) reveals the chrome again
   with no cleanup needed. Safe-area insets keep it clear of the notch / home
   indicator. The panel's own title bar is hidden for the minimal header
   specified in FIELD_MODE.md §UI. */
body.fp-landscape-takeover .panel-playByPlayField {
    position: fixed;
    top: env(safe-area-inset-top, 0px);
    right: env(safe-area-inset-right, 0px);
    bottom: env(safe-area-inset-bottom, 0px);
    left: env(safe-area-inset-left, 0px);
    z-index: 9999;
    background: #eef0f2;
}
body.fp-landscape-takeover .panel-playByPlayField .panel-title-bar { display: none; }
.panel-playByPlayField .panel-content.field-pbp-content {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 0;
    overflow: hidden;
    background: #eef0f2;
}
/* Role-disabled fade, matching Full PBP. */
.panel-playByPlayField.role-disabled .fp-play {
    opacity: .5;
    pointer-events: none;
}

/* Action row: mode pill + orientation toggle + Undo. */
.fp-actionrow {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    background: #fff;
    border-bottom: 1px solid #eee;
}
/* Override global button { margin: 10px } — the stray vertical margin was
   padding this row out and stealing room the modifier column needs below. */
.fp-actionrow button { margin: 0; }
.fp-actionrow-spacer { flex: 1 1 auto; }
/* Inline status lives in the top action row, shown only in landscape (where
   vertical space is scarce) — it takes over for the bottom .fp-statusbar so
   the field gets the freed height. Hidden in portrait. */
.fp-status-inline {
    display: none;
    flex: 1 1 auto; min-width: 0;
    font-size: 12.5px; color: #444;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.fp-status-inline b { color: #111; }
.field-pbp-content[data-o="landscape"] .fp-status-inline { display: block; }
.field-pbp-content[data-o="landscape"] .fp-actionrow-spacer { display: none; }
.field-pbp-content[data-o="landscape"] .fp-statusbar { display: none; }
.fp-modepill {
    display: inline-block;
    padding: 5px 14px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 12px;
    color: #fff;
}
.fp-modepill.offense { background: var(--fp-blue); }
.fp-modepill.defense { background: var(--fp-red); }
.fp-undo,
.fp-gameevents {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 7px 13px;
    border: 1px solid #bbb; border-radius: 7px;
    background: #fff; color: #333; font-weight: 600; font-size: 12.5px; cursor: pointer;
}

/* Play area = field + status + events. */
.fp-play {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
    min-width: 0;
    position: relative;
}
.fp-prow {
    flex: 1 1 auto;
    display: flex;
    min-height: 0;
    min-width: 0;
    background: #eef0f2;
}

/* Between points: the field + rail show the last point's state but are greyed
   and non-interactive — no events until Start Point (which lives in the action
   row, outside .fp-play, so it stays live). JS also guards the pointer layer. */
.fp-play.fp-between-points .fp-prow,
.fp-play.fp-between-points .fp-events { opacity: 0.45; pointer-events: none; }
.fp-play.fp-between-points .fp-mic { pointer-events: none; opacity: 0.5; }

/* Portrait: left name rail; landscape: players across the top. */
.field-pbp-content[data-o="portrait"] .fp-sidebar {
    flex: 0 0 152px;
    display: flex; flex-direction: column; gap: 7px;
    padding: 12px 8px; overflow: auto;
    background: #fff; border-right: 1px solid #e3e3e3;
}
.field-pbp-content[data-o="landscape"] .fp-prow { flex-direction: column; }
.field-pbp-content[data-o="landscape"] .fp-sidebar {
    flex: 0 0 auto;
    display: flex; flex-direction: row; flex-wrap: nowrap; gap: 6px;
    padding: 7px 10px; overflow: hidden;
    background: #fff; border-bottom: 1px solid #ddd;
}
.field-pbp-content[data-o="landscape"] .fp-rail {
    display: flex; flex-direction: row; flex: 1 1 auto; gap: 6px; min-width: 0;
}
.field-pbp-content[data-o="landscape"] .fp-rail .fp-chip { flex: 1 1 0; min-width: 0; justify-content: center; }
/* Landscape never scrolls — fitPlayers() in fieldPbp.js progressively shrinks:
   .fp-rail-tight drops jersey numbers; .fp-rail-xtight collapses Unknown's
   label to just "?". Both stages are applied via JS measurement. */
.field-pbp-content[data-o="landscape"] .fp-rail.fp-rail-tight .fp-chip .fp-num { display: none; }
.field-pbp-content[data-o="landscape"] .fp-rail.fp-rail-xtight .fp-chip.unknown .fp-nm { display: none; }
.field-pbp-content[data-o="landscape"] .fp-modsep { display: none; }
.field-pbp-content[data-o="landscape"] .fp-modcol { display: none; }

.fp-rail { display: flex; flex-direction: column; gap: 7px; }
.fp-rail-placeholder { color: #888; font-size: 13px; padding: 6px 2px; }
.fp-modsep { flex: 0 0 auto; height: 1px; background: #e3e3e3; margin: 8px 2px 4px; }
.fp-modcol { display: flex; flex-direction: column; gap: 5px; }
.fp-modcol-label { font-size: 12.5px; font-weight: 700; color: #333; }
.fp-modcol-sub { font: 600 11.5px 'JetBrains Mono', monospace; color: #555; }
/* Last-play tag chips wrap two-per-row so a 6-modifier throw doesn't make the
   sidebar tall. (Pull / D-placing mods stay stacked — only 2–3 of them.) */
.fp-modchips { display: flex; flex-wrap: wrap; gap: 5px; }
.fp-modchips .fp-modbtn { flex: 1 1 calc(50% - 3px); min-width: 0; padding: 7px 4px; }

/* Player chips. */
.fp-chip {
    display: flex; align-items: center; gap: 7px;
    background: #f7f7f7; border: 1px solid #cfcfcf; border-radius: 999px;
    padding: 8px 14px; font-size: 14px; font-weight: 600; color: #222;
    cursor: pointer; user-select: none; white-space: nowrap;
    /* touch-action none so a chip drag becomes a pegman, not a scroll */
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}
/* In pull mode chips aren't draggable, so let the rail scroll vertically. */
.field-pbp-content[data-mode="pull"] .fp-chip { touch-action: pan-y; }
.fp-chip .fp-num { font: 700 11px 'JetBrains Mono', monospace; color: #888; }
.fp-chip .fp-nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
/* The holder chip is inert on offense (no drag / no tap — can't pass to
   yourself), so it shouldn't advertise interactivity. */
.fp-chip.holder { background: var(--fp-holdbg); border-color: var(--fp-hold); box-shadow: 0 0 0 2px rgba(224, 166, 75, .3); cursor: default; }
.fp-chip.unknown { background: #f3f4f6; border: 1px dashed #b9bdc4; color: #6b7280; font-style: italic; }
.fp-chip .fp-umark { font: 700 12px 'JetBrains Mono', monospace; color: #9aa0a6; }

/* Field box. */
.fp-fieldwrap {
    flex: 1 1 auto;
    display: flex; align-items: center; justify-content: center;
    min-height: 0; min-width: 0; padding: 8px;
}
.fp-field {
    position: relative;
    background: linear-gradient(var(--fp-field), var(--fp-field2));
    border: 2px solid #fff; border-radius: 3px;
    touch-action: none;
    flex: 0 0 auto;
    /* No text selection on the touch surface — long-pressing a label to flip
       must not start a selection / iOS callout. */
    user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
/* Keep the 120:40 proportion; size to the constraining dimension. */
.field-pbp-content[data-o="portrait"] .fp-field { height: 100%; aspect-ratio: 40 / 120; max-width: 100%; }
.field-pbp-content[data-o="landscape"] .fp-field { width: 100%; aspect-ratio: 120 / 40; max-height: 100%; }

/* Attack-direction arrow: large, subtle, looks like part of the field, never
   interactive. Sized to ~50% of the field's long dimension; the wrapper is
   shrink-to-fit and centered. */
.fp-attack-arrow {
    position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
    pointer-events: none; user-select: none; z-index: 1;
}
.fp-attack-arrow svg { display: block; overflow: visible; }
.field-pbp-content[data-o="portrait"] .fp-attack-arrow { height: 50%; }
.field-pbp-content[data-o="portrait"] .fp-attack-arrow svg { height: 100%; width: auto; }
.field-pbp-content[data-o="landscape"] .fp-attack-arrow { width: 50%; }
.field-pbp-content[data-o="landscape"] .fp-attack-arrow svg { width: 100%; height: auto; }
.fp-aa-shape { fill: rgba(210, 245, 205, 0.16); }
/* "Attacking" label: centered on the field, rotated to align with the arrow
   and read from the Home side. Background-style, non-interactive. */
.fp-attack-label {
    position: absolute; left: 50%; top: 50%;
    pointer-events: none; user-select: none; z-index: 1; white-space: nowrap;
    color: rgba(255, 255, 255, 0.5);
    font: 800 26px system-ui, sans-serif;
    letter-spacing: 3px; text-transform: uppercase;
}

.fp-ezfill { position: absolute; background: var(--fp-ez); }
.fp-line { position: absolute; background: var(--fp-line); }
.fp-gline { position: absolute; background: repeating-linear-gradient(to right, var(--fp-guide) 0 6px, transparent 6px 12px); }
.fp-gline.v { background: repeating-linear-gradient(to bottom, var(--fp-guide) 0 6px, transparent 6px 12px); }
.fp-gline.rz { background: repeating-linear-gradient(to right, var(--fp-rz) 0 7px, transparent 7px 13px); }
.fp-gline.rz.v { background: repeating-linear-gradient(to bottom, var(--fp-rz) 0 7px, transparent 7px 13px); }
.fp-brick { position: absolute; color: rgba(255, 255, 255, .5); font-size: 12px; font-weight: 700; transform: translate(-50%, -50%); pointer-events: none; }
.fp-ezlabel { position: absolute; color: rgba(255, 255, 255, .5); font-size: 9px; letter-spacing: .1em; text-transform: uppercase; transform: translate(-50%, -50%); }
.fp-sidelbl { position: absolute; color: rgba(255, 255, 255, .34); font-size: 10px; letter-spacing: .18em; text-transform: uppercase; font-weight: 600; transform: translate(-50%, -50%); }
/* Padding enlarges the long-press hit area; translate(-50%,-50%) still centers
   on the label's anchor point so the visual position is unchanged. */
.fp-flbl { pointer-events: auto; cursor: pointer; padding: 6px; -webkit-tap-highlight-color: transparent; }

/* Status + events strips. */
.fp-statusbar {
    flex: 0 0 auto;
    background: #fff; border-top: 1px solid #ddd;
    padding: 7px 12px; font-size: 12.5px; color: #444;
    display: flex; align-items: center; gap: 8px; min-height: 34px;
}
.fp-statusbar b { color: #111; }
.fp-events {
    flex: 0 0 auto;
    background: #fff; border-top: 1px solid #ddd;
    padding: 8px 72px 8px 8px;   /* right pad keeps clear of the mic FAB */
    display: flex; flex-wrap: nowrap; gap: 6px; min-height: 8px;
}
/* Portrait: this row sits at the very bottom of the screen, in reach of
   iOS's swipe-up home gesture / Siri edge. Extra bottom clearance (plus the
   safe-area inset when the app runs with one) keeps taps on the buttons
   instead of the system edge. Landscape keeps the tight spacing — the row
   isn't at the screen edge there and field space is scarcer. */
.field-pbp-content[data-o="portrait"] .fp-events {
    padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}

/* Armed chip (puller picked; later: armed player awaiting placement). */
.fp-chip.armed { background: var(--fp-blue); border-color: var(--fp-blue); color: #fff; }
.fp-chip.armed .fp-num { color: #cdd9ff; }
.fp-chip.unknown.armed { background: var(--fp-blue); border-color: var(--fp-blue); color: #fff; font-style: normal; }

/* "Pick Puller:" / slot label. */
.fp-slotlbl { font-size: 12px; font-weight: 700; color: #555; padding: 2px 4px 5px; }

/* PULL mode pill + Start Point button in the action row. */
.fp-modepill.pull { background: var(--fp-hold); }
.fp-start-point-btn {
    border: none; border-radius: 7px; background: var(--fp-blue); color: #fff;
    padding: 6px 16px; font-size: 13px; font-weight: 700; cursor: pointer;
}

/* On-field located-event markers, the disc, and arrows. */
.fp-arrows { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.fp-disc {
    position: absolute; width: 18px; height: 18px; border-radius: 50%;
    background: #fff; border: 2px solid #111; transform: translate(-50%, -50%);
    pointer-events: none; z-index: 7; box-shadow: 0 0 0 3px rgba(255, 255, 255, .35);
}
.fp-marker {
    position: absolute; transform: translate(-50%, -50%); z-index: 5;
    font-size: 11px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    width: 21px; height: 21px; border-radius: 50%;
    color: #fff; border: 1.5px solid #fff; pointer-events: none;
}
.fp-marker.completion { background: rgba(37, 99, 235, .85); }
.fp-marker.score { background: var(--fp-green, #047857); }
.fp-marker.turn { background: var(--fp-red); }
.fp-marker.block { background: #047857; }
.fp-marker.pull { background: rgba(80, 80, 80, .85); }
/* Rendered markers are draggable for fine-tuning (incl. the fading previous
   possession, so a prior location can still be adjusted during the fade). */
.fp-marker[data-mkidx] { pointer-events: auto; cursor: grab; touch-action: none; }

/* Possession-change fade: previous-possession markers/arrows run this once
   (animation-fill-mode forwards holds them at 0 until they're dropped). It is
   a single bounded animation, not a continuous loop — negligible battery. */
@keyframes fpFadeOut { from { opacity: 1; } to { opacity: 0; } }

/* Events bar buttons (pull hangtime + brick; offense/defense buttons later). */
.fp-ebtn {
    /* basis = content so labels show in full; grow to share the row. nowrap
       keeps them on one line; they size to their text and fit the row. */
    flex: 1 1 auto; min-width: 0;
    margin: 0;   /* override global button { margin: 10px } — 4 buttons × 20px was starving the row and overflowing "Throwaway" */
    border: 1px solid #c8c8c8; border-radius: 6px; background: #f7f7f7;
    padding: 8px 7px; font-size: 14px; line-height: 1.2; font-weight: 600; color: #333;
    cursor: pointer; text-align: center; white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}
/* Portrait: full-height (44px+) tap targets — these live at the bottom of
   the screen where short buttons get mistaken for the iOS home gesture.
   Horizontal padding is trimmed to 4px so the longest label ("Throwaway")
   fits its border on narrow phones. Landscape keeps the compact ~35px
   height so the field stays roomy. */
.field-pbp-content[data-o="portrait"] .fp-ebtn {
    min-height: 44px;
    padding: 12px 4px;
}
.field-pbp-content[data-o="portrait"] .fp-events {
    gap: 4px;
}
.fp-ebtn.pullhang { flex: 3 1 0; background: #fff7e6; border-color: var(--fp-hold); color: #92600b; font: 700 13px 'JetBrains Mono', monospace; }
.fp-ebtn.pullbrick { flex: 1 1 0; background: #fff; border-color: var(--fp-hold); color: #92600b; }

/* Modifier-column buttons (pull tags now; throw/D modifiers in Phase 7). */
.fp-modbtn {
    flex: 0 0 auto; margin: 0;   /* override global button { margin: 10px } */
    border: 1px solid #cfcfcf; border-radius: 6px; background: #f7f7f7;
    padding: 7px 8px; font-size: 13px; font-weight: 600; color: #333;
    cursor: pointer; text-align: center; -webkit-tap-highlight-color: transparent;
}
.fp-modbtn.on { background: var(--fp-blue); border-color: var(--fp-blue); color: #fff; }

/* Defense: D-action buttons fill the player slot until one is chosen.
   Plain/neutral styling — same look as the other buttons, no color coding.
   Sized to match the player chips (~35px) that replace them once a defender
   takes possession, and the bottom event buttons — so the row never towers
   over the field. */
.fp-dtypebtn {
    display: flex; align-items: center; justify-content: center; gap: 7px;
    border-radius: 8px; padding: 8px 10px; font-size: 14px; font-weight: 700;
    cursor: pointer; border: 1px solid #cfcfcf; background: #f7f7f7; color: #333;
    -webkit-tap-highlight-color: transparent;
}
.fp-dtypebtn:active { filter: brightness(.96); }
/* Landscape: D actions split the row. */
.field-pbp-content[data-o="landscape"] .fp-rail .fp-dtypebtn { flex: 1 1 0; min-width: 0; }

/* ✕ cancel chip leading the defender picker while placing a D. */
.fp-dcancel {
    display: flex; align-items: center; justify-content: center; gap: 5px;
    border: 1px solid #d9534f; color: #d9534f; background: #fff; border-radius: 999px;
    padding: 7px 12px; font-size: 13px; font-weight: 700; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

/* Defense bottom bar action colors. */
.fp-ebtn.theyturn { color: #047857; }
.fp-ebtn.theyscore { color: #b91c1c; }
.fp-ebtn.more { flex: 0 0 auto; min-width: auto; color: #666; }

/* Offense bottom bar: Drop / Throwaway / Score toggles. `.on` = armed. */
.fp-ebtn.drop, .fp-ebtn.throwaway { color: #b91c1c; }
.fp-ebtn.score { color: #047857; border-color: #86d3b3; background: #e7f7f0; }
.fp-ebtn.on { background: var(--fp-blue); border-color: var(--fp-blue); color: #fff; }

/* Pegman ghost while dragging a player chip onto the field. Google-Maps
   Street-View style: the container is a zero-size anchor pinned at the exact
   drop point (where the "X" sits, lifted above the finger in JS). The shadow +
   X mark that point; the figure and name pill float above it. */
.fp-pegman {
    position: fixed; z-index: 999; pointer-events: none;
    width: 0; height: 0;
}
/* Soft ground shadow, centred on the drop point. */
.fp-peg-shadow {
    position: absolute; left: 0; top: 0; transform: translate(-50%, -50%);
    width: 30px; height: 12px; border-radius: 50%;
    background: radial-gradient(ellipse at center, rgba(0, 0, 0, .4), rgba(0, 0, 0, 0) 70%);
}
/* Precise drop-point marker, drawn on top of the shadow. */
.fp-peg-x {
    position: absolute; left: 0; top: 0; transform: translate(-50%, -50%);
    font-size: 16px; font-weight: 900; line-height: 1; color: var(--fp-blue);
    text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 3px #fff;
}
/* Player figure standing just above the drop point. */
.fp-peg-figure {
    position: absolute; left: 0; bottom: 4px; transform: translateX(-50%);
    line-height: 0;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .45));
}
.fp-peg-figure img {
    display: block; height: 54px; width: auto; pointer-events: none;
}
/* Name pill floating above the figure. */
.fp-peg-name {
    position: absolute; left: 0; bottom: 62px; transform: translateX(-50%);
    background: var(--fp-blue); color: #fff; border-radius: 999px;
    padding: 3px 10px; font-size: 12px; font-weight: 600; white-space: nowrap;
    box-shadow: 0 3px 10px rgba(0, 0, 0, .35);
}

/* Field-side popover picker ("Who got the block?"). Positioned in JS (top-left
   corner) with viewport clamping; scrolls if the roster is taller than fits. */
.fp-picker {
    position: fixed; z-index: 999; background: #fff; border: 1px solid #bbb;
    border-radius: 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
    padding: 7px; display: flex; flex-wrap: wrap; gap: 5px; max-width: 250px;
    max-height: 70vh; overflow-y: auto;
}
.fp-picker .fp-picker-ttl { flex: 1 1 100%; font-size: 11px; color: #888; text-align: center; margin-bottom: 2px; }
.fp-picker .fp-chip { padding: 7px 12px; font-size: 14px; }

/* Mic FAB, reserved bottom-right in both layouts. */
.fp-mic {
    position: absolute; right: 14px; bottom: 12px;
    width: 54px; height: 54px; border-radius: 50%;
    background: #e0533a; color: #fff; border: none;
    display: flex; align-items: center; justify-content: center; font-size: 20px;
    z-index: 20; box-shadow: 0 4px 14px rgba(0, 0, 0, .3); cursor: pointer;
}
