/*
Theme Name: Night Carrier
Theme URI: https://cjkoehn.com
Author: C.J. Koehn
Author URI: https://cjkoehn.com
Description: A BBS/CRT-terminal theme for a speculative fiction journal. Palette and monospace-terminal feel are drawn from int10h.org's oldschool PC font showcase (black background, light-gray body text, bright yellow links); the boxed layout, scanline overlay, and phosphor-glow treatment carry over the green-CRT / desert-night-radio mood of the SF writing site it replaces. Supports posts with featured images, YouTube embeds (via core oEmbed), a repeatable Downloads box, a repeatable Related Links box, and a dedicated Links/webring page template.
Version: 1.0.0
Requires at least: 6.0
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: night-carrier
*/

/* -------------------------------------------------------------
   0. Font faces
   -------------------------------------------------------------
   VT323 (Google Fonts, enqueued in functions.php) is the theme's
   default terminal font — the one every design mockup was built
   and approved against. int10h.org's "IBM VGA 8x16" webfont files
   are supported as an optional upgrade: drop them into this
   theme's /fonts/ folder (see readme.txt) and they take priority
   over VT323 automatically, since they're listed first below.
------------------------------------------------------------- */
@font-face {
  font-family: 'IBM VGA 8x16';
  src: url('fonts/Px437_IBM_VGA8.woff') format('woff'),
       url('fonts/Px437_IBM_VGA8.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* -------------------------------------------------------------
   1. Variables — Classic DOS palette (int10h.org's own colors:
   black bg / light-gray text / bright-yellow links), with three
   phosphor-CRT alternates switchable from the Customizer.
------------------------------------------------------------- */
:root {
  --bg: #000000;
  --bg-panel: #0a0a0a;
  --fg: #aaaaaa;
  --fg-bright: #ffffff;
  --fg-dim: #6b6b6b;
  --accent: #ffff55;
  --accent-glow: rgba(255, 255, 85, 0.45);
  --border: #3a3a3a;
  --box-glow: rgba(120, 160, 140, 0.08);
  --mono: 'IBM VGA 8x16', 'VT323', ui-monospace, Consolas, Menlo, 'Courier New', monospace;
  --img-filter: none;
}

/* Matched directly against sfwriting.chriskoehn.ca's own computed
   styles: #000 background, pure #00ff00 text and links, Courier New,
   bold links with no underline. Kept faithful to that, with a touch
   of CRT glow and a slightly brighter shade reserved for headings so
   there's some visual hierarchy. */
body.phosphor-green {
  --bg: #000000;
  --bg-panel: #030a03;
  --fg: #00ff00;
  --fg-bright: #7dff7d;
  --fg-dim: #0b8a0b;
  --accent: #33ff33;
  --accent-glow: rgba(0, 255, 0, 0.5);
  --border: #123312;
  --box-glow: rgba(0, 255, 0, 0.12);
  --img-filter: grayscale(60%) sepia(40%) hue-rotate(60deg) saturate(220%) brightness(0.9);
}
body.phosphor-green a { font-weight: 700; }

body.phosphor-amber {
  --bg: #0a0601;
  --bg-panel: #1a1004;
  --fg: #ffb000;
  --fg-bright: #ffd980;
  --fg-dim: #8a5c00;
  --accent: #ff5a3f;
  --accent-glow: rgba(255, 90, 63, 0.45);
  --border: #4a3000;
  --box-glow: rgba(255, 176, 0, 0.10);
  --img-filter: sepia(35%) saturate(160%) hue-rotate(-8deg) brightness(0.95);
}

/* Blue-white phosphor — the cooler, slightly-blue "paper white" look
   used on Panasonic and similar dedicated word-processor CRTs, as
   distinct from a plain grayscale monitor. */
body.phosphor-white {
  --bg: #030304;
  --bg-panel: #0b0b10;
  --fg: #e4e4f4;
  --fg-bright: #ffffff;
  --fg-dim: #8888a8;
  --accent: #a9c8ff;
  --accent-glow: rgba(169, 200, 255, 0.5);
  --border: #33334a;
  --box-glow: rgba(210, 210, 255, 0.14);
  --img-filter: grayscale(70%) saturate(120%) hue-rotate(190deg) brightness(1.05) contrast(1.05);
}

/* -------------------------------------------------------------
   2. Reset & base
------------------------------------------------------------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 17px;
  line-height: 1.6;
  margin: 0;
  min-height: 100vh;
}
img, video, iframe { max-width: 100%; height: auto; }
a { color: var(--accent); text-decoration: none; }
a:hover, a:focus { text-decoration: underline; text-shadow: 0 0 6px var(--accent-glow); }
h1, h2, h3, h4 {
  font-family: var(--mono);
  color: var(--fg-bright);
  text-shadow: 0 0 8px var(--box-glow);
  line-height: 1.25;
  margin: 0 0 0.6em;
}
p { margin: 0 0 1em; }
::selection { background: var(--accent); color: var(--bg); }

/* -------------------------------------------------------------
   3. CRT scanline + vignette overlay
------------------------------------------------------------- */
.crt-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0.18) 0px,
      rgba(0, 0, 0, 0.18) 1px,
      transparent 1px,
      transparent 3px
    ),
    radial-gradient(ellipse at center, transparent 60%, rgba(0, 0, 0, 0.55) 100%);
  mix-blend-mode: multiply;
  opacity: 0.6;
}
@media (prefers-reduced-motion: no-preference) {
  .crt-overlay { animation: nc-flicker 7s infinite; }
}
@keyframes nc-flicker {
  0%, 96%, 100% { opacity: 0.6; }
  97% { opacity: 0.45; }
  98% { opacity: 0.65; }
}

/* -------------------------------------------------------------
   4. Layout shell
------------------------------------------------------------- */
.content-wrap {
  min-width: 0;
}
.site-header {
  border-bottom: 1px solid var(--border);
  padding: 40px 20px 24px;
  text-align: left;
}
.site-header-inner { max-width: 1400px; margin: 0 auto; }

/* BBS/word-processor status readout — decorative, shown above the
   site title on every page. Sized to read as its own banner, the
   way it does on a real word-processor screen, not a fine-print
   caption. */
.statusline {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 24px;
  font-size: 1.4rem;
  letter-spacing: 1.5px;
  text-shadow: 0 0 6px var(--box-glow);
  color: var(--fg);
  text-align: left;
}
.statusline .status-left span { margin-right: 30px; }
.ruler {
  font-size: 1.1rem;
  letter-spacing: 0.5px;
  color: var(--fg);
  text-shadow: 0 0 5px var(--box-glow);
  white-space: pre;
  overflow-x: auto;
  overflow-y: hidden;
  text-align: left;
  margin: 4px 0 0;
}
.site-title {
  display: inline-block;
  font-size: 2rem;
  font-weight: normal;
  color: var(--fg-bright);
  text-shadow: 0 0 10px var(--box-glow);
  letter-spacing: 1px;
  margin-top: 22px;
}
.nc-cursor {
  display: inline-block;
  animation: nc-blink 1s steps(1) infinite;
}
@keyframes nc-blink { 0%, 50% { opacity: 1; } 51%, 100% { opacity: 0; } }
.site-tagline { color: var(--fg-dim); margin: 6px 0 18px; }
.site-nav ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 4px 0;
  margin: 0;
  padding: 0;
}
.site-nav li { margin: 0; }
.site-nav a {
  display: inline-block;
  padding: 4px 14px;
  color: var(--fg);
  border-right: 1px solid var(--border);
}
.site-nav li:first-child a { padding-left: 0; }
.site-nav li:last-child a { border-right: none; }
.site-nav a:hover { color: var(--accent); text-decoration: none; }

/* -------------------------------------------------------------
   4b. Sidebar layout
   -------------------------------------------------------------
   Wraps the main column between two fixed-width sidebar columns.
   Opened in header.php right after <main>, closed in footer.php
   right before </main> — every template's own .content-wrap sits
   between sidebar-left.php and sidebar-right.php as the middle
   grid item, unchanged.
------------------------------------------------------------- */
.site-layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 780px) 230px;
  justify-content: center;
  gap: 40px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 20px 60px;
  align-items: start;
}
.col-left, .col-right { min-width: 0; }

.widget {
  border: 1px solid var(--border);
  background: var(--bg-panel);
  box-shadow: 0 0 18px var(--box-glow);
  padding: 18px 20px;
  margin-bottom: 26px;
}
.widget h3, .widget .widget-title {
  font-weight: normal;
  font-size: 1rem;
  margin: 0 0 12px;
  color: var(--fg-bright);
  text-shadow: 0 0 6px var(--box-glow);
  border-bottom: 1px dashed var(--border);
  padding-bottom: 8px;
  letter-spacing: 1px;
}
.widget p { font-size: 0.95rem; line-height: 1.45; margin: 0; color: var(--fg); }
.widget ul { list-style: none; margin: 0; padding: 0; font-size: 0.95rem; }
.widget li { margin-bottom: 9px; }
.widget li a { color: var(--fg); }
.widget li a:hover { color: var(--accent); }

@media (max-width: 1000px) {
  .site-layout { grid-template-columns: 1fr; }
  .content-wrap { order: 1; }
  .col-left { order: 2; }
  .col-right { order: 3; }
}

/* -------------------------------------------------------------
   5. Boxes, posts, buttons
------------------------------------------------------------- */
.nc-box {
  border: 1px solid var(--border);
  background: var(--bg-panel);
  box-shadow: 0 0 24px var(--box-glow);
  padding: 24px 26px;
  margin: 34px 0;
}
.post-list { margin-top: 30px; }
.entry-title a { color: var(--fg-bright); }
.entry-title a:hover { color: var(--accent); }
.entry-meta {
  color: var(--fg-dim);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 16px;
}
.entry-thumb-full { display: block; margin: 16px 0; border: 1px solid var(--border); }
.entry-excerpt, .entry-content { color: var(--fg); }

/* Post-list snippet layout: thumbnail to the right of the text,
   matched to the text block's height — recreated from the mockup. */
.post-flex { display: flex; gap: 24px; align-items: stretch; }
.entry-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.entry-text .entry-excerpt { flex-grow: 1; }
.entry-thumb {
  display: block;
  flex-shrink: 0;
  width: 200px;
  border: 1px solid var(--border);
  overflow: hidden;
  margin: 0;
}
.entry-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; filter: var(--img-filter); }
@media (max-width: 600px) {
  .post-flex { flex-direction: column; }
  .entry-thumb { width: 100%; height: 200px; }
}
.entry-content h2, .entry-content h3 { margin-top: 1.4em; }
.entry-content blockquote {
  border-left: 3px solid var(--accent);
  margin: 1.4em 0;
  padding: 0.2em 1em;
  color: var(--fg-dim);
}
.entry-content pre, .entry-content code {
  background: var(--bg);
  border: 1px solid var(--border);
  font-family: var(--mono);
}
.entry-content pre { padding: 14px; overflow-x: auto; }
.entry-content code { padding: 1px 5px; }

.nc-button {
  display: inline-block;
  margin-top: 6px;
  color: var(--accent);
  border: 1px solid var(--border);
  padding: 6px 14px;
  font-family: var(--mono);
}
.nc-button:hover {
  border-color: var(--accent);
  text-decoration: none;
  box-shadow: 0 0 10px var(--accent-glow);
}

.ascii-divider {
  color: var(--border);
  overflow: hidden;
  white-space: nowrap;
  text-align: center;
  letter-spacing: 2px;
  user-select: none;
}

/* Downloads / Related links boxes */
.nc-downloads h3, .nc-links h3, .nc-linkroll h2 {
  font-size: 1rem;
  color: var(--fg-bright);
  border-bottom: 1px dashed var(--border);
  padding-bottom: 8px;
  margin-bottom: 14px;
}
.nc-downloads ul, .nc-links ul, .nc-linkroll ul { list-style: none; margin: 0; padding: 0; }
.nc-downloads li { margin-bottom: 10px; }
.nc-links li { margin-bottom: 8px; }
.nc-note { color: var(--fg-dim); font-size: 0.9rem; }

/* -------------------------------------------------------------
   5b. ASCII art & BBS-style highlighting
   -------------------------------------------------------------
   .ascii-art: wrap any ASCII/box-drawing art in a <pre class="ascii-art">
   block (use the block editor's "Custom HTML" block, or just paste
   into a Preformatted/Code block and add the class via the block's
   Advanced panel). It won't wrap or reflow, and scrolls horizontally
   on narrow screens instead of breaking the art.

   Site-wide ASCII banner: set one from Appearance > Customize >
   Site Identity > ASCII Banner, and it replaces the plain text site
   title in the header.

   BBS highlight: WordPress's built-in text Highlight tool (select
   text in a paragraph > toolbar > the highlighter icon) now renders
   as inverse video by default — background in the current phosphor
   color, text in the background color — like a BBS menu selection.
   A few extra named swatches (Signal, Inverse, Dim, Void) are also
   available from the block editor's text/background color pickers
   for one-off highlighted phrases.
------------------------------------------------------------- */
.ascii-art, pre.ascii-art {
  font-family: var(--mono);
  white-space: pre;
  overflow-x: auto;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 16px 20px;
  line-height: 1.15;
  margin: 24px 0;
}
.ascii-banner {
  display: inline-block;
  font-family: var(--mono);
  white-space: pre;
  overflow-x: auto;
  max-width: 100%;
  color: var(--fg-bright);
  text-shadow: 0 0 10px var(--box-glow);
  line-height: 1.1;
  margin: 0;
  text-align: left;
}

/* WordPress's native text-highlight tool → BBS inverse video */
mark, .entry-content mark {
  background: var(--fg);
  color: var(--bg);
  padding: 0 4px;
  text-shadow: none;
}

/* Named editor swatches (registered in functions.php) rendered
   using the theme's live CSS variables, so they track whichever
   phosphor mode is active rather than being fixed colors. */
.has-nc-signal-color { color: var(--accent) !important; }
.has-nc-signal-background-color { background-color: var(--accent) !important; color: var(--bg) !important; }
.has-nc-inverse-background-color { background-color: var(--fg) !important; color: var(--bg) !important; padding: 0 4px; }
.has-nc-dim-color { color: var(--fg-dim) !important; }
.has-nc-void-background-color { background-color: var(--bg) !important; }
.has-nc-bright-color { color: var(--fg-bright) !important; }

/* -------------------------------------------------------------
   6. Embeds (YouTube etc. via core oEmbed) — responsive 16:9
------------------------------------------------------------- */
.nc-embed {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  margin: 20px 0;
  border: 1px solid var(--border);
  background: #000;
}
.nc-embed iframe, .nc-embed embed, .nc-embed object {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* -------------------------------------------------------------
   7. Comments
------------------------------------------------------------- */
.comments-area h3 { font-size: 1rem; }
.comment-list { list-style: none; margin: 0; padding: 0; }
.comment-list li { border-top: 1px dashed var(--border); padding: 14px 0; }
.comment-list .comment-author { color: var(--fg-bright); }
.comment-list .comment-metadata { color: var(--fg-dim); font-size: 0.8rem; }
.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form input[type="url"],
.comment-form textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--fg);
  font-family: var(--mono);
  padding: 8px 10px;
  margin-bottom: 12px;
}
.comment-form .form-submit input {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-family: var(--mono);
  padding: 8px 18px;
  cursor: pointer;
}

/* -------------------------------------------------------------
   8. Footer & widgets
------------------------------------------------------------- */
.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 60px;
  padding: 30px 20px 40px;
  text-align: center;
  color: var(--fg-dim);
  font-size: 0.85rem;
}
.footer-widgets {
  max-width: 1400px;
  margin: 0 auto 20px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  text-align: left;
}
.widget-title { font-size: 0.9rem; color: var(--fg-bright); }

/* -------------------------------------------------------------
   9. Pagination
------------------------------------------------------------- */
.pagination { text-align: center; margin: 40px 0; }
.pagination a, .pagination span {
  display: inline-block;
  padding: 6px 12px;
  border: 1px solid var(--border);
  margin: 0 3px;
  color: var(--fg);
}
.pagination .current { color: var(--accent); border-color: var(--accent); }

/* -------------------------------------------------------------
   10. Small screens
------------------------------------------------------------- */
@media (max-width: 600px) {
  body { font-size: 15.5px; }
  .site-title { font-size: 1.5rem; }
  .nc-box { padding: 18px 16px; }
  .statusline { font-size: 1.05rem; }
  .ruler { font-size: 0.95rem; }
}
