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

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

/* =========================================
   CSS Custom Properties - Dark Theme (OS default)
   ========================================= */
:root {
  --bg-base: #1a1a1a;
  --bg-elevated: #242424;
  --bg-surface: #2a2a2a;
  --text-primary: #f5f5f5;
  --text-secondary: #888888;
  --text-muted: #8a8a8a;
  --accent: #ff6b35;
  --accent-soft: rgba(255, 107, 53, 0.12);
  --accent-glow: rgba(255, 107, 53, 0.25);
  --border: #333333;
  --border-strong: #444444;
  --code-bg: #1e1e1e;
  --gradient-start: #ff6b35;
  --gradient-end: #f7931e;
}

/* =========================================
   CSS Custom Properties - Light Theme (OS preference)
   ========================================= */
@media (prefers-color-scheme: light) {
  :root {
    --bg-base: #fafaf9;
    --bg-elevated: #ffffff;
    --bg-surface: #f5f5f4;
    --text-primary: #1c1917;
    --text-secondary: #78716c;
    --text-muted: #6b6560;
    --accent: #ea580c;
    --accent-soft: rgba(234, 88, 12, 0.08);
    --accent-glow: rgba(234, 88, 12, 0.15);
    --border: #e7e5e4;
    --border-strong: #d6d3d1;
    --code-bg: #f5f5f4;
    --gradient-start: #ea580c;
    --gradient-end: #f59e0b;
  }
}

/* =========================================
   Base Styles
   ========================================= */
body {
  font-family: 'Sora', sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition:
    background 0.4s ease,
    color 0.3s ease;
}

/* Gradient accent line at top */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--gradient-start), var(--gradient-end));
  z-index: 100;
}

.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 2rem;
}

/* =========================================
   Accessibility - Skip Link
   ========================================= */
.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
  background: var(--text-primary);
  color: var(--bg-base);
  padding: 0.5rem 1rem;
  text-decoration: none;
  z-index: 1000;
  border-radius: 4px;
}

.skip-link:focus {
  position: fixed;
  top: 1rem;
  left: 1rem;
  width: auto;
  height: auto;
  overflow: visible;
}

/* =========================================
   Navigation
   ========================================= */
nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2rem 0;
  border-bottom: 1px solid var(--border);
}

.nav-logo {
  font-family: 'Instrument Serif', serif;
  font-size: 1.5rem;
  font-style: italic;
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 2rem;
}

.nav-links {
  display: flex;
  gap: 1.5rem;
}

.nav-links a {
  font-family: 'DM Mono', monospace;
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  transition: color 0.2s ease;
}

.nav-links a:hover {
  color: var(--accent);
}

/* =========================================
   Hero Section - Two Column
   ========================================= */
.hero {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4rem;
  padding: 6rem 0;
  align-items: center;
}

.hero-content {
  position: relative;
}

.hero-label {
  font-family: 'DM Mono', monospace;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--accent);
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.hero-label::before {
  content: '';
  width: 2rem;
  height: 1px;
  background: var(--accent);
}

.hero-title {
  font-family: 'Instrument Serif', serif;
  font-size: clamp(3rem, 6vw, 4.5rem);
  font-weight: 400;
  line-height: 1.1;
  margin-bottom: 1.5rem;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.hero-title em {
  font-style: italic;
  color: var(--accent);
}

.hero-subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  max-width: 400px;
  margin-bottom: 2rem;
}

.hero-meta {
  display: flex;
  gap: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.meta-label {
  font-family: 'DM Mono', monospace;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-muted);
}

.meta-value {
  font-size: 0.9rem;
  color: var(--text-primary);
}

/* =========================================
   Terminal Card on Right
   ========================================= */
.hero-terminal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  box-shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 20px 50px -12px rgba(0, 0, 0, 0.25);
  transform: rotate(1deg);
  transition: transform 0.3s ease;
}

.hero-terminal:hover {
  transform: rotate(0deg);
  box-shadow:
    0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 25px 60px -15px rgba(0, 0, 0, 0.35);
}

.term-header {
  background: var(--bg-surface);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border);
}

.term-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  transition: filter 0.2s;
}

.term-dot:hover {
  filter: brightness(1.2);
}

.term-dot.r {
  background: radial-gradient(circle at 30% 30%, #ff6b6b, #ed5f5f 40%, #d64545);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.3);
}

.term-dot.y {
  background: radial-gradient(circle at 30% 30%, #ffd93d, #f5c842 40%, #e6b800);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.3);
}

.term-dot.g {
  background: radial-gradient(circle at 30% 30%, #6bcb77, #5cb85c 40%, #4cae4c);
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.3);
}

.term-title {
  flex: 1;
  text-align: center;
  font-family: 'DM Mono', monospace;
  font-size: 0.7rem;
  color: var(--text-muted);
}

.term-body {
  padding: 1.0rem;
  font-family: 'DM Mono', monospace;
  font-size: 0.85rem;
  line-height: 1.7;
  height: 280px;
  display: flex;
  flex-direction: column;
}

.term-line {
  margin-bottom: 0.75rem;
  opacity: 0;
  animation: typeIn 0.5s ease forwards;
  flex-shrink: 0;
}

.term-output-history > .term-line:nth-child(1) {
  animation-delay: 0.2s;
}
.term-output-history > .term-line:nth-child(2) {
  animation-delay: 0.4s;
}
.term-output-history > .term-line:nth-child(3) {
  animation-delay: 0.6s;
}
.term-output-history > .term-line:nth-child(4) {
  animation-delay: 0.8s;
}
.term-output-history > .term-line:nth-child(5) {
  animation-delay: 1s;
}
.term-output-history > .term-line:nth-child(6) {
  animation-delay: 1.2s;
}

@keyframes typeIn {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.term-prompt {
  color: var(--accent);
}

.term-cmd {
  color: var(--text-primary);
}

.term-output {
  color: var(--text-secondary);
  padding-left: 1rem;
}

.term-comment {
  color: var(--text-muted);
  font-style: italic;
}

.term-cursor {
  display: inline-block;
  width: 8px;
  height: 16px;
  background: var(--accent);
  animation: blink 1s step-end infinite;
  vertical-align: text-bottom;
  margin-left: 4px;
}

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

/* Terminal Input Styles */
.term-output-history {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.term-output-history::-webkit-scrollbar {
  display: none;
}

.term-input-line {
  animation: none !important;
  opacity: 1 !important;
}

.term-input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: 'DM Mono', monospace;
  font-size: 0.85rem;
  padding: 0;
  margin: 0;
  width: calc(100% - 1.5rem);
  caret-color: var(--accent);
}

.term-input:focus {
  outline: none !important;
  border: none !important;
  box-shadow: none !important;
}

.term-input::selection {
  background: var(--accent);
  color: var(--bg-base);
}

/* =========================================
   Sections
   ========================================= */
.section {
  padding: 6rem 0;
  border-top: 1px solid var(--border);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 3rem;
}

.section-title {
  font-family: 'Instrument Serif', serif;
  font-size: 2.5rem;
  font-weight: 400;
}

.section-count {
  font-family: 'DM Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* =========================================
   Connect Section - Card Grid
   ========================================= */
.connect-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.connect-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  text-decoration: none;
  color: inherit;
  transition:
    border-color 0.2s ease,
    transform 0.2s ease,
    box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  cursor: pointer;
}

.connect-card:hover,
.connect-card:focus {
  border-color: var(--accent);
  transform: translateY(-4px);
  box-shadow: 0 10px 40px -10px var(--accent-glow);
}

.connect-card .icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

.connect-card .icon svg {
  width: 20px;
  height: 20px;
}

.connect-card .title {
  font-family: 'Instrument Serif', serif;
  font-size: 1.25rem;
}

.connect-card .desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.connect-card .arrow {
  margin-top: auto;
  font-family: 'DM Mono', monospace;
  font-size: 0.75rem;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Email special card */
.email-card {
  background: linear-gradient(135deg, var(--accent-soft), transparent);
  border-color: var(--accent);
}

.email-card .code {
  font-family: 'DM Mono', monospace;
  font-size: 0.85rem;
  color: var(--text-secondary);
  background: var(--code-bg);
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.email-card .revealed {
  display: none;
  font-family: 'Instrument Serif', serif;
  font-size: 1.5rem;
  color: var(--accent);
}

.email-card.active .code {
  display: none;
}
.email-card.active .revealed {
  display: block;
}

/* =========================================
   Footer
   ========================================= */
footer {
  padding: 3rem 0;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-text {
  font-family: 'DM Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.footer-hint {
  color: var(--text-muted);
  opacity: 0.6;
}

/* =========================================
   Toast Notification
   ========================================= */
.notification {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--bg-elevated);
  border: 1px solid var(--accent);
  border-radius: 100px;
  padding: 1rem 2rem;
  font-family: 'DM Mono', monospace;
  font-size: 0.85rem;
  color: var(--text-primary);
  box-shadow: 0 10px 40px -10px var(--accent-glow);
  z-index: 3000;
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.notification.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.notification .emoji {
  margin-right: 0.5rem;
}

/* =========================================
   Modal - Snake Game
   ========================================= */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  z-index: 2000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal {
  background: var(--bg-elevated);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  max-width: 600px;
  width: 90%;
  overflow: hidden;
}

.modal-chrome {
  background: var(--bg-surface);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-family: 'DM Mono', monospace;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.875rem;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s;
}

.modal-close:hover {
  background: #ff6b6b;
  color: white;
}

.modal-content {
  padding: 2rem;
  text-align: center;
}

.game-title {
  font-family: 'Instrument Serif', serif;
  font-size: 1.5rem;
  color: var(--accent);
  margin-bottom: 1rem;
}

#gameCanvas {
  border: 2px solid var(--border);
  border-radius: 8px;
  margin: 1rem auto;
  display: block;
  background: var(--bg-surface);
}

.game-score {
  font-size: 1.125rem;
  color: var(--accent);
  margin: 1rem 0 0.5rem;
}

.game-highscore {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.game-controls {
  color: var(--text-secondary);
  font-size: 0.8rem;
  line-height: 1.8;
}

.game-message {
  color: var(--accent);
  font-size: 1rem;
  margin: 1rem 0;
  min-height: 1.5rem;
}

/* =========================================
   Coffee Break Overlay
   ========================================= */
.coffee-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, #1a1205 0%, #2d1f0a 50%, #1a1205 100%);
  z-index: 2500;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  cursor: pointer;
}

.coffee-overlay.active {
  display: flex;
  animation: fadeIn 0.5s ease;
}

.coffee-content {
  text-align: center;
}

.coffee-ascii {
  color: #d4a574;
  font-size: 1.5rem;
  line-height: 1.2;
  text-shadow: 0 0 20px rgba(212, 165, 116, 0.5);
  animation: steam 2s ease-in-out infinite;
}

@keyframes steam {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-5px);
  }
}

.coffee-text {
  color: #d4a574;
  font-size: 1.5rem;
  margin-top: 1.25rem;
  text-shadow: 0 0 10px rgba(212, 165, 116, 0.5);
}

.coffee-timer {
  color: #8b7355;
  font-size: 3rem;
  margin-top: 1.25rem;
  font-weight: bold;
  font-variant-numeric: tabular-nums;
}

.coffee-hint {
  color: #5c4a3a;
  font-size: 0.875rem;
  margin-top: 2.5rem;
}

/* =========================================
   Enhance Overlay
   ========================================= */
.enhance-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #000;
  z-index: 2500;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.enhance-overlay.active {
  display: flex;
}

.enhance-content {
  text-align: center;
}

.enhance-ascii {
  color: #0f0;
  font-size: 0.5rem;
  line-height: 1;
  transition: all 0.5s ease;
  text-shadow: 0 0 5px #0f0;
  filter: blur(0px);
}

.enhance-ascii.zoom-1 {
  font-size: 0.8rem;
}
.enhance-ascii.zoom-2 {
  font-size: 1.2rem;
}
.enhance-ascii.zoom-3 {
  font-size: 1.8rem;
  filter: blur(2px);
}
.enhance-ascii.zoom-4 {
  font-size: 2.5rem;
  filter: blur(4px);
}
.enhance-ascii.zoom-5 {
  font-size: 1.5rem;
  filter: blur(0px);
  color: #0ff;
}

.enhance-text {
  color: #0f0;
  font-size: 1.2rem;
  margin-top: 1.875rem;
  text-transform: uppercase;
  letter-spacing: 3px;
  text-shadow: 0 0 10px #0f0;
}

.enhance-text.final {
  color: #0ff;
  font-size: 1.5rem;
  text-shadow: 0 0 20px #0ff;
}

/* =========================================
   Exit/Dark Net Overlay
   ========================================= */
.exit-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: #000;
  z-index: 2500;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 1.25rem;
}

.exit-overlay.active {
  display: flex;
}

.exit-overlay.glitch {
  animation: glitchBg 0.3s ease-out;
}

@keyframes glitchBg {
  0%,
  100% {
    background: #000;
  }
  25% {
    background: #0a0a0a;
    transform: translateX(-2px);
  }
  50% {
    background: #111;
    transform: translateX(2px);
  }
  75% {
    background: #050505;
    transform: translateY(-1px);
  }
}

.exit-content {
  text-align: center;
  max-width: 600px;
}

.exit-text {
  color: #0f0;
  font-size: 1.125rem;
  margin-bottom: 1.25rem;
  text-shadow: 0 0 10px #0f0;
  min-height: 1.5em;
}

.darknet-ascii {
  color: #f00;
  font-size: 0.6rem;
  line-height: 1.1;
  margin-bottom: 1.25rem;
  text-shadow: 0 0 5px #f00;
  display: none;
}

.darknet-ascii.active {
  display: block;
  animation: flicker 0.1s infinite;
}

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

.darknet-logs {
  color: #0f0;
  font-size: 0.8rem;
  text-align: left;
  line-height: 1.6;
  text-shadow: 0 0 5px #0f0;
}

.darknet-logs .log-line {
  opacity: 0;
  animation: fadeInLog 0.1s forwards;
}

.darknet-logs .warning {
  color: #ff0;
}
.darknet-logs .error {
  color: #f00;
}
.darknet-logs .success {
  color: #0ff;
}

@keyframes fadeInLog {
  to {
    opacity: 1;
  }
}

/* =========================================
   Matrix Canvas
   ========================================= */
#matrixCanvas {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 2000;
  pointer-events: none;
}

#matrixCanvas.active {
  display: block;
}

/* =========================================
   Rainbow Effect (Konami Code)
   ========================================= */
.rainbow-effect {
  animation: rainbow 2s linear infinite;
}

@keyframes rainbow {
  0% {
    filter: hue-rotate(0deg);
  }
  100% {
    filter: hue-rotate(360deg);
  }
}

/* =========================================
   Scroll Animations
   ========================================= */
.fade-in-up {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.fade-in-up.visible {
  opacity: 1;
  transform: translateY(0);
}

/* =========================================
   Focus Styles (Accessibility)
   ========================================= */
*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* =========================================
   Noscript Notice
   ========================================= */
.noscript-notice {
  background: var(--bg-elevated);
  border: 2px solid var(--accent);
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
  max-width: 800px;
  margin: 1rem auto;
}

/* =========================================
   Reduced Motion (Accessibility)
   ========================================= */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .fade-in-up {
    opacity: 1 !important;
    transform: none !important;
  }
}

/* =========================================
   Responsive Design
   ========================================= */

/* Tablet */
@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 3rem;
    padding: 4rem 0;
  }

  .hero-terminal {
    transform: none;
  }

  .section {
    padding: 3rem 0;
  }

  .connect-grid {
    grid-template-columns: 1fr;
  }

  .nav-links {
    display: none;
  }
}

/* Mobile */
@media (max-width: 600px) {
  .page {
    padding: 0 1rem;
  }

  .hero-title {
    font-size: 2.5rem;
  }

  .hero-meta {
    flex-direction: column;
    gap: 1rem;
  }

  .section {
    padding: 2rem 0;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  footer {
    flex-direction: column;
    gap: 1.5rem;
    text-align: center;
  }

  #gameCanvas {
    width: 100%;
    max-width: 400px;
    aspect-ratio: 1;
  }

  .modal {
    width: 95%;
  }

  .modal-content {
    padding: 1rem;
  }
}

/* Print Styles */
@media print {
  body {
    background: white;
    color: black;
  }

  body::before {
    display: none;
  }

  .term-header,
  .term-dot {
    display: none;
  }

  .hero-terminal {
    box-shadow: none;
    border: 1px solid #ddd;
  }
}
