/**
 * 1mb — one-man-band
 * https://1mb.dev
 */

/* ========================================
   Fonts (self-hosted)
   ======================================== */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400 600;
  font-display: swap;
  src: url('/assets/fonts/inter-latin.woff2') format('woff2');
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/assets/fonts/space-grotesk-700-latin.woff2') format('woff2');
  unicode-range:
    U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ========================================
   Design Tokens
   ======================================== */

:root {
  /* Colors - Light */
  --bg: #fafafa;
  --fg: #1a1a1a;
  --muted: #6b6b6b;
  --border: #e0e0e0;
  --surface: #f0f0f0;

  /* Spacing - 8pt grid */
  --space-1: 0.5rem; /* 8px */
  --space-2: 1rem; /* 16px */
  --space-3: 1.5rem; /* 24px */
  --space-4: 2rem; /* 32px */
  --space-5: 2.5rem; /* 40px */
  --space-6: 3rem; /* 48px */
  --space-8: 4rem; /* 64px */

  /* Type Scale - 1.25 ratio */
  --text-xs: 0.75rem; /* 12px */
  --text-sm: 0.875rem; /* 14px */
  --text-base: 1rem; /* 16px */
  --text-md: 1.125rem; /* 18px */
  --text-lg: 1.25rem; /* 20px */
  --text-xl: 1.5rem; /* 24px */
  --text-2xl: 2rem; /* 32px */
  --text-3xl: 2.5rem; /* 40px */

  /* Fonts */
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;

  /* Misc */
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0a0a;
    --fg: #e5e5e5;
    --muted: #888;
    --border: #2a2a2a;
    --surface: #151515;
  }
}

/* ========================================
   Reset
   ======================================== */

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

/* ========================================
   Base
   ======================================== */

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  background: var(--bg);
  color: var(--fg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: var(--space-4);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: relative;
  overflow: hidden;
}

/* Watermark */
body::before {
  content: '1';
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(calc(-50% + var(--parallax-x, 0px)), calc(-45% + var(--parallax-y, 0px)));
  font-family: var(--font-display);
  font-size: clamp(250px, 40vw, 400px);
  font-weight: 700;
  color: var(--fg);
  opacity: 0.04;
  pointer-events: none;
  z-index: 0;
  line-height: 1;
  transition: transform 0.15s ease-out;
  will-change: transform;
}

/* ========================================
   Layout
   ======================================== */

main {
  max-width: 480px;
  text-align: center;
  position: relative;
  z-index: 1;
}

header {
  margin-bottom: var(--space-6);
}

article {
  margin-bottom: var(--space-2);
}

/* ========================================
   Logo
   ======================================== */

.logo {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
  margin-bottom: var(--space-2);
}

.subtitle {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--muted);
  text-transform: lowercase;
  letter-spacing: 0.15em;
}

/* ========================================
   Content
   ======================================== */

.manifesto {
  font-family: var(--font-body);
  font-size: var(--text-md);
  font-weight: 500;
  color: var(--fg);
  margin-bottom: var(--space-4);
}

.description {
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--muted);
  max-width: 320px;
  margin: 0 auto;
  line-height: 1.7;
}

.context {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--muted);
  margin-top: var(--space-4);
  line-height: 1.8;
}

/* ========================================
   Separator
   ======================================== */

.separator {
  border: none;
  margin: var(--space-2) 0;
  color: var(--border);
  font-size: var(--text-sm);
  letter-spacing: 0.5em;
  text-align: center;
}

.separator::before {
  content: '· · ·';
}

/* ========================================
   Invitation
   ======================================== */

.invitation {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-style: italic;
  color: var(--muted);
  margin-bottom: var(--space-4);
}

/* ========================================
   Counter
   ======================================== */

.counter {
  margin-top: 0;
}

.counter-btn {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  font-style: italic;
  color: var(--bg);
  background: var(--fg);
  border: none;
  padding: var(--space-2) var(--space-4);
  border-radius: calc(var(--radius) / 2);
  cursor: pointer;
  transition: all 0.2s ease;
}

.counter-btn:hover:not(:disabled) {
  opacity: 0.85;
}

.counter-btn:active:not(:disabled) {
  transform: scale(0.98);
}

.counter-btn:disabled {
  cursor: default;
}

.counter-btn:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

.counter-btn.voted {
  background: transparent;
  color: var(--muted);
  font-style: normal;
}

.counter-btn.voted::before {
  content: '✓ ';
}

.counter-btn.error {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  font-style: normal;
}

.counter-proof {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--muted);
  margin-top: var(--space-3);
}

.counter-proof span {
  color: var(--fg);
  font-weight: 500;
}

/* Counter loading skeleton - shimmer effect */
.count-loading {
  display: inline-block;
  width: 4em;
  height: 1em;
  background: linear-gradient(90deg, var(--border) 0%, var(--surface) 50%, var(--border) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 4px;
  vertical-align: middle;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

/* Counter fade-in */
.count-loaded {
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========================================
   Theme Toggle
   ======================================== */

.theme-toggle {
  position: fixed;
  bottom: var(--space-4);
  right: var(--space-4);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-base);
  transition: all 0.2s ease;
  z-index: 10;
}

.theme-toggle:hover {
  border-color: var(--fg);
  color: var(--fg);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

/* Icons */
.theme-toggle .icon-sun,
.theme-toggle .icon-moon {
  display: none;
}

/* Default (system/light): show moon */
.theme-toggle .icon-moon {
  display: block;
}

/* Dark mode: show sun */
[data-theme='dark'] .theme-toggle .icon-moon {
  display: none;
}

[data-theme='dark'] .theme-toggle .icon-sun {
  display: block;
}

/* Light mode explicit: show moon */
[data-theme='light'] .theme-toggle .icon-sun {
  display: none;
}

[data-theme='light'] .theme-toggle .icon-moon {
  display: block;
}

/* Theme overrides */
[data-theme='dark'] {
  --bg: #0a0a0a;
  --fg: #e5e5e5;
  --muted: #888;
  --border: #2a2a2a;
  --surface: #151515;
}

[data-theme='light'] {
  --bg: #fafafa;
  --fg: #1a1a1a;
  --muted: #6b6b6b;
  --border: #e0e0e0;
  --surface: #f0f0f0;
}

/* ========================================
   Accessibility
   ======================================== */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .counter-btn {
    transition: none;
  }

  body::before {
    display: none;
  }
}

/* ========================================
   404 Page
   ======================================== */

.page-404::before {
  content: '0';
}

.page-404 main {
  max-width: 320px;
}

.page-404 h1 {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: var(--space-2);
}

.page-404 .message {
  color: var(--muted);
  font-size: var(--text-base);
  line-height: 1.6;
  margin-bottom: var(--space-1);
}

.page-404 .subtext {
  color: var(--muted);
  font-size: var(--text-sm);
  margin-bottom: var(--space-5);
}

.page-404 .back-link {
  display: inline-block;
  font-size: var(--text-sm);
  color: var(--bg);
  background: var(--fg);
  text-decoration: none;
  padding: var(--space-2) var(--space-3);
  border-radius: calc(var(--radius) / 2);
  transition: opacity 0.2s ease;
}

.page-404 .back-link:hover {
  opacity: 0.85;
}

.page-404 .back-link:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

/* ========================================
   Print
   ======================================== */

@media print {
  body {
    background: white;
    color: black;
  }

  body::before {
    display: none;
  }

  .logo,
  .subtitle,
  .manifesto,
  .description {
    color: black;
  }

  .logo-container {
    border-color: #ccc;
  }

  .counter {
    display: none;
  }
}
