/* === TwitterVD website — shared base =======================================
   Loaded FIRST on every page under website/html/, before the page-level sheet:

     <link rel="stylesheet" href="base.css" />
     <link rel="stylesheet" href="<page>.css" />

   It holds the design tokens, the reset, the global keyboard-focus ring, the
   reduced-motion guard, and the pixel page chrome that index / privacy /
   welcome all share (status bar, nav, windows, buttons, footer, hero
   primitives, entrance animations). Page sheets add only what is genuinely
   page-specific, or override a single declaration where a page deliberately
   differs (e.g. --shadow on the welcome page).

   The uninstall page uses a different, utilitarian design system on purpose —
   it still loads this file for the reset/tokens/focus ring and opts out of the
   pixel body chrome; see uninstall/uninstall.css.
   ======================================================================== */

/* --- Design tokens --------------------------------------------------------
   Every colour used by the site lives here. Don't inline bare hexes in rules;
   add a token instead. (The extension has its own, different palette — see
   STYLES.md / src/pages/themes.ts. The two are not interchangeable.)         */
:root {
  /* Brand */
  --red: #e63946;
  --blue: #1da1f2;
  --green: #22c55e;
  --black: #1a1a1a;
  --white: #f5f5f5;
  --yellow: #f5c518;
  --gray: #c8c8c8;
  --bg: #f5f5f5;

  /* Neutrals, dark → light. Named for their dominant role (secondary text),
     but they double as the greyscale prop fills (TV knobs, rocket smoke).
     --text-dim sits 4 units off --text-muted; kept distinct so the hero
     rating line renders exactly as it did before. */
  --text-prose: #333;
  --text-note: #4a4a4a;
  --text-muted: #555;
  --text-dim: #595959;
  --text-soft: #666;
  --text-faint: #888;

  /* Surfaces */
  --paper: #fff;
  --surface-alt: #ebebeb;

  /* Dark neutrals — CRT/terminal prop fills and dark body copy */
  --dark-1: #2a2a2a;
  --dark-2: #333;
  --dark-3: #444;
  --screen-dark: #0a0a1a;
  --screen-text: #ccc;

  /* Type */
  --font-pixel: 'Press Start 2P', monospace;
  --font-vt: 'VT323', monospace;

  /* Lines & elevation */
  --border: 2px solid var(--black);
  --shadow: 2px 2px 0 var(--black);
}

/* --- Reset --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: auto;
}

/* --- Keyboard focus ring --------------------------------------------------
   Mirrors the extension's global rule in src/pages/main.sass. Blue on the
   light page background and on the black footer/status bars alike (≈6:1 on
   --black). Pages that put focusable elements on a light accent fill — e.g.
   the yellow contact block in privacy.css — re-point outline-color locally. */
:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* ==========================================================================
   PIXEL PAGE CHROME (index / privacy / welcome)
   ========================================================================== */

/* --- Page shell --- */
body {
  font-family: var(--font-pixel);
  background: var(--bg);
  color: var(--black);
  overflow-x: hidden;
  image-rendering: pixelated;
}

/* Pixel scanline overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.015) 2px,
    rgba(0, 0, 0, 0.015) 4px
  );
  pointer-events: none;
  z-index: 9999;
}

/* Grid background */
.pixel-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(26, 26, 26, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(26, 26, 26, 0.04) 1px, transparent 1px);
  background-size: 16px 16px;
  pointer-events: none;
  z-index: 0;
}

/* Pixel HR divider */
.pixel-hr {
  height: 4px;
  background: repeating-linear-gradient(
    90deg,
    var(--red) 0px,
    var(--red) 4px,
    var(--blue) 4px,
    var(--blue) 8px,
    var(--black) 8px,
    var(--black) 12px,
    var(--white) 12px,
    var(--white) 16px
  );
  border: none;
  margin: 0;
}

/* --- Status bar --- */
.status-bar {
  background: var(--black);
  color: var(--white);
  font-family: var(--font-pixel);
  font-size: 7px;
  text-align: center;
  padding: 5px 24px;
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  border-bottom: 2px solid var(--red);
}

.status-bar-sep {
  opacity: 0.4;
}

@keyframes blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

.status-dot {
  width: 6px;
  height: 6px;
  background: var(--green);
  display: inline-block;
  flex-shrink: 0;
  animation: blink 1s step-end infinite;
}

/* --- Nav --- */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--white);
  border-bottom: var(--border);
  transition: border-bottom-color 0s;
}

.nav.scrolled {
  border-bottom-color: var(--red);
}

.nav-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.nav-logo {
  font-family: var(--font-pixel);
  color: var(--black);
  text-decoration: none;
  display: flex;
  align-items: center;
}

.nav-logo img {
  image-rendering: pixelated;
  flex-shrink: 0;
}

.nav-logo-icon {
  width: 16px;
  height: 16px;
  background: var(--blue);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid var(--black);
}

.logo-twitter {
  color: var(--blue);
}

.nav-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--red);
  color: var(--white);
  font-family: var(--font-pixel);
  font-size: 8px;
  text-decoration: none;
  padding: 8px 14px;
  border: var(--border);
  box-shadow: var(--shadow);
  white-space: nowrap;
  transition: none;
  cursor: pointer;
}

.nav-cta:hover {
  background: var(--black);
  color: var(--white);
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 var(--black);
}

.nav-cta:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}

/* --- Buttons --------------------------------------------------------------
   The offset is written out rather than using var(--shadow): the welcome page
   re-points --shadow to 4px for its windows but its buttons stay at 2px.     */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--red);
  color: var(--white);
  font-family: var(--font-pixel);
  font-size: 9px;
  text-decoration: none;
  padding: 12px 20px;
  border: var(--border);
  box-shadow: 2px 2px 0 var(--black);
  transition: none;
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary:hover {
  background: var(--black);
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 var(--black);
}

.btn-primary:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}

.btn-primary.large {
  font-size: 10px;
  padding: 14px 24px;
}

/* --- Window chrome --------------------------------------------------------
   Sizes/paddings that differ per page (the welcome windows are a size up) are
   set in the page sheets.                                                    */
.win-titlebar {
  background: var(--blue);
  border-bottom: 2px solid var(--black);
  padding: 6px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.win-title {
  font-family: var(--font-pixel);
  font-size: 7px;
  color: var(--white);
  letter-spacing: 0.5px;
}

.win-controls {
  display: flex;
  gap: 4px;
}

.win-btn {
  border: 1px solid rgba(255, 255, 255, 0.6);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
}

.win-btn.close {
  background: rgba(255, 255, 255, 0.3);
}

.win-body {
  padding: 20px;
}

/* --- Hero primitives --- */
.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-pixel);
  font-size: 7px;
  background: var(--black);
  color: var(--white);
  padding: 6px 12px;
  margin-bottom: 24px;
  border: 2px solid var(--black);
}

.hero-title {
  font-family: var(--font-pixel);
  font-weight: 400;
  letter-spacing: -1px;
  color: var(--black);
  margin-bottom: 24px;
}

.hero-accent {
  color: var(--blue);
  text-decoration: underline;
  text-decoration-color: var(--red);
  text-decoration-thickness: 3px;
  text-underline-offset: 4px;
}

.hero-sub {
  font-family: var(--font-vt);
  color: var(--text-muted);
  line-height: 1.5;
}

.hero-sub strong {
  color: var(--black);
}

/* --- Footer --- */
.footer {
  position: relative;
  z-index: 1;
  background: var(--black);
  padding: 20px 0;
}

.footer-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.footer-logo {
  font-family: var(--font-pixel);
  font-size: 8px;
  color: var(--white);
}

.footer-sep {
  color: var(--red);
  font-family: var(--font-pixel);
  font-size: 10px;
}

.footer-link {
  font-family: var(--font-pixel);
  font-size: 7px;
  color: var(--gray);
  text-decoration: none;
  transition: none;
}

.footer-link:hover {
  color: var(--blue);
  text-decoration: underline;
}

.footer-right {
  font-family: var(--font-pixel);
  font-size: 6px;
  color: var(--text-muted);
}

/* Hidden until the counter script has a number to show. The welcome page
   opts out of that and renders it unconditionally — see welcome.css. */
.footer-visitors {
  display: none;
  font-family: var(--font-pixel);
  font-size: 6px;
  color: var(--text-faint);
  letter-spacing: 0.5px;
  line-height: 1;
  margin-left: auto;
}

.footer-visitors.is-visible {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.footer-visitors #footer-visitors-count {
  line-height: 1;
  vertical-align: middle;
}

.footer-visitors .dot {
  width: 5px;
  height: 5px;
  background: var(--green);
  display: inline-block;
  box-shadow: 0 0 0 1px var(--black);
  flex-shrink: 0;
}

/* ==========================================================================
   RETRO ENTRANCE ANIMATIONS
   Keyframes are inert until a page opts in. The load-time boot sequence
   (CRT power-on + nav drop + colour-cycling dot) is gated behind
   <body class="boot-anim"> because the welcome page deliberately shows a
   static status bar. The scroll-triggered .anim-* classes are added by each
   page's own script.
   ========================================================================== */

@keyframes crtOn {
  0% {
    opacity: 0;
    transform: scaleY(0.02);
    filter: brightness(3);
  }
  8% {
    opacity: 1;
    transform: scaleY(0.02);
    filter: brightness(6);
  }
  18% {
    opacity: 1;
    transform: scaleY(1);
    filter: brightness(2);
  }
  30% {
    filter: brightness(1.1);
  }
  100% {
    opacity: 1;
    transform: scaleY(1);
    filter: brightness(1);
  }
}

/* Pixel drop-in (integer step) */
@keyframes pixelDrop {
  0% {
    transform: translateY(-12px);
    opacity: 0;
  }
  40% {
    transform: translateY(-12px);
    opacity: 0;
  }
  60% {
    transform: translateY(2px);
    opacity: 1;
  }
  80% {
    transform: translateY(-2px);
    opacity: 1;
  }
  100% {
    transform: translateY(0px);
    opacity: 1;
  }
}

/* Retro marquee shimmer on status bar dots */
@keyframes dotScan {
  0%,
  100% {
    background: var(--green);
  }
  33% {
    background: var(--yellow);
  }
  66% {
    background: var(--blue);
  }
}

.boot-anim .status-bar {
  animation: crtOn 0.6s step-end both;
}

.boot-anim .nav {
  animation: pixelDrop 0.5s step-end 0.15s both;
}

.boot-anim .status-dot {
  animation: dotScan 2s step-end infinite;
}

/* --- Scroll-triggered entrance animations ---------------------------------
   Elements start hidden; the page script adds .anim-visible when they scroll
   into view.                                                                 */

/* base hidden state for all animated elements */
.anim-hidden {
  opacity: 0;
}

/* pixel-drop: items fall in from above with bounce */
.anim-drop {
  transform: translateY(-16px);
  opacity: 0;
  transition:
    transform 0.3s steps(6, end),
    opacity 0.2s steps(3, end);
}
.anim-drop.anim-visible {
  transform: translateY(0px);
  opacity: 1;
}

/* slide-left: items enter from the left */
.anim-left {
  transform: translateX(-24px);
  opacity: 0;
  transition:
    transform 0.3s steps(5, end),
    opacity 0.2s steps(3, end);
}
.anim-left.anim-visible {
  transform: translateX(0px);
  opacity: 1;
}

/* slide-right: items enter from the right */
.anim-right {
  transform: translateX(24px);
  opacity: 0;
  transition:
    transform 0.3s steps(5, end),
    opacity 0.2s steps(3, end);
}
.anim-right.anim-visible {
  transform: translateX(0px);
  opacity: 1;
}

/* pixel-pop: scale from 0 */
.anim-pop {
  transform: scale(0);
  opacity: 0;
  transform-origin: center bottom;
  transition:
    transform 0.25s steps(4, end),
    opacity 0.15s steps(2, end);
}
.anim-pop.anim-visible {
  transform: scale(1);
  opacity: 1;
}

/* scanline-wipe: clip from top to bottom */
.anim-wipe {
  clip-path: inset(0 0 100% 0);
  opacity: 0;
  transition:
    clip-path 0.35s steps(8, end),
    opacity 0.1s steps(1, end);
}
.anim-wipe.anim-visible {
  clip-path: inset(0 0 0% 0);
  opacity: 1;
}

/* blink-in: retro loading flicker */
.anim-blink {
  opacity: 0;
  transition: opacity 0.4s steps(6, end);
}
.anim-blink.anim-visible {
  opacity: 1;
}

/* --- Reduced motion -------------------------------------------------------
   Site-wide: covers every page's animations, including the ones declared in
   the page sheets, since this file is loaded everywhere.                     */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
