/*
 * CALMFAX marketing — teletext styling.
 * World System Teletext Level 1 palette on black, blocky monospace, a subtle
 * CRT flourish (static scanlines; any motion is guarded by reduced-motion).
 */

:root {
  --tt-black: #000000;
  --tt-red: #ff3232;
  --tt-green: #22c822;
  --tt-yellow: #ffe100;
  --tt-blue: #4b6bff;
  --tt-magenta: #ff5cf0;
  --tt-cyan: #22d3d3;
  --tt-white: #f2f2f2;
  --tt-dim: #9aa0a6;

  --bg: #050505;
  --maxw: 60rem;
  --font:
    'Cascadia Mono', 'Consolas', 'SFMono-Regular', ui-monospace, 'Liberation Mono', Menlo, monospace;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--tt-white);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.55;
  letter-spacing: 0.02em;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
}

/* Static scanline overlay for a gentle CRT feel. */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.28) 3px
  );
  mix-blend-mode: multiply;
  z-index: 50;
}

a {
  color: var(--tt-cyan);
  text-underline-offset: 3px;
}
a:hover {
  color: var(--tt-white);
}

.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* ---- Teletext header row ------------------------------------------------ */
.ttx-header {
  border-bottom: 2px solid #1a1a1a;
}
.ttx-header .row {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 0.75rem 0;
  font-weight: 700;
  letter-spacing: 0.12em;
}
.pageno {
  color: var(--tt-cyan);
}
.brand {
  color: var(--tt-yellow);
}
.clock {
  margin-left: auto;
  color: var(--tt-white);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---- Hero --------------------------------------------------------------- */
/* Use longhand vertical padding so .wrap's horizontal padding is preserved
   (a `padding` shorthand here would zero the left/right inset on mobile). */
.hero {
  padding-top: 3.5rem;
  padding-bottom: 2rem;
}
.hero h1 {
  margin: 0;
  font-size: clamp(2.75rem, 9vw, 5.5rem);
  line-height: 0.95;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--tt-yellow);
  text-shadow: 0 0 18px rgba(255, 225, 0, 0.35);
}
.hero .tagline {
  margin: 1rem 0 0;
  font-size: clamp(1.1rem, 2.6vw, 1.5rem);
  color: var(--tt-cyan);
}
.hero .sub {
  margin: 1.25rem 0 0;
  max-width: 42rem;
  color: var(--tt-white);
}

/* ---- Call-to-action key -------------------------------------------------- */
.cta {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 1.75rem;
  padding: 0.85rem 1.4rem;
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-decoration: none;
  color: var(--tt-black);
  background: var(--tt-green);
  border: 2px solid var(--tt-green);
  border-radius: 4px;
}
.cta:hover {
  color: var(--tt-black);
  background: var(--tt-white);
  border-color: var(--tt-white);
}
.cta.secondary {
  color: var(--tt-white);
  background: transparent;
  border-color: #2b2b2b;
}
.cta.secondary:hover {
  color: var(--tt-black);
  background: var(--tt-cyan);
  border-color: var(--tt-cyan);
}
.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* ---- Teletext mosaic block graphics ------------------------------------- */
/* A subtle nod to Ceefax "block graphics": chunky coloured mosaic cells.
   Purely decorative (aria-hidden in markup). */
.mosaic {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 0.7rem;
  grid-template-rows: repeat(2, 0.7rem);
  gap: 3px;
  width: max-content;
  max-width: 100%;
  margin: 1.9rem 0 0.25rem;
  opacity: 0.92;
}
.mosaic span {
  border-radius: 2px;
}
.mosaic .tall {
  grid-row: span 2;
}
.mosaic .r {
  background: var(--tt-red);
}
.mosaic .y {
  background: var(--tt-yellow);
}
.mosaic .g {
  background: var(--tt-green);
}
.mosaic .c {
  background: var(--tt-cyan);
}
.mosaic .b {
  background: var(--tt-blue);
}
.mosaic .m {
  background: var(--tt-magenta);
}
.mosaic .w {
  background: var(--tt-white);
}

/* Small mosaic marker before section headings — two stacked block cells. */
.section h2::before,
.doc h2::before {
  content: '';
  display: inline-block;
  width: 0.5em;
  height: 0.95em;
  margin-right: 0.55em;
  vertical-align: -0.08em;
  background: linear-gradient(currentColor 0 42%, transparent 42% 58%, currentColor 58% 100%);
}

/* ---- Section headings --------------------------------------------------- */
/* Longhand vertical padding keeps .wrap's horizontal inset intact on mobile. */
.section {
  padding-top: 2.25rem;
  padding-bottom: 2.25rem;
  border-top: 2px solid #141414;
}
.section h2 {
  margin: 0 0 1.25rem;
  font-size: 1.15rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--tt-green);
}

/* ---- Teletext "contents" listing --------------------------------------- */
.contents {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.35rem;
}
.contents li {
  display: grid;
  grid-template-columns: 3.5rem 1fr;
  gap: 0.75rem;
  align-items: baseline;
}
.contents .n {
  color: var(--tt-green);
  font-weight: 700;
}
.contents .d {
  color: var(--tt-white);
}
.contents .d small {
  display: block;
  color: var(--tt-dim);
  letter-spacing: 0.01em;
}

/* ---- Feature grid ------------------------------------------------------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1.25rem;
}
.card {
  border: 2px solid #171717;
  border-radius: 6px;
  padding: 1.1rem 1.15rem;
  background: #080808;
}
.card h3 {
  margin: 0 0 0.5rem;
  color: var(--tt-cyan);
  font-size: 1rem;
  letter-spacing: 0.06em;
}
.card p {
  margin: 0;
  color: var(--tt-white);
}

/* ---- Coming soon: Pro --------------------------------------------------- */
.pro-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}
.pro-head h2 {
  margin: 0;
  color: var(--tt-magenta);
}
.soon {
  display: inline-block;
  padding: 0.12rem 0.55rem;
  color: var(--tt-black);
  background: var(--tt-magenta);
  border-radius: 3px;
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.pro .sub {
  max-width: 46rem;
  margin: 0 0 1.5rem;
  color: var(--tt-white);
}
.pro-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 1rem;
}
.pro-card {
  border: 2px solid #1c1420;
  border-top: 3px solid var(--tt-magenta);
  border-radius: 6px;
  padding: 1rem 1.15rem 1.15rem;
  background: linear-gradient(180deg, #0d070d 0%, #070707 60%);
}
.pro-card .n {
  display: inline-block;
  margin-bottom: 0.5rem;
  color: var(--tt-magenta);
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
}
.pro-card h3 {
  margin: 0 0 0.4rem;
  color: var(--tt-cyan);
  font-size: 1rem;
  letter-spacing: 0.04em;
}
.pro-card p {
  margin: 0;
  color: var(--tt-white);
  font-size: 0.95rem;
}

/* ---- Newsletter signup -------------------------------------------------- */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}
.signup .sub {
  max-width: 46rem;
}
.signup-form {
  margin-top: 1.5rem;
  max-width: 34rem;
}
.signup-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: stretch;
}
.signup-row input[type='email'] {
  flex: 1 1 16rem;
  min-width: 0;
  padding: 0.85rem 1rem;
  font: inherit;
  color: var(--tt-white);
  background: #080808;
  border: 2px solid #2b2b2b;
  border-radius: 4px;
}
.signup-row input[type='email']::placeholder {
  color: var(--tt-dim);
}
.signup-row input[type='email']:focus {
  outline: none;
  border-color: var(--tt-cyan);
}
.signup-row .cta {
  margin-top: 0;
  flex: 0 0 auto;
}
/* Honeypot: taken fully out of the layout and off-screen, never displayed. */
.signup-hp {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.signup-consent {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  margin-top: 1rem;
  color: var(--tt-dim);
  font-size: 0.9rem;
  line-height: 1.5;
}
.signup-consent input {
  margin-top: 0.2rem;
  accent-color: var(--tt-green);
}
.signup-consent a {
  color: var(--tt-cyan);
}
.signup-status {
  min-height: 1.4em;
  margin: 0.9rem 0 0;
  font-size: 0.92rem;
  color: var(--tt-dim);
}
.signup-status.is-ok {
  color: var(--tt-green);
}
.signup-status.is-error {
  color: var(--tt-red);
}

/* ---- Fastext-style footer ---------------------------------------------- */
.foot {
  margin-top: auto;
  border-top: 2px solid #141414;
  padding: 1.5rem 0 2.5rem;
}
.fastext {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}
.fastext a {
  text-align: center;
  padding: 0.55rem 0.4rem;
  border-radius: 4px;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--tt-black);
}
.fastext .r {
  background: var(--tt-red);
}
.fastext .g {
  background: var(--tt-green);
}
.fastext .y {
  background: var(--tt-yellow);
}
.fastext .b {
  background: var(--tt-blue);
  color: var(--tt-white);
}
.legal {
  color: var(--tt-dim);
  font-size: 0.85rem;
  line-height: 1.6;
}
.legal a {
  color: var(--tt-dim);
}
.legal a:hover {
  color: var(--tt-white);
}

/* ---- Legal / prose pages ------------------------------------------------ */
/* Longhand vertical padding keeps .wrap's horizontal inset intact on mobile. */
.doc {
  padding-top: 2rem;
  padding-bottom: 3rem;
  max-width: 46rem;
}
.doc h1 {
  color: var(--tt-yellow);
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  letter-spacing: 0.04em;
  margin: 0 0 0.25rem;
}
.doc .updated {
  color: var(--tt-dim);
  margin: 0 0 2rem;
}
.doc h2 {
  color: var(--tt-green);
  font-size: 1.1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 2rem 0 0.6rem;
}
.doc h3 {
  color: var(--tt-cyan);
  font-size: 1rem;
  margin: 1.5rem 0 0.4rem;
}
.doc p,
.doc li {
  color: var(--tt-white);
}
.doc ul {
  padding-left: 1.25rem;
}
.doc .note {
  border-left: 3px solid var(--tt-magenta);
  padding: 0.5rem 0 0.5rem 1rem;
  color: var(--tt-dim);
  margin: 1.5rem 0;
}
.back {
  display: inline-block;
  margin-bottom: 1.5rem;
  color: var(--tt-cyan);
  text-decoration: none;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--tt-yellow);
  color: #000;
  padding: 0.5rem 0.75rem;
  z-index: 100;
}
.skip-link:focus {
  left: 0;
}

@media (max-width: 40rem) {
  .fastext {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

/* ---- Help / guide page -------------------------------------------------- */
.lead {
  color: var(--tt-white);
  font-size: 1.08rem;
  margin: 0 0 1.5rem;
}

kbd {
  display: inline-block;
  min-width: 1.5rem;
  padding: 0.1rem 0.45rem;
  text-align: center;
  color: var(--tt-white);
  background: #111;
  border: 1px solid #333;
  border-bottom-width: 2px;
  border-radius: 4px;
  font-family: var(--font);
  font-size: 0.85rem;
  line-height: 1.4;
}

.tag {
  display: inline-block;
  padding: 0.05rem 0.45rem;
  color: var(--tt-black);
  background: var(--tt-cyan);
  border-radius: 3px;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.tag.alt {
  background: var(--tt-green);
}

/* Keyboard legend */
.keys {
  list-style: none;
  padding: 0;
  margin: 1rem 0 1.5rem;
  display: grid;
  gap: 0.5rem;
}
.keys li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.keys li span {
  color: var(--tt-dim);
}

/* Colour swatch key */
.swatch-key {
  list-style: none;
  padding: 0;
  margin: 1rem 0 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.swatch-key li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.65rem 0.35rem 0.4rem;
  border: 1px solid #1c1c1c;
  border-radius: 4px;
  background: #080808;
  color: var(--tt-white);
}
.swatch-key .chip {
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

/* Sextant (2x3 block) diagram */
.sextant {
  display: grid;
  grid-template-columns: repeat(2, 2.4rem);
  grid-template-rows: repeat(3, 2.4rem);
  gap: 3px;
  width: max-content;
  margin: 1rem 0 1.5rem;
  padding: 3px;
  background: #1c1c1c;
  border-radius: 4px;
}
.sextant span {
  background: #0a0a0a;
  border-radius: 2px;
}
.sextant span.on {
  background: var(--tt-white);
}

/* Numbered steps */
.steps {
  counter-reset: step;
  list-style: none;
  padding: 0;
  margin: 1rem 0 1.5rem;
  display: grid;
  gap: 0.65rem;
}
.steps li {
  position: relative;
  padding-left: 2.5rem;
  color: var(--tt-white);
  min-height: 1.7rem;
}
.steps li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 1.7rem;
  height: 1.7rem;
  display: grid;
  place-items: center;
  color: var(--tt-black);
  background: var(--tt-green);
  border-radius: 4px;
  font-weight: 700;
}

/* Definition rows (control reference) */
.defs {
  margin: 1rem 0 1.5rem;
  display: grid;
  gap: 0.55rem;
}
.defs > div {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: 0.85rem;
  align-items: baseline;
}
.defs dt {
  margin: 0;
}
.defs dd {
  margin: 0;
  color: var(--tt-white);
}

@media (max-width: 40rem) {
  .defs > div {
    grid-template-columns: 5rem 1fr;
    gap: 0.6rem;
  }
}

/* ---- Article figures (retro TV set frame) ------------------------------ */
.doc figure {
  margin: 2rem 0;
}
.doc figure.hero-figure {
  margin: 1.75rem 0 2.25rem;
}
.tv-frame {
  position: relative;
  margin: 0;
  padding: 0.7rem 0.7rem 0.55rem;
  background: linear-gradient(160deg, #1c1c1c 0%, #0c0c0c 100%);
  border: 1px solid #2a2a2a;
  border-radius: 10px;
  box-shadow:
    inset 0 0 0 2px #050505,
    0 10px 30px rgba(0, 0, 0, 0.55);
}
.tv-frame img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 4px;
  filter: saturate(1.02) contrast(1.02);
}
/* Faint scanline + vignette over the picture for a CRT feel. */
.tv-frame::after {
  content: '';
  position: absolute;
  inset: 0.7rem 0.7rem 0.55rem;
  pointer-events: none;
  border-radius: 4px;
  background:
    radial-gradient(120% 120% at 50% 50%, transparent 62%, rgba(0, 0, 0, 0.35) 100%),
    repeating-linear-gradient(
      to bottom,
      rgba(0, 0, 0, 0) 0,
      rgba(0, 0, 0, 0) 2px,
      rgba(0, 0, 0, 0.16) 3px
    );
  mix-blend-mode: multiply;
}
.doc figcaption {
  margin-top: 0.7rem;
  color: var(--tt-dim);
  font-size: 0.85rem;
  line-height: 1.5;
  border-left: 3px solid var(--tt-cyan);
  padding-left: 0.75rem;
}

/* Two-up figure gallery */
.tv-gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin: 2rem 0;
}
.tv-gallery figure {
  margin: 0;
}
@media (max-width: 40rem) {
  .tv-gallery {
    grid-template-columns: 1fr;
  }
}
