/*
Theme Name:        SalemWire Terminal
Author:            SalemWire
Description:       Terminal presentation layer for the SalemWire newswire engine. Liquid three-to-one column wire, CRT display profiles (Blue/Green/Amber/Mono), SHARP/SOFT screen setting, boot grammar, glyph status, optional vector field and micro-sound. Requires the SalemWire Core plugin for content; renders a plain readable wire without JavaScript.
Version:           1.0.1
Requires at least: 6.2
Requires PHP:      7.4
License:           GPL-2.0-or-later
License URI:       https://www.gnu.org/licenses/gpl-2.0.html
Text Domain:       salemwire-terminal
Tags:              news, dark, three-columns, accessibility-ready
*/

/* =====================================================================
   1. CRT DISPLAY PROFILES — render profiles, not color themes.
   Profiles change expression only: never content, order, semantics,
   accessibility or feed state (packet §9).
   Custom properties:
     --sw-bg          field (background)
     --sw-ink         primary phosphor (body/headlines)
     --sw-ink-dim     dim phosphor (meta, blurbs, rules-adjacent text)
     --sw-accent      utility/label accent
     --sw-alert       alert/failure
     --sw-rule        structural rules
     --sw-vector      vector field stroke (consumed by JS)
     --sw-glow        glow radius multiplier (SHARP/SOFT scales this)
     --sw-glow-color  glow tint
   ===================================================================== */

:root,
html[data-sw-profile="blue"] {
	/* BLUE PHOSPHOR — SalemWire default. Serious broadcast character,
	   deliberately distinct from APNU fluorescent green. */
	--sw-bg: #030d16;
	--sw-ink: #8fd8f8;
	--sw-ink-dim: #64a9c8;
	--sw-accent: #cdeeff;
	--sw-alert: #ff9d9d;
	--sw-rule: #12405c;
	--sw-vector: 47, 148, 199;
	--sw-glow: 1;
	--sw-glow-color: rgba(80, 190, 255, 0.55);
}

html[data-sw-profile="green"] {
	/* GREEN PHOSPHOR — classic VDT; field color from APNU evidence. */
	--sw-bg: #020904;
	--sw-ink: #58e39c;
	--sw-ink-dim: #43ad78;
	--sw-accent: #b8ffd9;
	--sw-alert: #ffa1a1;
	--sw-rule: #0f4227;
	--sw-vector: 0, 255, 136;
	--sw-glow: 1;
	--sw-glow-color: rgba(0, 255, 136, 0.5);
}

html[data-sw-profile="amber"] {
	/* AMBER PHOSPHOR — warm low-light CRT. */
	--sw-bg: #0d0700;
	--sw-ink: #ffc069;
	--sw-ink-dim: #c69354;
	--sw-accent: #ffe3b3;
	--sw-alert: #ff9d9d;
	--sw-rule: #4f3410;
	--sw-vector: 255, 176, 76;
	--sw-glow: 1;
	--sw-glow-color: rgba(255, 180, 90, 0.5);
}

html[data-sw-profile="mono"] {
	/* MONO — restrained cool white/gray, high legibility, minimal glow. */
	--sw-bg: #0b0b0d;
	--sw-ink: #e8e8ee;
	--sw-ink-dim: #b0b0bc;
	--sw-accent: #ffffff;
	--sw-alert: #ffa1a1;
	--sw-rule: #33333c;
	--sw-vector: 190, 190, 205;
	--sw-glow: 0.25;
	--sw-glow-color: rgba(230, 230, 240, 0.35);
}

/* SCREEN axis — independent from profile. Both are terminal-dark; this is
   NOT light/dark mode (packet §9). SOFT lowers glow and intensity only;
   text contrast is preserved. */
html[data-sw-screen="soft"] {
	--sw-glow: 0.15;
}

/* =====================================================================
   2. BASE
   ===================================================================== */

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
	margin: 0;
	background: var(--sw-bg);
	color: var(--sw-ink);
	font-family: "SF Mono", "Cascadia Mono", Consolas, "DejaVu Sans Mono", Menlo, monospace;
	font-size: 16px;
	line-height: 1.45;
	overflow-x: hidden;
}

img { max-width: 100%; height: auto; }

a { color: var(--sw-ink); }
a:hover { color: var(--sw-accent); }

:focus-visible {
	outline: 2px solid var(--sw-accent);
	outline-offset: 2px;
}

.screen-reader-text {
	position: absolute !important;
	width: 1px; height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

.sw-skip-link {
	position: absolute;
	left: -9999px;
	top: 0;
	background: var(--sw-bg);
	color: var(--sw-accent);
	padding: 0.5em 1em;
	z-index: 1000;
}
.sw-skip-link:focus { left: 0; }

.sw-wrapper {
	max-width: 1640px;
	margin: 0 auto;
	padding: 0 16px 40px;
	position: relative;
	z-index: 1; /* Above the vector field canvas. */
}

/* =====================================================================
   3. MASTHEAD — configurable brand, aspect-ratio-agnostic logo,
   optional compact status line. No editorial hero (packet §5).
   ===================================================================== */

.sw-masthead {
	text-align: center;
	padding: 22px 0 10px;
}

.sw-logo-link { display: inline-block; text-decoration: none; }

.sw-logo {
	display: block;
	margin: 0 auto;
	max-height: 150px;
	width: auto;
	max-width: 100%;
	object-fit: contain; /* Square dev logo and future horizontal logo both undistorted. */
	filter: drop-shadow(0 0 calc(6px * var(--sw-glow)) var(--sw-glow-color));
}

.sw-logo-text {
	font-size: clamp(1.8rem, 5vw, 3.2rem);
	font-weight: 700;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	text-shadow: 0 0 calc(10px * var(--sw-glow)) var(--sw-glow-color);
}

.sw-status-line {
	margin: 8px auto 0;
	font-size: 0.72rem;
	letter-spacing: 0.22em;
	text-transform: uppercase;
	color: var(--sw-ink-dim);
}
.sw-status-line .sw-status-live { color: var(--sw-accent); }

/* =====================================================================
   4. TICKER — optional, server-rendered text, pausable, motion-safe.
   ===================================================================== */

.sw-ticker {
	display: flex;
	align-items: center;
	gap: 12px;
	border-top: 1px solid var(--sw-rule);
	border-bottom: 1px solid var(--sw-rule);
	margin: 10px 0;
	padding: 4px 8px;
	overflow: hidden;
}

.sw-ticker-pause {
	flex: none;
	background: transparent;
	border: 1px solid var(--sw-rule);
	color: var(--sw-ink-dim);
	font: inherit;
	font-size: 0.7rem;
	letter-spacing: 0.1em;
	text-transform: uppercase;
	padding: 2px 8px;
	cursor: pointer;
}

.sw-ticker-track {
	display: flex;
	gap: 3em;
	list-style: none;
	margin: 0;
	padding: 0;
	white-space: nowrap;
	animation: sw-ticker-scroll 60s linear infinite;
}
/* Explicit toggle (JS). */
.sw-ticker.paused .sw-ticker-track { animation-play-state: paused; }
/* Keyboard reading affordance. Without JS the whole ticker pauses on focus —
   the only pause available there. With JS the button owns the sticky state,
   so the CSS pause narrows to the track's links; otherwise the button holding
   focus after Resume would keep the crawl frozen (ISSUES L-23). */
.sw-ticker:not(.sw-ticker-js):focus-within .sw-ticker-track,
.sw-ticker.sw-ticker-js .sw-ticker-track:focus-within { animation-play-state: paused; }
.sw-ticker-track a { text-decoration: none; }
.sw-ticker-track a:hover,
.sw-ticker-track a:focus { text-decoration: underline; }

@keyframes sw-ticker-scroll {
	from { transform: translateX(100%); }
	to   { transform: translateX(-100%); }
}

/* =====================================================================
   5. WIRE — liquid three-to-one grid. Three channels of one instrument.
   Reading order (DOM = narrow-screen order): utility → col1 → col2 → col3.
   ===================================================================== */

.sw-wire {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	border-top: 1px solid var(--sw-rule);
	margin-top: 6px;
}

.sw-col {
	min-width: 0;
	padding: 18px 20px 30px;
}
.sw-col + .sw-col { border-left: 1px solid var(--sw-rule); }

/* Column 1 utility head is pinned above its wire stream. */
.sw-utility { margin-bottom: 20px; }

.sw-utility .sw-module-head,
.sw-utility .sw-insert-links .sw-headline {
	letter-spacing: 0.05em;
}

/* Modules */
.sw-module { margin: 0 0 26px; }

.sw-module-head {
	font-size: 0.78rem;
	font-weight: 700;
	letter-spacing: 0.2em;
	text-transform: uppercase;
	color: var(--sw-ink-dim);
	margin: 0 0 10px;
	border-bottom: 1px solid var(--sw-rule);
	padding-bottom: 4px;
}

.sw-headlines,
.sw-insert-links ul {
	list-style: none;
	margin: 0;
	padding: 0;
}

.sw-item { margin: 0 0 14px; }

.sw-headline {
	display: inline;
	font-size: 1.02rem;
	line-height: 1.35;
	text-decoration: underline;
	text-underline-offset: 3px;
	text-decoration-thickness: 1px;
	text-shadow: 0 0 calc(7px * var(--sw-glow)) var(--sw-glow-color);
	overflow-wrap: break-word;
}

.sw-item-date,
.sw-item-blurb {
	display: block;
	font-size: 0.82rem;
	color: var(--sw-ink-dim);
	margin-top: 2px;
}

.sw-module-empty {
	color: var(--sw-ink-dim);
	font-size: 0.85rem;
	font-style: italic;
}

/* Inserts */
.sw-insert-body { font-size: 0.95rem; }
.sw-insert-links li { margin: 0 0 8px; }

/* Revenue: visually distinct from editorial headlines (packet §6.6).
   The ADVERTISEMENT label is real markup rendered by the Insert Engine, not
   generated content, so it survives with styles unavailable (ISSUES L-09). */
.sw-insert-revenue {
	border: 1px dashed var(--sw-rule);
	padding: 10px;
}
.sw-revenue-label {
	display: block;
	margin: 0 0 6px;
	font-size: 0.6rem;
	letter-spacing: 0.3em;
	color: var(--sw-ink-dim);
	text-transform: uppercase;
}

/* Slots */
.sw-slot { padding: 8px 0; text-align: center; }
/* A region emptied by a soft refresh must not leave its spacing behind. */
.sw-slot:empty, .sw-utility:empty, .sw-stream:empty { display: none; }
.sw-slot .sw-module { margin-bottom: 12px; }

/* =====================================================================
   6. FOOTER
   ===================================================================== */

.sw-footer {
	border-top: 1px solid var(--sw-rule);
	margin-top: 10px;
	padding: 24px 16px 90px;
	text-align: center;
	font-size: 0.85rem;
	color: var(--sw-ink-dim);
}

/* =====================================================================
   7. PUBLIC CONTROLS — tiny (packet §9): SCREEN + AUDIO. Rendered by JS
   (they control enhancement only); keyboard accessible.
   ===================================================================== */

.sw-controls {
	position: fixed;
	left: 16px;
	bottom: 16px;
	z-index: 50;
	display: flex;
	gap: 8px;
}

.sw-control {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	background: color-mix(in srgb, var(--sw-bg) 82%, black);
	border: 1px solid var(--sw-rule);
	border-radius: 20px;
	color: var(--sw-ink);
	font: inherit;
	font-size: 0.68rem;
	font-weight: 700;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	padding: 7px 14px;
	cursor: pointer;
}
.sw-control:hover { border-color: var(--sw-ink-dim); }

.sw-control .sw-led {
	width: 8px;
	height: 8px;
	border-radius: 50%;
	background: var(--sw-rule);
}
.sw-control[aria-pressed="true"] .sw-led {
	background: var(--sw-ink);
	box-shadow: 0 0 calc(8px * var(--sw-glow)) var(--sw-glow-color);
}

/* =====================================================================
   8. VECTOR FIELD CANVAS — atmosphere only; below content; ignored by AT.
   ===================================================================== */

.sw-vector-canvas {
	position: fixed;
	inset: 0;
	width: 100vw;
	height: 100vh;
	z-index: 0;
	pointer-events: none;
	user-select: none;
}

/* =====================================================================
   9. EXPRESSION — event-driven, brief, causally connected. All motion is
   removed under prefers-reduced-motion.
   ===================================================================== */

/* Boot: applied ONLY when the early inline gate script adds the class
   (JS present, gate elapsed, motion allowed). Opacity/filter only — no
   layout change, no CLS, and server-rendered text is never destroyed. */
html.sw-boot-pending .sw-masthead,
html.sw-boot-pending .sw-wire,
html.sw-boot-pending .sw-ticker,
html.sw-boot-pending .sw-slot,
html.sw-boot-pending .sw-footer {
	opacity: 0;
}

html.sw-booting .sw-masthead { animation: sw-resolve 0.28s ease-out forwards; }
html.sw-booting .sw-ticker,
html.sw-booting .sw-slot { animation: sw-resolve 0.3s ease-out 0.18s forwards; }
/* All three columns energize simultaneously — one instrument. */
html.sw-booting .sw-wire { animation: sw-energize 0.5s cubic-bezier(0.23, 1, 0.32, 1) 0.16s forwards; }
html.sw-booting .sw-footer { animation: sw-resolve 0.3s ease-out 0.4s forwards; }

@keyframes sw-resolve {
	from { opacity: 0; }
	to   { opacity: 1; }
}

@keyframes sw-energize {
	0%   { opacity: 0; filter: brightness(2.4) contrast(1.5); }
	60%  { opacity: 1; filter: brightness(1.25) contrast(1.1); }
	100% { opacity: 1; filter: brightness(1) contrast(1); }
}

/* PULSE — one restrained resolve on a newly arrived headline. */
.sw-pulse { animation: sw-pulse 1.1s ease-out 1; }

@keyframes sw-pulse {
	0%   { text-shadow: 0 0 calc(16px * var(--sw-glow)) var(--sw-glow-color); color: var(--sw-accent); }
	100% { text-shadow: 0 0 calc(7px * var(--sw-glow)) var(--sw-glow-color); color: var(--sw-ink); }
}

/* FLASH — brief module-level acknowledgment (e.g. feed recovered). */
.sw-flash { animation: sw-flash 0.6s ease-out 1; }

@keyframes sw-flash {
	0%   { filter: brightness(1.8); }
	100% { filter: brightness(1); }
}

/* Glyph cursor used by the glyph renderer in the status line. */
.sw-glyph-cursor {
	display: inline-block;
	animation: sw-blink 0.5s steps(1) infinite alternate;
}
@keyframes sw-blink { from { opacity: 0.15; } to { opacity: 1; } }

/* Reduced motion: preserve structure and meaning, remove motion
   (packet §8.2, §11). Boot classes resolve instantly. */
@media (prefers-reduced-motion: reduce) {
	html.sw-boot-pending .sw-masthead,
	html.sw-boot-pending .sw-wire,
	html.sw-boot-pending .sw-ticker,
	html.sw-boot-pending .sw-slot,
	html.sw-boot-pending .sw-footer { opacity: 1; }

	.sw-ticker-track {
		animation: none;
		white-space: normal;
		flex-wrap: wrap;
		gap: 1em;
	}

	.sw-pulse, .sw-flash, .sw-glyph-cursor,
	html.sw-booting .sw-masthead,
	html.sw-booting .sw-wire,
	html.sw-booting .sw-ticker,
	html.sw-booting .sw-slot,
	html.sw-booting .sw-footer { animation: none; }
}

/* =====================================================================
   10. DENSITY (admin preset)
   ===================================================================== */

html[data-sw-density="compact"] .sw-item { margin-bottom: 8px; }
html[data-sw-density="compact"] .sw-headline { font-size: 0.95rem; }
html[data-sw-density="compact"] .sw-module { margin-bottom: 18px; }

/* =====================================================================
   11. RESPONSIVE — liquid 3 → 1. No primary horizontal scroll.
   ===================================================================== */

@media (max-width: 1024px) {
	.sw-col { padding: 14px 14px 24px; }
}

@media (max-width: 768px) {
	.sw-wire { grid-template-columns: minmax(0, 1fr); }
	.sw-col + .sw-col { border-left: none; border-top: 1px solid var(--sw-rule); }
	.sw-logo { max-height: 110px; }
	body { font-size: 15px; }
	.sw-controls { left: 10px; bottom: 10px; }
}

/* =====================================================================
   12. SINGULAR CONTENT (pages/posts fallback — the wire is the product;
   this is a plain readable surface, not a magazine layout).
   ===================================================================== */

.sw-singular {
	max-width: 760px;
	margin: 0 auto;
	padding: 20px 0 60px;
}
.sw-singular .sw-title { font-size: 1.7rem; line-height: 1.3; }
.sw-singular .sw-content { color: var(--sw-ink); }
.sw-singular .sw-content a { color: var(--sw-accent); }

/* =====================================================================
   13. PRINT — plain wire, no effects.
   ===================================================================== */

@media print {
	body { background: #fff; color: #000; }
	.sw-vector-canvas, .sw-controls, .sw-ticker-pause { display: none !important; }
	.sw-headline { color: #000; text-shadow: none; }
}
