/* ================================================================
   Shared styles for the app pages built in Phases 2-4:
   Dashboard, Game Review, Play Bots (+ the BoardUI board).
   Tokens come from site.css; layout sits inside the app shell.
   ================================================================ */
.ap-page { max-width: 1240px; margin: 0 auto; }
.ap-eyebrow { font: 600 13px var(--sans); letter-spacing: .2em; text-transform: uppercase; color: var(--slate); }
.ap-eyebrow.is-brass { color: var(--brass); }
.ap-h1 { font: 700 clamp(28px, 3.4vw, 44px)/1.1 var(--serif); color: var(--ivory); margin: 8px 0 0; }
.ap-h2 { font: 700 20px/1.3 var(--sans); color: var(--ivory); margin: 0 0 14px; }
.ap-muted { color: var(--slate); }
.ap-note { font: 400 15px/1.55 var(--sans); color: var(--slate); margin: 0; }
.ap-hidden, [hidden] { display: none !important; }

.ap-card {
  background: var(--ink-900); border: 1px solid var(--line); border-radius: 16px;
  padding: 24px; box-sizing: border-box; min-width: 0;
}
.ap-card.is-feature {
  border-color: var(--brass-dim);
  background: linear-gradient(135deg, rgba(201, 162, 75, .10), rgba(201, 162, 75, .02)), var(--ink-900);
}
.ap-card-title { font: 700 20px/1.3 var(--sans); color: var(--ivory); margin: 0 0 6px; }

/* Buttons */
.ap-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border-radius: 12px; border: 1px solid transparent; cursor: pointer;
  font: 600 15px var(--sans); text-decoration: none; white-space: nowrap;
}
.ap-btn-primary { background: var(--brass); color: var(--ink-950); }
.ap-btn-primary:hover:not(:disabled) { background: var(--brass-bright); }
.ap-btn-ghost { background: transparent; border-color: var(--line); color: var(--ivory); }
.ap-btn-ghost:hover:not(:disabled) { border-color: var(--brass-dim); color: var(--brass-bright); }
.ap-btn-dashed { background: transparent; border: 1px dashed var(--brass-dim); color: var(--brass-bright); border-radius: 999px; padding: 9px 18px; }
.ap-btn-dashed:hover { background: rgba(201, 162, 75, .08); }
.ap-btn-teal { background: var(--teal-deep, #1F433D); border-color: var(--teal); color: var(--ivory); }
.ap-btn-teal:hover:not(:disabled) { background: var(--teal); }
.ap-btn:disabled { opacity: .45; cursor: default; }
.ap-btn-sm { padding: 7px 12px; font-size: 14px; border-radius: 9px; }

/* Chips (quick questions, filters) */
.ap-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ap-chip {
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--brass-dim); background: transparent;
  color: var(--brass-bright); font: 500 15px var(--sans); cursor: pointer;
}
.ap-chip:hover:not(:disabled) { background: rgba(201, 162, 75, .1); }
.ap-chip[aria-pressed="true"] { background: rgba(201, 162, 75, .18); border-color: var(--brass); }
.ap-chip:disabled { opacity: .4; cursor: default; }

/* Forms */
.ap-field { display: grid; gap: 6px; }
.ap-label { font: 600 14px var(--sans); color: var(--slate); }
.ap-input, .ap-select {
  width: 100%; box-sizing: border-box; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--ink-950); color: var(--ivory); font: 400 15px var(--sans);
}
.ap-input:focus-visible, .ap-select:focus-visible { outline: 2px solid var(--brass); outline-offset: 1px; }
.ap-seg { display: inline-flex; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.ap-seg button {
  padding: 11px 16px; border: 0; background: transparent; color: var(--slate); font: 500 15px var(--sans); cursor: pointer;
}
.ap-seg button[aria-pressed="true"] { background: var(--ink-800); color: var(--ivory); font-weight: 600; }
.ap-link-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: stretch; }
.ap-link-form .ap-input { flex: 1 1 200px; width: auto; }
.ap-msg { font: 500 15px var(--sans); margin: 8px 0 0; min-height: 1em; }
.ap-msg.is-error { color: #E58A83; }
.ap-msg.is-ok { color: var(--teal-bright); }

/* Stat counters */
.ap-stats { display: flex; }
.ap-stat { padding: 0 26px; text-align: center; border-left: 1px solid var(--line); }
.ap-stat:first-child { border-left: 0; }
.ap-stat-num { font: 700 34px/1 var(--sans); color: var(--ivory); font-variant-numeric: tabular-nums; }
.ap-stat-of { font: 600 17px var(--sans); color: var(--slate); margin-left: 3px; }
.ap-stat-label { font: 400 15px var(--sans); color: var(--slate); margin-top: 8px; }

/* Grade badges (Game Review, Bots) */
.ap-grade { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font: 600 13px var(--sans); border: 1px solid; }
.ap-grade::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
/* Move grades (chess.com-style scale, in our palette) */
.ap-grade-brilliant { color: #3FD0CB; border-color: #1f7471; }
.ap-grade-great { color: #7FB2E5; border-color: #35557a; }
.ap-grade-best { color: var(--teal-bright); border-color: var(--teal-dim); }
.ap-grade-excellent { color: #7CC49A; border-color: #2f6246; }
.ap-grade-good { color: #A5BFB0; border-color: #45574d; }
.ap-grade-book { color: #D2B27A; border-color: var(--brass-dim); }
.ap-grade-inaccuracy { color: #E3C878; border-color: var(--brass-dim); }
.ap-grade-mistake { color: #E6A15A; border-color: #7a5424; }
.ap-grade-blunder { color: #E58A83; border-color: #7a3a3a; }

/* Tiny spinner */
.ap-spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--brass); animation: ap-spin .8s linear infinite; display: inline-block; vertical-align: -3px; }
@keyframes ap-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .ap-spin { animation-duration: 3s; } }

/* ---------- BoardUI ---------- */
.bui { container-type: inline-size; position: relative; width: 100%; aspect-ratio: 1 / 1; border-radius: 6px; overflow: hidden; border: 3px solid var(--line); box-sizing: border-box; user-select: none; }
.bui-squares { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); grid-template-rows: repeat(8, minmax(0, 1fr)); }
.bui-sq { position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; min-width: 0; min-height: 0; }
.bui-sq.is-light { background: #f0d9b5; }
.bui-sq.is-dark { background: #b58863; }
.bui-sq.is-last::before { content: ''; position: absolute; inset: 0; background: rgba(201, 162, 75, .42); }
.bui-sq.is-selected::before { content: ''; position: absolute; inset: 0; background: rgba(75, 145, 135, .55); }
.bui-sq.is-live { cursor: pointer; }
.bui-sq.is-target::after { content: ''; position: absolute; width: 28%; height: 28%; border-radius: 50%; background: rgba(18, 21, 26, .28); }
.bui-sq.is-capture::after { content: ''; position: absolute; inset: 4%; border-radius: 50%; border: 5px solid rgba(18, 21, 26, .28); }
.bui-piece { position: relative; z-index: 1; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.bui-piece img { width: 92%; height: 92%; pointer-events: none; }
.bui-piece:not(:has(img))::before { content: attr(data-glyph); font-size: 10cqi; line-height: 1; }
.bui-piece.bui-w:not(:has(img))::before { color: #fefefe; -webkit-text-stroke: 1.5px #202225; }
.bui-piece.bui-b:not(:has(img))::before { color: #1a1a1a; }
.bui-coord { position: absolute; z-index: 2; font: 700 clamp(7px, 2.2cqi, 11px) var(--mono); pointer-events: none; }
.bui-sq.is-light .bui-coord { color: #b58863; }
.bui-sq.is-dark .bui-coord { color: #f0d9b5; }
.bui-rank { top: 3px; left: 4px; }
.bui-file { bottom: 2px; right: 4px; }
.bui-arrows { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }
.bui-mark { position: absolute; z-index: 4; top: 3%; right: 3%; width: 30%; height: 30%; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.4); }
.bui-mark-blunder { background: #C8463E; }
.bui-mark-mistake { background: #D98A2B; }
.bui-mark-inaccuracy { background: #C9A24B; }
.bui-mark-best, .bui-mark-good, .bui-mark-book { background: var(--teal); }
/* Grade symbol on the square of the move (Game Review) */
.bui-mark { display: grid; place-items: center; font: 700 clamp(7px, 2.1cqi, 16px)/1 var(--sans); color: #fff; letter-spacing: -.04em; width: 34%; height: 34%; top: 2%; right: 2%; }
.bui-mark-brilliant { background: #1FA8A3; } .bui-mark-brilliant::after { content: '!!'; }
.bui-mark-great { background: #4F86C0; } .bui-mark-great::after { content: '!'; }
.bui-mark-best { background: var(--teal); } .bui-mark-best::after { content: '\2605'; }
.bui-mark-excellent { background: #3F9466; } .bui-mark-excellent::after { content: '\2713'; }
.bui-mark-good { background: #6E8A7A; } .bui-mark-good::after { content: '\2713'; }
.bui-mark-book { background: #A8844A; } .bui-mark-book::after { content: 'B'; }
.bui-mark-inaccuracy::after { content: '?!'; }
.bui-mark-mistake::after { content: '?'; }
.bui-mark-blunder::after { content: '??'; }
.bui-mark-missed { background: #C9A24B; } .bui-mark-missed::after { content: '\2715'; }
.bui-mark-mate { background: #2a2f38; } .bui-mark-mate::after { content: '#'; }

/* Eval bar for BoardUI pages */
.ap-evalbar { position: relative; width: 16px; border-radius: 4px; overflow: hidden; background: #2a2d33; border: 1px solid var(--line); flex: none; }
.ap-evalbar-fill { position: absolute; left: 0; right: 0; bottom: 0; height: 50%; background: var(--ivory); transition: height .35s ease; }
.ap-evalbar.is-flipped { background: var(--ivory); }
.ap-evalbar.is-flipped .ap-evalbar-fill { background: #2a2d33; }

/* Rating chart */
.ap-chart { position: relative; }
.ap-chart svg { display: block; width: 100%; height: 220px; overflow: visible; }
.ap-chart-grid { stroke: var(--line-soft); stroke-width: 1; }
.ap-chart-axis { font: 400 13px var(--sans); fill: var(--slate-dim); }
.ap-chart-line { fill: none; stroke: var(--brass); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.ap-chart-area { fill: rgba(201, 162, 75, .08); }
.ap-chart-hair { stroke: var(--slate); stroke-width: 1; stroke-dasharray: 3 3; }
.ap-chart-dot { fill: var(--brass); stroke: var(--ink-900); stroke-width: 2; }
.ap-tip {
  position: absolute; pointer-events: none; transform: translate(-50%, calc(-100% - 12px));
  background: var(--ink-800); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; white-space: nowrap;
  font: 400 13px var(--sans); color: var(--slate); box-shadow: 0 4px 14px rgba(0,0,0,.35);
}
.ap-tip strong { display: block; font: 700 15px var(--sans); color: var(--ivory); }
.ap-table-toggle { margin-top: 8px; font: 400 14px var(--sans); color: var(--slate); }
.ap-table-toggle summary { cursor: pointer; }
.ap-table { width: 100%; border-collapse: collapse; margin-top: 8px; font: 400 14px var(--sans); color: var(--slate); }
.ap-table th, .ap-table td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--line-soft); }

@media (max-width: 899px) {
  .ap-card { padding: 18px; border-radius: 14px; }
  .ap-stats { width: 100%; justify-content: space-between; }
  .ap-stat { padding: 0 10px; flex: 1; }
  .ap-stat-num { font-size: 26px; }
  .ap-stat-label { font-size: 13px; }
}

/* Footer inside the app column */
.coach-footer { max-width: 1180px; margin: 48px auto 0; padding-top: 20px; border-top: 1px solid var(--line-soft); }
.coach-footer nav { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 8px; }
.coach-footer a { font: 500 15px var(--sans); color: var(--slate); text-decoration: none; }
.coach-footer a:hover { color: var(--ivory); }
.coach-footer p { font: 400 14px var(--sans); color: var(--slate-dim); margin: 0; }

/* Profile: linked accounts */
.pf-accounts { display: grid; gap: 8px; margin: 12px 0; }
.pf-acct { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--ink-850); font: 500 15px var(--sans); color: var(--ivory); }
.pf-linkform .pf-site { width: auto; flex: 0 0 150px; }

/* Older pages moved into the app shell (Puzzles, Profile): drop their own top spacing */
.as-main > .landing-section { padding-top: 0; margin-top: 0; }
.as-main > .profile-wrap { margin-top: 0; padding-top: 0; }

/* Square highlights (BoardUI.setHighlights): point at pieces during a line walkthrough */
.bui-sq.is-hl-danger::before { content: ''; position: absolute; inset: 0; background: rgba(200, 70, 62, .38); box-shadow: inset 0 0 0 4px rgba(200, 70, 62, .95); z-index: 0; }
.bui-sq.is-hl-check::before { content: ''; position: absolute; inset: 0; background: radial-gradient(circle, rgba(230, 60, 50, .95) 0%, rgba(230, 60, 50, .55) 45%, rgba(230, 60, 50, 0) 75%); z-index: 0; }
.bui-sq.is-hl-good::before { content: ''; position: absolute; inset: 0; background: rgba(75, 145, 135, .35); box-shadow: inset 0 0 0 4px rgba(94, 196, 182, .95); z-index: 0; }
@media (prefers-reduced-motion: no-preference) { .bui-sq[class*="is-hl-"]::before { animation: bui-hl-in .35s ease-out; } }
@keyframes bui-hl-in { from { opacity: 0; } to { opacity: 1; } }
.bui-sq.is-check-flash::before { content: ''; position: absolute; inset: 0; z-index: 0; background: radial-gradient(circle, rgba(240, 45, 35, 1) 0%, rgba(240, 45, 35, .85) 55%, rgba(240, 45, 35, .35) 100%); box-shadow: inset 0 0 0 4px rgba(200, 30, 25, .9); }

/* ---- Puzzles: "Picked for you" from reviewed games (2026-09-30) ---- */
.fy-card { display: grid; grid-template-columns: 1fr auto; gap: 20px 28px; align-items: end; margin: 8px 0 20px; padding: 22px 24px; background: var(--ink-900); border: 1px solid var(--line); border-left: 4px solid var(--brass); border-radius: 16px; }
.fy-card:empty { display: none; }
.fy-eyebrow { font: 600 12px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--brass-bright); margin-bottom: 6px; }
.fy-title { font: 600 24px/1.2 var(--serif); color: var(--ivory); margin: 0 0 6px; }
.fy-lead { font: 400 15.5px/1.55 var(--sans); color: var(--ivory); margin: 0; max-width: 560px; }
.fy-card.is-empty .fy-lead { color: var(--slate); }
.fy-bars { margin: 14px 0 0; max-width: 420px; }
.fy-bars-h { font: 600 11.5px var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--slate-dim); margin-bottom: 6px; }
.fy-bar { display: grid; grid-template-columns: 104px 1fr 24px; gap: 10px; align-items: center; margin: 5px 0; font: 500 13.5px var(--sans); color: var(--slate); }
.fy-track { height: 8px; background: var(--line-soft); border-radius: 4px; overflow: hidden; }
.fy-fill { display: block; height: 100%; background: var(--teal); border-radius: 4px; }
.fy-bar.is-top { color: var(--ivory); }
.fy-bar.is-top .fy-fill { background: var(--brass); }
.fy-bar-n { font: 600 13px var(--mono); color: var(--ivory); text-align: right; }
.fy-foot { font: 12.5px var(--mono); color: var(--slate-dim); margin: 12px 0 0; }
.fy-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.fy-cta { font: 600 15px var(--sans); color: var(--ink-950, #0d1014); background: var(--brass-bright); border: none; border-radius: 10px; padding: 14px 20px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.fy-cta:hover, .fy-cta:focus-visible { background: var(--ivory); }
.fy-also { font: 13.5px var(--sans); color: var(--slate); text-align: right; }
.fy-link { background: none; border: none; padding: 0; font: 600 13.5px var(--sans); color: var(--teal-bright); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.fy-review { font-weight: 500; color: var(--slate); }
@media (max-width: 760px) {
  .fy-card { grid-template-columns: 1fr; padding: 18px; }
  .fy-actions { align-items: stretch; }
  .fy-cta { text-align: center; white-space: normal; }
  .fy-also { text-align: left; }
  .fy-title { font-size: 21px; }
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
