:root {
  --font-mono:
    ui-monospace, "SF Mono", SFMono-Regular, "Cascadia Code", "Consolas",
    "Liberation Mono", "DejaVu Sans Mono", monospace;
  --green: #22c55e;
  --bg: #fafaf9;
  --fg: #1c1917;
  --fg-muted: #78716c;
  --terminal-bg: #1c1917;
  --terminal-fg: #e7e5e4;
  --terminal-bar: #e7e5e4;
  --terminal-shadow: rgba(0, 0, 0, 0.08);
  --grain-opacity: 0.03;
}
[data-theme="dark"] {
  --bg: #0c0a09;
  --fg: #e7e5e4;
  --fg-muted: #a8a29e;
  --terminal-bg: #1c1917;
  --terminal-fg: #e7e5e4;
  --terminal-bar: #292524;
  --terminal-shadow: rgba(34, 197, 94, 0.06);
  --grain-opacity: 0.04;
}

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

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: var(--font-mono);
  color: var(--fg);
  text-align: left;
  background: var(--bg);
}

/* Grain texture overlay */
body::before {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  content: "";
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
  opacity: var(--grain-opacity);
}

main {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: center;
  max-width: 720px;
  padding: 2rem 2rem 4rem;
}

/* Staggered reveal */
.reveal {
  opacity: 0;
  transform: translateY(8px);
  animation: reveal 0.5s ease forwards;
}
.reveal:nth-child(1) {
  animation-delay: 0.1s;
}
.reveal:nth-child(2) {
  animation-delay: 0.3s;
}
.reveal:nth-child(3) {
  animation-delay: 0.6s;
}

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

/* Terminal */
.terminal {
  max-width: 420px;
  overflow: hidden;
  border-radius: 10px;
  box-shadow:
    0 1px 3px var(--terminal-shadow),
    0 8px 24px var(--terminal-shadow);
}
.terminal-titlebar {
  display: flex;
  align-items: center;
  padding: 0.65rem 0.85rem;
  background: var(--terminal-bar);
}
.terminal-dots {
  display: flex;
  gap: 7px;
}
.terminal-dots span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}
.terminal-dots span:nth-child(1) {
  background: #ff5f57;
}
.terminal-dots span:nth-child(2) {
  background: #ffbd2e;
}
.terminal-dots span:nth-child(3) {
  background: #28c840;
}
.terminal-body {
  padding: 1rem 1.15rem;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--terminal-fg);
  background: var(--terminal-bg);
}
.terminal-body .prompt {
  font-weight: 700;
  color: var(--green);
}
.terminal-body .cursor {
  display: inline-block;
  width: 8px;
  height: 1.15em;
  margin-left: 1px;
  vertical-align: text-bottom;
  background: var(--terminal-fg);
  animation: blink 1s step-end infinite;
}
@keyframes blink {
  50% {
    opacity: 0;
  }
}

/* Theme toggle */
.theme-toggle {
  gap: 0.25rem;
}
.theme-toggle button {
  min-width: 44px;
  min-height: 44px;
  padding: 0.5rem;
  border-radius: 8px;
  opacity: 0.6;
  transition:
    opacity 0.2s,
    background 0.2s;
}
.theme-toggle button:hover {
  opacity: 0.8;
}
.theme-toggle button:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
  opacity: 1;
}
.theme-toggle button.active {
  background: color-mix(in srgb, var(--fg) 10%, transparent);
  opacity: 1;
}
.theme-toggle button svg {
  width: 16px;
  height: 16px;
  vertical-align: middle;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Bottom bar */
.bottom-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  justify-content: space-between;
  padding: 2rem 2rem calc(2rem + env(safe-area-inset-bottom, 0px));
}

/* Footer */
footer p {
  font-size: 0.8rem;
  color: var(--fg-muted);
  letter-spacing: 0.02em;
}
footer p::before {
  content: "// ";
  opacity: 0.5;
}

/* Accessibility: reduced motion */
@media (prefers-reduced-motion: reduce) {
  .reveal {
    opacity: 1;
    transform: none;
    animation: none;
  }
  .terminal-body .cursor {
    animation: none;
  }
  .theme-toggle button {
    transition: none;
  }
}
