/* ==========================================
   THEME
   ========================================== */

:root {
  color-scheme: light;

  --background: #f5f5f2;
  --foreground: #171719;
  --muted: #66666e;
  --border: #d8d8d3;
  --button-hover: #e8e8e3;

  --rgb-red: #ff1638;
  --rgb-green: #00ed58;
  --rgb-blue: #164bff;

  --scanline-opacity: 0.07;
  --noise-opacity: 0.035;
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --background: #101113;
  --foreground: #f4f4f0;
  --muted: #a2a2ab;
  --border: #303137;
  --button-hover: #202126;

  --rgb-red: #ff1638;
  --rgb-green: #00ff60;
  --rgb-blue: #2855ff;

  --scanline-opacity: 0.12;
  --noise-opacity: 0.045;
}

/* ==========================================
   GLOBAL
   ========================================== */

* {
  box-sizing: border-box;
}

html {
  background: var(--background);
}

body {
  margin: 0;

  min-height: 100vh;
  min-height: 100svh;

  display: flex;
  flex-direction: column;

  background: var(--background);
  color: var(--foreground);

  font-family: "Courier New", Courier, monospace;
}

html.theme-ready body {
  transition:
    background-color 200ms ease,
    color 200ms ease;
}

.svg-definitions {
  position: absolute;

  width: 0;
  height: 0;
  overflow: hidden;

  pointer-events: none;
}

/* ==========================================
   HEADER
   ========================================== */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;

  padding: 28px clamp(20px, 5vw, 72px);
}

/* Home com cursor de digitação. */

.site-header .brand {
  display: inline-flex;
  align-items: center;
  gap: 3px;

  color: var(--foreground);

  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.5px;
  text-decoration: none;
}

.site-header .brand .brand-cursor {
  display: inline-block;
  flex: 0 0 1px;

  width: 1px;
  height: 0.95em;
  margin: 0;

  background-color: var(--muted);

  opacity: 0.8;

  animation: brand-caret-blink 1s steps(1, end) infinite;
  animation-play-state: running;
}

@keyframes brand-caret-blink {
  0%, 49% {
    opacity: 0.8;
  }

  50%, 100% {
    opacity: 0;
  }
}

/* Botão de tema. */

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;

  min-width: 140px;
  padding: 10px 16px;

  border: 1px solid var(--border);
  border-radius: 999px;

  background: transparent;
  color: var(--foreground);

  font: inherit;
  font-size: 13px;

  cursor: pointer;
}

html.theme-ready .theme-toggle {
  transition:
    background-color 200ms ease,
    border-color 200ms ease,
    color 200ms ease;
}

.theme-toggle:hover {
  background: var(--button-hover);
}

.theme-toggle:focus-visible,
.effect-toggle:focus-visible,
.brand:focus-visible {
  outline: 2px solid var(--foreground);
  outline-offset: 5px;
}

.theme-icon {
  font-size: 16px;
  line-height: 1;
}

/* Rótulo correto desde a primeira renderização. */

.label-light {
  display: none;
}

.label-dark {
  display: inline;
}

:root[data-theme="dark"] .label-light {
  display: inline;
}

:root[data-theme="dark"] .label-dark {
  display: none;
}

/* ==========================================
   HERO
   ========================================== */

.hero {
  flex: 1;

  display: grid;
  place-items: center;

  padding: 64px 20px;

  text-align: center;
}

.hero-content {
  width: 100%;
  max-width: 1100px;
}

.welcome {
  margin: 0 0 20px;

  color: var(--muted);

  font-size: clamp(16px, 2.5vw, 24px);
  font-weight: 400;
  letter-spacing: 0.22em;
}

/* ==========================================
   GLITCH
   ========================================== */

.glitch-title {
  position: relative;
  isolation: isolate;

  display: inline-block;

  margin: 0;

  font-family: Arial, Helvetica, sans-serif;
  font-size: clamp(36px, 11vw, 140px);
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -0.055em;
  white-space: nowrap;
}

.title-stack {
  position: relative;
  isolation: isolate;

  display: block;
}

.glitch-title.is-burst .title-stack {
  filter: url("#text-displacement");
}

.title-main,
.title-layer {
  display: block;

  transform: translate(
    var(--offset-x, 0px),
    var(--offset-y, 0px)
  );

  transition: transform 17ms linear;
}

.title-layer {
  position: absolute;
  inset: 0;

  pointer-events: none;
  user-select: none;
}

.title-red {
  z-index: 1;
  color: var(--rgb-red);
}

.title-green {
  z-index: 2;
  color: var(--rgb-green);
}

.title-blue {
  z-index: 3;
  color: var(--rgb-blue);
}

.title-main {
  position: relative;
  z-index: 4;

  color: var(--foreground);
}

/* Cópias recortadas do texto para interferência localizada. */

.title-slice {
  position: absolute;
  inset: 0;
  z-index: 5;

  display: block;

  color: var(--foreground);
  opacity: 0;

  clip-path: inset(
    var(--slice-top, 35%)
    0
    var(--slice-bottom, 55%)
    0
  );

  transform: translate(
    var(--slice-x, 0px),
    var(--slice-y, 0px)
  );

  text-shadow:
    -2px 0 var(--slice-color-one, var(--rgb-red)),
    2px 0 var(--slice-color-two, var(--rgb-blue));

  pointer-events: none;
  user-select: none;
}

.glitch-title.is-burst .title-slice {
  opacity: var(--slice-opacity, 0);
}

/* ==========================================
   TV TEXTURE
   ========================================== */

.tv-scanlines,
.tv-noise {
  position: absolute;
  inset: 0;

  display: block;

  pointer-events: none;
  user-select: none;
}

.tv-scanlines {
  z-index: 7;

  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 2px,
    #000 2px,
    #000 3px
  );

  opacity: var(--scanline-opacity);
}

.tv-noise {
  z-index: 8;

  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Cpath fill='%23888' filter='url(%23n)' d='M0 0h160v160H0z'/%3E%3C/svg%3E");

  background-repeat: repeat;
  background-size: 120px 120px;

  opacity: var(--noise-opacity);
}

:root[data-effect="off"] .tv-scanlines,
:root[data-effect="off"] .tv-noise {
  display: none;
}

/* ==========================================
   TAGLINE AND EFFECT CONTROL
   ========================================== */

.tagline {
  margin: 28px 0 0;

  color: var(--muted);

  font-size: clamp(12px, 1.8vw, 15px);
  line-height: 1.6;
  letter-spacing: 0.04em;
}

.effect-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  min-width: 130px;
  margin-top: 24px;
  padding: 9px 12px;

  border: 1px solid var(--border);
  border-radius: 999px;

  background: transparent;
  color: var(--muted);

  font: inherit;
  font-size: 11px;

  cursor: pointer;
}

.effect-toggle:hover {
  background: var(--button-hover);
  color: var(--foreground);
}

.effect-label-on {
  display: none;
}

.effect-label-off {
  display: inline;
}

:root[data-effect="on"] .effect-label-on {
  display: inline;
}

:root[data-effect="on"] .effect-label-off {
  display: none;
}

/* ==========================================
   FOOTER
   ========================================== */

.site-footer {
  padding: 24px 20px;

  color: var(--muted);

  text-align: center;
  font-size: 12px;
  letter-spacing: 0.08em;
}

.site-footer p {
  margin: 0;
}

/* ==========================================
   MOBILE
   ========================================== */

@media (max-width: 480px) {
  .site-header {
    padding: 20px;
  }

  .theme-toggle {
    min-width: 130px;
    padding: 9px 12px;

    font-size: 12px;
  }

  .welcome {
    margin-bottom: 16px;
  }
}

/* ==========================================
   REDUCED MOTION
   ========================================== */

/* Mantém o comportamento atual do projeto:
   o glitch é controlado pelo botão e o cursor continua piscando. */

@media (prefers-reduced-motion: reduce) {
  html.theme-ready body,
  html.theme-ready .theme-toggle {
    transition: none;
  }

  .site-header .brand .brand-cursor {
    animation: brand-caret-blink 1s steps(1, end) infinite;
    animation-play-state: running;
  }
}