/* =================================================================
   Page-specific rules for the tool and community pages:
   console, badge builder, live stream, statistics, reviews, feedback,
   report abuse, legal and the error page. Everything shared lives in
   style.css; this file only uses its tokens.
   ================================================================= */

/* ---- Shared pieces ---- */
.card-h { font-family: var(--font-primary); font-size: 1.1rem; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 1rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.75rem; }
.card-h-gap { margin-top: 2rem; padding-top: 1.5rem; border-top: 1px dashed var(--border-strong); }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }
.btn-neon.btn-sm, .btn-outline-neon.btn-sm { font-size: 0.82rem; padding: 0.3rem 0.7rem; }
.btn-danger-quiet:hover, .btn-danger-quiet:focus-visible { color: var(--err); border-color: var(--err); }
.mono-input { font-family: var(--font-mono); font-size: 0.85rem; }
.form-text em, .act-hint em { font-style: normal; color: var(--text-dim); font-weight: 600; }
.form-check-label { color: var(--text-dim); }
.detail-card details { background: var(--surface-2); margin: 1rem 0 0; }
.detail-card > details:last-child { margin-bottom: 0; }
.form-card { max-width: 760px; }
.outro-note { color: var(--text-dim); }
.section > .detail-card + p, .section > .callout + .btn-row { margin-top: 1.25rem; }
.empty { text-align: left; max-width: 620px; }

/* Result boxes filled by page scripts */
.result { margin-top: 1rem; padding: 0.85rem 1rem; border: 1px solid var(--border); border-left: 3px solid var(--ok); border-radius: var(--radius); background: var(--surface-2); color: var(--text-dim); overflow-wrap: anywhere; }
.result.is-err { border-left-color: var(--err); }
.result strong { color: var(--text); }
.result.is-err strong { color: var(--err); }
.result > div + div { margin-top: 0.4rem; }
.result code { color: var(--accent); overflow-wrap: anywhere; }
.result pre { margin: 0.4rem 0 0; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 320px; }

/* Groups of related controls */
.act { border: 0; border-top: 1px dashed var(--border-strong); margin: 1.5rem 0 0; padding: 1.25rem 0 0; min-width: 0; }
.act > legend { float: none; width: auto; padding: 0 0.6rem 0 0; margin: 0; font-family: var(--font-mono); font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent); }
.act-hint { color: var(--text-dim); font-size: 0.92rem; max-width: var(--measure); margin-bottom: 0.9rem; }
.act .form-check { margin-bottom: 0.35rem; }

/* ---- Console ---- */
.console-pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; align-items: start; margin-top: 1.5rem; }
.v1-card { margin-top: 1.5rem; }
.v1-tokens { max-width: none; margin-top: 1.5rem; }
.v1-status { font-family: var(--font-mono); font-size: 0.9rem; color: var(--text); margin-bottom: 0.25rem; }
.v1-countdown { font-size: 0.85rem; color: var(--text-faint); }
.v1-output-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.75rem; }
.v1-output-row .form-label { margin: 0; }
.v1-output-row .form-select { width: auto; min-width: 14rem; flex: 0 1 auto; }
.v1-badge img { display: block; }
#v1-result { min-height: 3.4rem; max-height: 420px; }
#v1-curl, #v1-headers { max-height: 260px; }

/* ---- Badge builder ---- */
.bb { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); grid-template-areas: "options preview" "options snippets"; grid-template-rows: auto 1fr; gap: 1rem; align-items: start; }
.bb-preview { grid-area: preview; }
.bb-options { grid-area: options; }
.bb-snippets { grid-area: snippets; }
.bb-stage { display: flex; align-items: center; justify-content: center; min-height: 96px; padding: 1.25rem; margin-bottom: 0.9rem; background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.bb-stage img { height: 28px; width: auto; max-width: 100%; }
.bb-options .act:first-of-type { border-top: 0; margin-top: 0; padding-top: 0; }
.bb-options .act:first-of-type > legend { margin-bottom: 0.75rem; }
.bb-snippets .code-wrap { margin: 0.75rem 0; }

/* ---- Live stream ---- */
.stream-head-row { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.75rem; }
.stream-head-row .sec-title { margin-bottom: 0; }
.stream-head-badges { display: flex; gap: 0.4rem; align-items: center; }
.sim-badge, .nova-badge { letter-spacing: 0.08em; }
.nova-badge { box-shadow: 0 0 12px var(--accent); }
.stream-card { position: relative; }

.achievement-toast {
  position: absolute; top: 0.85rem; right: 0.85rem; z-index: 5;
  background: var(--surface-2); border: 1px solid var(--accent); border-radius: var(--radius);
  padding: 0.45rem 0.75rem; font-size: 0.8rem; color: var(--text);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55);
  opacity: 0; transform: translateY(-6px); pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.achievement-toast.is-visible { opacity: 1; transform: translateY(0); }
.toast-tag { font-family: var(--font-mono); font-size: 0.68rem; color: var(--accent); font-weight: 700; margin-right: 0.35rem; }

.stream-hud { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.75rem; margin-bottom: 0.85rem; }
.hud-cell { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.65rem 0.85rem; display: flex; flex-direction: column; gap: 0.22rem; min-width: 0; }
.hud-label { font-family: var(--font-mono); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.09em; color: var(--text-faint); }
.hud-value { font-family: var(--font-mono); font-weight: 700; font-size: 1.02rem; color: var(--text); }
.hud-value small { font-size: 0.72rem; font-weight: 500; color: var(--text-faint); }
.hud-sub { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-dim); }
.hud-bar { width: 100%; height: 6px; background: var(--code-bg); border: 1px solid var(--border); border-radius: 99px; overflow: hidden; margin-top: 0.15rem; }
.hud-bar-fill { height: 100%; width: 0%; background: var(--accent); transition: width 0.35s ease, background-color 0.25s ease; }
.hud-bar-fill.is-overdrive { background: var(--err); box-shadow: 0 0 10px var(--err); }
.hud-core-fill { background: var(--post); }
.hud-xp-fill { background: var(--get); }

.mode-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.75rem; }
.mode-group { display: inline-flex; flex-wrap: wrap; gap: 0.35rem; }
.mode-group .btn.is-active, #btn-play[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

.arcade-hud { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.45rem 0.75rem; margin-bottom: 0.65rem; border: 1px solid var(--accent-line); border-radius: var(--radius); background: var(--accent-dim); font-family: var(--font-mono); font-size: 0.76rem; color: var(--text); }
.arcade-stats strong { color: var(--accent); }

.scale-select { width: auto; font-family: var(--font-mono); font-size: 0.76rem; padding: 0.25rem 0.5rem; height: auto; }

.playground-card { margin-top: 1rem; }
.playground-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.65rem; }
.playground-desc { margin: 0.25rem 0 0; font-size: 0.88rem; color: var(--text-dim); }
.playground-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; }
.playground-actions .btn-row { margin-top: 0; }
.playground-curl { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.3rem 0.55rem; font-size: 0.78rem; }

.canvas-wrap { position: relative; }
.stream-canvas { display: block; width: 100%; height: 280px; background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius); cursor: crosshair; }

.sparkline-wrap { margin-top: 0.85rem; }
.sparkline-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.35rem; font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-faint); }
.sparkline-canvas { display: block; width: 100%; height: 44px; background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius); }

.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 0.35rem 1rem; padding: 0; margin: 0; font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-dim); }
.legend li { display: inline-flex; align-items: center; gap: 0.4rem; }
.legend-dot { width: 14px; height: 3px; border-radius: 2px; background: var(--accent); }
.legend-incr { background: var(--post); }
.legend-decr { background: var(--put); }
.legend-read { background: var(--get); }

.action-pills { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.6rem; margin-top: 0.9rem; }
.action-pill { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.45rem 0.65rem; }
.pill-n { font-family: var(--font-mono); font-weight: 700; font-size: 0.92rem; color: var(--text); }
.action-pill.is-flashing { animation: pill-flash 0.45s ease-out; }
@keyframes pill-flash { 0% { border-color: var(--accent); background: var(--surface-3); } 100% { border-color: var(--border); background: var(--surface-2); } }

.stream-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem; margin-top: 0.85rem; padding-top: 0.85rem; border-top: 1px dashed var(--border-strong); }
.stream-footer .form-text { margin: 0; }
.stream-controls { margin-top: 0; }

.badges-section { margin: 1.15rem 0 1rem; }
.badges-strip { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.45rem; }
.badge-item { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.3rem 0.6rem; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); font-family: var(--font-mono); font-size: 0.74rem; color: var(--text-faint); opacity: 0.62; transition: opacity 0.2s ease, border-color 0.2s ease; }
.badge-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--border-strong); }
.badge-item.is-unlocked { opacity: 1; border-color: var(--accent-line); color: var(--text); background: var(--accent-dim); }
.badge-item.is-unlocked .badge-dot { background: var(--accent); box-shadow: 0 0 6px var(--accent); }

.stat-read { color: var(--get); }
.activity { list-style: none; padding: 0; margin: 0; max-height: 460px; overflow-y: auto; }
.activity-row { display: flex; align-items: center; gap: 0.5rem 0.9rem; padding: 0.55rem 0.25rem; border-bottom: 1px dashed var(--border); animation: activity-in 0.3s ease-out; }
.activity-row:last-child { border-bottom: 0; }
.activity-row .mchip { min-width: 3.4rem; text-align: center; }
.activity-text { flex: 1; min-width: 0; color: var(--text-dim); font-size: 0.92rem; }
.activity-time { font-family: var(--font-mono); font-size: 0.75rem; color: var(--text-faint); white-space: nowrap; }
.activity-empty { color: var(--text-faint); padding: 1rem 0.25rem; }
@keyframes activity-in { from { opacity: 0; } }

/* ---- Traffic panel (shared by stream and statistics) ---- */
.metrics-line { color: var(--text-dim); min-height: 4.5rem; }
.metrics-line .stat-row { margin-top: 0; }
.metrics-note { font-size: 0.85rem; color: var(--text-faint); margin: 0; }

/* ---- Statistics ---- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); gap: 1rem; margin-top: 1.5rem; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--accent); border-radius: var(--radius-lg); padding: 1.1rem 1.25rem 1.2rem; min-width: 0; }
.kpi:nth-child(4n+2) { border-top-color: var(--get); }
.kpi:nth-child(4n+3) { border-top-color: var(--post); }
.kpi:nth-child(4n+4) { border-top-color: var(--put); }
.kpi-label { font-family: var(--font-mono); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-faint); }
.kpi-n { font-family: var(--font-mono); font-weight: 800; font-size: clamp(1.6rem, 3vw, 2.1rem); line-height: 1.2; color: var(--text); margin: 0.35rem 0 0.3rem; overflow-wrap: anywhere; }
.kpi-n small { font-size: 0.8rem; font-weight: 500; color: var(--text-faint); }
.kpi-sub { font-size: 0.85rem; color: var(--text-dim); line-height: 1.45; }

.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-top: 1.5rem; }
.chart { margin: 0; min-width: 0; }
.chart-wide { grid-column: 1 / -1; }
.chart-box { position: relative; height: 280px; }
.chart-box-round { height: 250px; }
.pairs { display: flex; flex-wrap: wrap; gap: 0.5rem 2rem; margin: 1rem 0 0; padding-top: 0.9rem; border-top: 1px dashed var(--border-strong); }
.pairs > div { display: flex; align-items: baseline; gap: 0.5rem; }
.main-content .pairs dt { margin: 0; font-weight: 400; font-size: 0.85rem; color: var(--text-faint); }
.main-content .pairs dd { margin: 0; font-family: var(--font-mono); font-weight: 700; color: var(--text); }
.bars { display: grid; gap: 1.1rem; margin-top: 1rem; }
.bar-row { display: grid; grid-template-columns: 9rem minmax(0, 1fr) 11rem; align-items: center; gap: 0.4rem 1rem; }
.bar-label { font-size: 0.9rem; font-weight: 600; color: var(--text); }
.bar { -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 12px; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.bar::-webkit-progress-bar { background: var(--surface-2); }
.bar::-webkit-progress-value { background: var(--accent); }
.bar::-moz-progress-bar { background: var(--accent); }
.bar-count { font-family: var(--font-mono); font-size: 0.78rem; color: var(--text-dim); text-align: right; }

/* ---- Reviews ---- */
.review { display: flex; flex-direction: column; }
.review .review-stars { font-size: 1.15rem; margin-bottom: 0.75rem; }
.review-stars-off { color: var(--border-strong); }
.review-text { color: var(--text); font-size: 1rem; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; margin-bottom: 1rem; }
.review-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.9rem; margin-top: auto; padding-top: 0.85rem; border-top: 1px dashed var(--border-strong); font-size: 0.88rem; }
.review-author { color: var(--text); font-weight: 650; }
.review-date { color: var(--text-faint); margin-left: auto; font-family: var(--font-mono); font-size: 0.75rem; }

/* ---- Feedback ---- */
a.choice { text-decoration: none; }
a.choice .tile-title { display: block; color: var(--text); }
a.choice .tile-title::after { content: ' →'; color: var(--text-faint); transition: color 0.15s ease; }
a.choice:hover .tile-title, a.choice:hover .tile-title::after { color: var(--accent); }
a.choice .tile-text { display: block; margin: 0; }
.star-field { border: 0; padding: 0; margin: 0 0 1.5rem; min-width: 0; }
.star-field > legend { float: none; width: auto; margin-bottom: 0.35rem; }
.star-rating { position: relative; display: inline-flex; flex-direction: row-reverse; gap: 0.1rem; font-size: 2.4rem; line-height: 1; }
.star-rating input { position: absolute; left: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; }
.star-rating label { cursor: pointer; padding: 0 0.1rem; color: var(--text-faint); border-radius: 4px; transition: color 0.15s ease; }
.star-rating label:hover, .star-rating label:hover ~ label, .star-rating input:checked ~ label { color: var(--accent); }
.star-rating input:focus-visible + label { outline: 2px solid var(--accent-hi); outline-offset: 2px; }

/* ---- Report abuse ---- */
.confirm { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); padding: 0.9rem 1.1rem; margin-bottom: 1.5rem; font-size: 0.92rem; }
.confirm p { margin-bottom: 0.4rem; }
.confirm ul { margin: 0; padding-left: 1.2rem; }
.prose-list { padding-left: 1.3rem; max-width: var(--measure); }
.prose-list li { color: var(--text-dim); margin-bottom: 0.5rem; }
.prose-list li::marker { color: var(--accent); font-family: var(--font-mono); font-size: 0.85em; }

/* ---- Legal ---- */
.legal-item { max-width: 78ch; margin-bottom: 2rem; }
.legal-item p, .legal-item li { color: var(--text-dim); }
.legal-item ul { padding-left: 1.2rem; }
.legal-item li { margin-bottom: 0.3rem; }
.legal-item li::marker { color: var(--accent); }
.main-content .legal-h { font-size: 1.15rem; font-weight: 700; margin: 0 0 0.75rem; padding-bottom: 0.5rem; border-bottom: 1px dashed var(--border-strong); }
.legal-note, .legal-updated { font-size: 0.88rem; color: var(--text-faint); }
.legal-note { margin-top: 1rem; }
.legal-updated { font-family: var(--font-mono); margin-top: 3rem; }

/* ---- Error page ---- */
.error-head { border-bottom: 0 !important; margin-bottom: 1rem !important; }
.error-head::after { display: none; }
.error-code { display: block; font-size: 2.2em; line-height: 0.9; }

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .console-pair, .charts { grid-template-columns: minmax(0, 1fr); }
  .bb { grid-template-columns: minmax(0, 1fr); grid-template-areas: "preview" "options" "snippets"; grid-template-rows: auto; }
  .stream-hud { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .btn-row .btn { flex: 1 1 auto; }
  .bar-row { grid-template-columns: 1fr; gap: 0.3rem; }
  .bar-count { text-align: left; }
  .stream-hud { grid-template-columns: minmax(0, 1fr); }
  .stream-canvas { height: 210px; }
  .action-pills { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-box { height: 230px; }
  .star-rating { font-size: 2.1rem; }
  .review-date { margin-left: 0; }
  .v1-output-row .form-select { width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .canvas-wrap { display: none; }
  .hud-bar-fill, .achievement-toast, .action-pill.is-flashing { transition: none; animation: none; }
}

/* Links inside help text need more than colour to stand out */
.form-text a { text-decoration: underline; text-underline-offset: 2px; }
