/* FLAG PLOT — Battle Stations · carltonjames.com/flag-plot */
/* T03 · 25 Alpha LLC · September 2026 */

:root {
  --void: #050508;
  --void-2: #0a0a0f;
  --void-3: #0c0c14;
  --void-4: #141420;
  --gold: #C9A84C;
  --gold-dim: #CEAA4F;
  --gold-bright: #e8c56a;
  --navy: #003F72;
  --electric: #7B5FFF;
  --signal: #2ECC71;
  --ember: #D44A26;
  --white: #F4F1EC;
  --muted: #ADADBD;
  --border: rgba(201,168,76,0.15);
  --border-bright: rgba(201,168,76,0.4);
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-mono: 'Azeret Mono', 'Courier New', monospace;
  --font-body: 'Libre Franklin', system-ui, sans-serif;
  --cell-size: 44px;
}

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

html { scroll-behavior: smooth; font-size: 16px; }

body {
  background: var(--void);
  color: var(--white);
  font-family: var(--font-body);
  font-weight: 300;
  line-height: 1.6;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  z-index: 9999;
  opacity: 0.35;
}

::selection { background: var(--gold); color: var(--void); }

a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-bright); }

/* ══ NAVIGATION ══ */
nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  padding: 1.25rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(to bottom, rgba(5,5,8,0.95), transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.nav-logo {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  color: var(--gold);
  text-transform: uppercase;
  text-decoration: none;
}

.nav-links {
  display: flex;
  gap: 2rem;
  list-style: none;
}

.nav-links a {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  transition: color 0.2s;
}
.nav-links a:hover,
.nav-links a[aria-current="page"] { color: var(--gold); }

/* ══ LAYOUT ══ */
.page-wrapper {
  min-height: 100vh;
  padding-top: 80px;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 2rem;
}

/* ══ TITLE BLOCK ══ */
.title-block {
  padding: 3rem 0 2rem;
  border-bottom: 1px solid var(--border);
}

.title-overline {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--gold-dim);
  margin-bottom: 0.5rem;
}

.title-main {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 6vw, 5rem);
  font-weight: 300;
  color: var(--gold);
  line-height: 1;
  letter-spacing: 0.05em;
}

.title-sub {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 0.5rem;
}

.title-desc {
  font-size: 0.9rem;
  color: var(--muted);
  max-width: 680px;
  margin-top: 1rem;
  line-height: 1.6;
}

/* ══ SEA TRIALS CARD ══ */
#sea-trials-card {
  display: none;
  min-height: calc(100vh - 80px);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
  gap: 2rem;
}
#sea-trials-card.visible { display: flex; }

.sea-trials-label {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--gold-dim);
}

.sea-trials-title {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 4rem);
  font-weight: 300;
  color: var(--white);
}

/* ══ SCREENS ══ */
.screen { display: none; }
.screen.active { display: block; }

/* ══ PLACEMENT SCREEN ══ */
#placement-screen {
  padding: 2rem 0 4rem;
}

.placement-layout {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3rem;
  align-items: start;
}

.placement-board-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.board-label {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--gold-dim);
}

.placement-controls {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-width: 400px;
}

.difficulty-section h3 {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--gold-dim);
  margin-bottom: 0.75rem;
}

.difficulty-row {
  display: flex;
  gap: 0.5rem;
}

.diff-btn {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 0.7rem 0.5rem;
  background: var(--void-3);
  color: var(--muted);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s;
}

.diff-btn:hover { border-color: var(--gold-dim); color: var(--white); }
.diff-btn.active { background: var(--gold); color: var(--void); border-color: var(--gold); font-weight: 700; }

.diff-desc {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.5;
  min-height: 3rem;
}

.fleet-roster {
  border: 1px solid var(--border);
  background: var(--void-2);
}

.roster-header {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--gold-dim);
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}

.roster-ship {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
}
.roster-ship:last-child { border-bottom: none; }

.roster-ship-name {
  flex: 1;
  font-weight: 500;
  color: var(--white);
}

.roster-ship-class {
  font-family: var(--font-mono);
  font-size: 0.55rem;
  letter-spacing: 0.1em;
  color: var(--muted);
  text-transform: uppercase;
}

.roster-ship-squares {
  display: flex;
  gap: 3px;
}

.roster-sq {
  width: 10px;
  height: 10px;
  background: var(--gold);
  opacity: 0.6;
}

.placement-hint {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--muted);
  letter-spacing: 0.05em;
  line-height: 1.6;
}

.placement-hint kbd {
  display: inline-block;
  background: var(--void-3);
  border: 1px solid var(--border-bright);
  padding: 0.1rem 0.35rem;
  font-size: 0.6rem;
  color: var(--gold-dim);
  border-radius: 2px;
}

.cta-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.btn-primary {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 0.9rem 2rem;
  background: var(--gold);
  color: var(--void);
  border: none;
  cursor: pointer;
  font-weight: 700;
  transition: all 0.2s;
}
.btn-primary:hover { background: var(--gold-bright); transform: translateY(-1px); }
.btn-primary:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.btn-ghost {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 0.9rem 2rem;
  background: transparent;
  color: var(--gold);
  border: 1px solid var(--border-bright);
  cursor: pointer;
  transition: all 0.2s;
}
.btn-ghost:hover { border-color: var(--gold); background: rgba(201,168,76,0.05); }
.btn-ghost:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ══ GRID ══ */
.grid-container {
  display: inline-flex;
  flex-direction: column;
  gap: 0;
  position: relative;
}

.grid-coords-top {
  display: flex;
  margin-left: calc(var(--cell-size) + 4px);
}

.grid-coord {
  width: var(--cell-size);
  font-family: var(--font-mono);
  font-size: 0.55rem;
  color: var(--muted);
  text-align: center;
  padding-bottom: 4px;
  letter-spacing: 0.05em;
}

.grid-row {
  display: flex;
  gap: 0;
  align-items: center;
}

.grid-row-label {
  width: var(--cell-size);
  font-family: var(--font-mono);
  font-size: 0.55rem;
  color: var(--muted);
  text-align: right;
  padding-right: 8px;
  flex-shrink: 0;
}

.grid-cell {
  width: var(--cell-size);
  height: var(--cell-size);
  border: 1px solid rgba(0,63,114,0.3);
  background: rgba(0,20,40,0.6);
  cursor: pointer;
  position: relative;
  transition: background 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 1rem;
}

.grid-cell:hover { background: rgba(0,63,114,0.5); }
.grid-cell:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; z-index: 1; }

/* Ship states */
.grid-cell.ship {
  background: rgba(201,168,76,0.15);
  border-color: rgba(201,168,76,0.3);
}
.grid-cell.ship-selected {
  background: rgba(201,168,76,0.3);
  border-color: var(--gold);
}
.grid-cell.preview-valid {
  background: rgba(201,168,76,0.2);
  border-color: rgba(201,168,76,0.5);
}
.grid-cell.preview-invalid {
  background: rgba(212,74,38,0.2);
  border-color: rgba(212,74,38,0.5);
}

/* Hit/miss — glyphs carry meaning, color reinforces */
.grid-cell.miss {
  background: rgba(244,241,236,0.04);
  border-color: rgba(244,241,236,0.15);
  color: rgba(244,241,236,0.4);
  cursor: default;
}
.grid-cell.miss::after {
  content: '×';
  font-size: 1.1rem;
  color: rgba(244,241,236,0.5);
}

.grid-cell.hit {
  background: rgba(212,74,38,0.25);
  border-color: var(--ember);
  cursor: default;
}
.grid-cell.hit::after {
  content: '✦';
  font-size: 0.9rem;
  color: var(--ember);
}

/* Sunk ship — hatch pattern */
.grid-cell.sunk {
  background-image: repeating-linear-gradient(
    45deg,
    rgba(138,111,48,0.15) 0px,
    rgba(138,111,48,0.15) 2px,
    transparent 2px,
    transparent 8px
  );
  background-color: rgba(138,111,48,0.1);
  border-color: var(--gold-dim);
  cursor: default;
}
.grid-cell.sunk::after {
  content: '✦';
  font-size: 0.9rem;
  color: var(--gold-dim);
}

/* AI thinking pulse on Red Fleet cells */
.grid-cell.thinking {
  animation: thinking-pulse 0.45s ease-in-out;
}

@keyframes thinking-pulse {
  0%   { background: rgba(123,95,255,0.05); }
  50%  { background: rgba(123,95,255,0.3); border-color: var(--electric); }
  100% { background: rgba(0,20,40,0.6); }
}

/* Targeted cell (keyboard cursor) */
.grid-cell.targeted {
  outline: 2px solid var(--gold);
  outline-offset: -2px;
  z-index: 1;
}

/* Red fleet cells — interactive */
.grid-cell.red-target {
  cursor: crosshair;
}
.grid-cell.red-target:hover { background: rgba(0,63,114,0.7); }
.grid-cell.red-target:focus-visible { outline: 2px solid var(--gold); outline-offset: -2px; }
.grid-cell.red-target.already-shot { cursor: default; }

/* ══ BATTLE SCREEN ══ */
#battle-screen { padding: 2rem 0 4rem; }

.battle-layout {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 2rem;
  align-items: start;
}

.board-section { display: flex; flex-direction: column; gap: 0.75rem; }

.board-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.board-title {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--gold-dim);
}

.board-status {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--muted);
}

/* ══ SIGNAL LOG ══ */
.signal-log {
  width: 240px;
  flex-shrink: 0;
}

.signal-log-header {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--gold-dim);
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.5rem;
}

.signal-log-entries {
  max-height: 440px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.signal-log-entries::-webkit-scrollbar { width: 3px; }
.signal-log-entries::-webkit-scrollbar-track { background: var(--void-2); }
.signal-log-entries::-webkit-scrollbar-thumb { background: var(--gold-dim); }

.log-entry {
  font-family: var(--font-mono);
  font-size: 0.58rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  padding: 3px 6px;
  line-height: 1.4;
}
.log-entry.player-shot { color: var(--gold-dim); }
.log-entry.player-hit  { color: var(--gold); }
.log-entry.red-shot    { color: rgba(212,74,38,0.7); }
.log-entry.red-hit     { color: var(--ember); font-weight: 700; }
.log-entry.sunk-entry  { color: var(--white); border-left: 2px solid var(--ember); padding-left: 8px; }

.log-toggle {
  display: none;
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  color: var(--gold-dim);
  background: none;
  border: none;
  cursor: pointer;
  margin-top: 0.5rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.log-toggle:focus-visible { outline: 2px solid var(--gold); }

/* ══ STATUS BAR ══ */
.status-bar {
  display: flex;
  gap: 2rem;
  padding: 1rem 0;
  border-top: 1px solid var(--border);
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.stat-chip {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-chip-label {
  font-family: var(--font-mono);
  font-size: 0.5rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-chip-val {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  color: var(--white);
}

/* ══ REVEAL CARD ══ */
.reveal-area {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 320px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.reveal-card {
  background: var(--void-3);
  border: 1px solid var(--border-bright);
  border-left: 3px solid var(--ember);
  padding: 1.25rem;
  animation: slideInCard 0.35s ease-out;
}

@keyframes slideInCard {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

.reveal-card-label {
  font-family: var(--font-mono);
  font-size: 0.5rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ember);
  margin-bottom: 0.4rem;
}

.reveal-card-ship {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--gold);
  margin-bottom: 0.4rem;
}

.reveal-card-fact {
  font-size: 0.78rem;
  color: var(--white);
  line-height: 1.5;
}

/* ══ ARIA LIVE REGION ══ */
.sr-announce {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
}

/* ══ END SCREEN ══ */
#end-screen {
  display: none;
  padding: 4rem 0;
}
#end-screen.active { display: block; }

.end-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4rem;
  align-items: start;
}

.end-left {}

.end-verdict-label {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--gold-dim);
  margin-bottom: 0.75rem;
}

.end-verdict-title {
  font-family: var(--font-display);
  font-size: clamp(3rem, 7vw, 6rem);
  font-weight: 300;
  line-height: 1;
  margin-bottom: 1.5rem;
}
.end-verdict-title.victory { color: var(--gold); }
.end-verdict-title.defeat  { color: var(--ember); }

.end-stats {
  display: flex;
  gap: 2rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.end-stat { display: flex; flex-direction: column; gap: 4px; }

.end-stat-num {
  font-family: var(--font-mono);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--white);
}

.end-stat-label {
  font-family: var(--font-mono);
  font-size: 0.5rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

.end-cta-row { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1.5rem; }

/* ══ AAR BLOCK ══ */
.aar-block {
  background: var(--void-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--gold);
  padding: 2rem;
}

.aar-heading {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--gold-dim);
  margin-bottom: 1rem;
}

.aar-text {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 300;
  color: var(--white);
  line-height: 1.7;
  font-style: italic;
}

.aar-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  background: var(--gold);
  animation: blink 0.8s step-end infinite;
  vertical-align: middle;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

.aar-loading {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--muted);
  letter-spacing: 0.1em;
  animation: loadingFade 1.5s ease-in-out infinite;
}

@keyframes loadingFade {
  0%, 100% { opacity: 0.4; }
  50%      { opacity: 1; }
}

/* ══ PULSE-DOT ══ */
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.4; transform: scale(0.7); }
}

/* ══ MOBILE ══ */
@media (max-width: 760px) {
  :root { --cell-size: 32px; }

  .placement-layout { grid-template-columns: 1fr; }
  .placement-controls { max-width: 100%; }

  .battle-layout {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .signal-log { width: 100%; }

  .signal-log-entries {
    max-height: 6.5rem;
    overflow: hidden;
  }
  .signal-log-entries.expanded { max-height: 300px; overflow-y: auto; }
  .log-toggle { display: block; }

  .end-layout { grid-template-columns: 1fr; gap: 2rem; }

  .reveal-area {
    width: calc(100vw - 2rem);
    right: 1rem;
  }

  .nav-links { display: none; }
}

@media (max-width: 480px) {
  :root { --cell-size: 30px; }
}

/* ══ REDUCED MOTION ══ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
