/* ==========================================================================
   Terminal Portfolio - CSS Custom Properties & Theme
   ========================================================================== */

:root {
  /* Colors - Terminal Theme */
  --color-bg: #0a0a0a;
  --color-bg-overlay: rgba(10, 10, 10, 0.95);
  --color-text: #f0f0f0;
  --color-text-muted: #888888;
  --color-text-dim: #555555;
  --color-accent: #00ff41;
  --color-accent-dim: #00cc44;
  --color-error: #ff4444;
  --color-success: #008F11;

  /* Glow Effects */
  --glow-color: #00ff41;
  --glow-intensity: 0 0 2px;
  --glow-strong: 0 0 4px, 0 0 8px;
  --glow-blur: 0.4px;
  --glow-layered:
    0 0 3px var(--glow-color),
    0 0 6px var(--glow-color),
    0 0 12px rgba(0, 255, 65, 0.4),
    0 0 24px rgba(0, 255, 65, 0.2);
  --glow-layered-strong:
    0 0 4px var(--glow-color),
    0 0 8px var(--glow-color),
    0 0 16px rgba(0, 255, 65, 0.5),
    0 0 32px rgba(0, 255, 65, 0.3);

  /* Typography */
  --font-primary: 'Science Gothic', monospace;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.25rem;
  --font-size-xl: 1.5rem;
  --font-size-2xl: 2rem;
  --font-size-3xl: 2.5rem;
  --font-size-hero: clamp(2rem, 5vw, 4rem);

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;

  /* Animation Timing */
  --duration-instant: 0ms;
  --duration-fast: 100ms;
  --duration-normal: 200ms;
  --duration-slow: 400ms;
  --duration-boot: 2000ms;
  --duration-typing: 50ms;

  /* CRT / Scanline Effects */
  --scanline-opacity: 0.05;
  --scanline-size: 2px;

  /* Layout */
  --max-width-content: 800px;
  --min-touch-target: 44px;

  /* Z-Index Scale */
  --z-base: 0;
  --z-content: 10;
  --z-overlay: 100;
  --z-boot: 200;
  --z-command-bar: 300;
}

/* Reduced Motion Preferences */
@media (prefers-reduced-motion: reduce) {
  :root {
    --duration-boot: 0ms;
    --duration-typing: 0ms;
    --duration-fast: 0ms;
    --duration-normal: 0ms;
    --duration-slow: 0ms;
    --scanline-opacity: 0;
  }

  /* Hide gradient mask immediately for reduced motion */
  .terminal-main::before {
    opacity: 0;
  }
}

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

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-primary);
  font-weight: 400;
  font-size: var(--font-size-base);
  line-height: 1.6;
  background-color: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ==========================================================================
   CRT Scanline Overlay
   ========================================================================== */

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, var(--scanline-opacity)) 0px,
    rgba(0, 0, 0, var(--scanline-opacity)) var(--scanline-size),
    transparent var(--scanline-size),
    transparent calc(var(--scanline-size) * 2)
  );
  pointer-events: none;
  z-index: var(--z-overlay);
}

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

.terminal-container {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  min-height: 100vh;
  padding: var(--space-lg);
  padding-left: max(var(--space-xl), 10vw);
  position: relative;
}

.terminal-main {
  max-width: var(--max-width-content);
  width: 100%;
  text-align: left;
  position: relative;
}

/* Gradient mask at top of viewport - boot messages fade as they scroll up */
.terminal-main::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 120px;
  background: linear-gradient(
    to bottom,
    var(--color-bg) 0%,
    var(--color-bg) 50%,
    transparent 100%
  );
  z-index: var(--z-boot);
  pointer-events: none;
  opacity: 1;
  transition: opacity 300ms ease-out;
}

/* Larger gradient on desktop */
@media (min-width: 768px) {
  .terminal-main::before {
    height: 150px;
  }
}

/* Hide gradient after animation completes */
.terminal-main.animation-complete::before {
  opacity: 0;
}

/* ==========================================================================
   Focus Styles
   ========================================================================== */

:focus {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

:focus:not(:focus-visible) {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ==========================================================================
   Screen Reader Only
   ========================================================================== */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ==========================================================================
   Mobile-First Responsive Breakpoints
   ========================================================================== */

/* Small devices (landscape phones, 576px and up) */
@media (min-width: 576px) {
  :root {
    --font-size-hero: clamp(2.5rem, 6vw, 4.5rem);
  }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 768px) {
  :root {
    --space-lg: 2rem;
    --space-xl: 3rem;
  }

  .terminal-container {
    padding: var(--space-xl);
  }
}

/* Large devices (desktops, 1024px and up) */
@media (min-width: 1024px) {
  :root {
    --font-size-hero: clamp(3rem, 5vw, 5rem);
  }
}

/* Extra large devices (large desktops, 1440px and up) */
@media (min-width: 1440px) {
  :root {
    --max-width-content: 1000px;
  }
}

/* ==========================================================================
   Boot Sequence (integrated with page)
   ========================================================================== */

.boot-messages-wrapper {
  position: relative;
  overflow: visible;
  margin-bottom: var(--space-md);
  transform: translateY(0);
  opacity: 1;
  transition: transform 250ms ease-out, opacity 250ms ease-out;
}

/* When boot completes, push wrapper up and out */
.boot-messages-wrapper.pushed-up {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}

/* Hidden immediately (for hash URL load) */
.boot-messages-wrapper.hidden {
  display: none;
}

.boot-messages {
  font-size: var(--font-size-sm);
  color: var(--color-accent);
  line-height: 1.8;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.boot-messages .boot-line {
  display: block;
  opacity: 0;
  animation: boot-line-appear var(--duration-fast) ease-out forwards;
}

@keyframes boot-line-appear {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Reduced motion: instant appear */
@media (prefers-reduced-motion: reduce) {
  .boot-messages .boot-line {
    opacity: 1;
    animation: none;
  }

  .boot-messages-wrapper {
    transition: none;
  }

  .boot-messages-wrapper.pushed-up {
    display: none;
  }
}

/* ==========================================================================
   Hero Section
   ========================================================================== */

/* Hero section slides up into view after boot */
.hero-section {
  margin-bottom: var(--space-2xl);
  transform: translateY(80px);
  opacity: 0;
  transition: transform 250ms ease-out, opacity 250ms ease-out;
  /* Note: margin-bottom NOT transitioned - causes jitter when compacting */
}

.hero-section.sliding-up {
  transform: translateY(0);
  opacity: 1;
}

/* Hero name visible immediately when hero slides */

/* Tagline hidden until slide-up phase */
.hero-tagline {
  opacity: 0;
  transform: translateY(15px);
  transition: opacity 200ms ease-out, transform 200ms ease-out;
}

.hero-tagline.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Compact mode when page content is shown */
.hero-section.compact {
  margin-bottom: var(--space-md);
}

.hero-section.compact .hero-name {
  font-size: clamp(1.5rem, 3vw, 2.5rem);
}


/* Reduced motion: instant appear */
@media (prefers-reduced-motion: reduce) {
  .hero-section {
    transform: none;
    opacity: 1;
    transition: none;
  }

  .hero-section.sliding-up {
    transform: none;
  }

  .hero-name,
  .hero-tagline {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

.hero-name {
  font-size: var(--font-size-hero);
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--color-accent);
  text-shadow: var(--glow-layered);
  filter: blur(var(--glow-blur));
  margin-bottom: var(--space-sm);
  cursor: default;
  transition: font-size 400ms ease-in-out;
}

.hero-name.glow-effect {
  text-shadow: var(--glow-layered-strong);
}

.hero-role {
  font-size: var(--font-size-lg);
  color: var(--color-text);
  margin-bottom: var(--space-md);
}

.hero-tagline {
  font-size: var(--font-size-base);
  color: var(--color-text-muted);
  transition: font-size 400ms ease-in-out;
}

/* Hero name text wrapper */
.hero-name-text {
  display: inline;
}

/* Blinking cursor - positioned next to hero name */
.cursor {
  display: inline-block;
  vertical-align: baseline;
  width: 0.5em;
  height: 0.85em;
  background-color: var(--color-accent);
  box-shadow: var(--glow-layered);
  filter: blur(var(--glow-blur));
  margin-left: 0.1em;
  opacity: 1;
  animation: cursor-blink 1s step-end infinite;
  transform: translateY(0.05em);
}

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

/* Reduced motion: static cursor */
@media (prefers-reduced-motion: reduce) {
  .cursor {
    animation: none;
  }
}

/* ==========================================================================
   Navigation Section
   ========================================================================== */

.nav-section {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 300ms ease-out, transform 300ms ease-out;
  margin-bottom: 0;
  /* Note: margin-bottom NOT transitioned - causes jitter when compacting */
}

.nav-section.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Compact mode when page content is shown */
.nav-section.compact {
  margin-bottom: var(--space-md);
}

/* Reduced motion: instant appear */
@media (prefers-reduced-motion: reduce) {
  .nav-section {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

.nav-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: var(--space-md);
}

.nav-list li {
  display: inline-block;
}

.nav-link {
  display: inline-flex;
  font-size: var(--font-size-base);
  color: var(--color-text);
  text-decoration: none;
  padding: var(--space-sm) 0;
  min-height: var(--min-touch-target);
  align-items: center;
  justify-content: flex-start;
  border: 1px solid transparent;
  transition: color var(--duration-fast), border-color var(--duration-fast), text-shadow var(--duration-fast);
}

.nav-link::before {
  content: '[';
  color: var(--color-text-muted);
  margin-right: var(--space-xs);
}

.nav-link::after {
  content: ']';
  color: var(--color-text-muted);
  margin-left: var(--space-xs);
}

.nav-link:hover,
.nav-link:focus,
.nav-link.active {
  color: var(--color-accent);
  text-shadow: var(--glow-intensity) var(--glow-color);
}

.nav-link:hover::before,
.nav-link:hover::after,
.nav-link:focus::before,
.nav-link:focus::after,
.nav-link.active::before,
.nav-link.active::after {
  color: var(--color-accent);
}

/* ==========================================================================
   Command Bar
   ========================================================================== */

.command-bar {
  position: fixed;
  bottom: var(--space-xl);
  left: 50%;
  width: calc(100% - var(--space-xl) * 2);
  max-width: 500px;
  background-color: var(--color-bg-overlay);
  border: 1px solid var(--color-accent-dim);
  border-radius: 8px;
  padding: var(--space-md);
  z-index: var(--z-command-bar);
  transform: translateX(-50%) translateY(calc(100% + var(--space-xl)));
  transition: transform var(--duration-normal) ease-out;
  box-shadow: 0 4px 20px rgba(0, 255, 65, 0.1);
}

.command-bar.visible,
.command-bar[aria-hidden="false"] {
  transform: translateX(-50%) translateY(0);
}

.command-bar[aria-hidden="true"] {
  transform: translateX(-50%) translateY(calc(100% + var(--space-xl)));
}

.command-prompt {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  max-width: var(--max-width-content);
  margin: 0 auto;
}

.prompt-symbol {
  color: var(--color-accent);
  font-weight: bold;
}

.command-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--color-text);
  font-family: var(--font-primary);
  font-size: var(--font-size-base);
  outline: none;
  caret-color: var(--color-accent);
}

.command-input::placeholder {
  color: var(--color-text-dim);
}

.command-output {
  max-width: var(--max-width-content);
  margin: var(--space-md) auto 0;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  max-height: 200px;
  overflow-y: auto;
}

.command-output:empty {
  display: none;
}

.command-result {
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--color-text-dim);
}

.command-result:last-child {
  border-bottom: none;
}

.command-result.success {
  color: var(--color-success);
}

.command-result.error {
  color: var(--color-error);
}

.command-result-input {
  color: var(--color-text-muted);
  margin-bottom: var(--space-xs);
}

.command-result-message {
  white-space: pre-wrap;
}

/* ==========================================================================
   Matrix Hover Effect (for hero name)
   ========================================================================== */

.hero-name .char {
  display: inline-block;
  transition: none;
}

.hero-name .char.scrambling {
  color: var(--color-accent-dim);
}

.hero-name .char.resolved {
  color: var(--color-accent);
}

.hero-name .char.locked {
  color: var(--color-accent);
}

/* Reduced motion: no scramble effect */
@media (prefers-reduced-motion: reduce) {
  .hero-name .char.scrambling {
    color: var(--color-accent);
  }
}

/* ==========================================================================
   Page Content Area (SPA Navigation)
   ========================================================================== */

.page-content {
  margin-top: var(--space-lg);
  padding: var(--space-lg) 0;
  min-height: 0;
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 300ms ease-out, transform 300ms ease-out;
}

.page-content.visible {
  opacity: 1;
  transform: translateY(0);
}

.page-content:empty {
  display: none;
}

.page-content h2 {
  font-size: var(--font-size-xl);
  color: var(--color-accent);
  margin-bottom: var(--space-md);
  font-weight: 600;
}

.page-content p {
  color: var(--color-text-muted);
  line-height: 1.8;
  margin-bottom: var(--space-md);
}

.page-content .coming-soon {
  color: var(--color-text-dim);
  font-style: italic;
}

.page-content .matrix-quote {
  color: var(--color-accent-dim);
  border-left: 2px solid var(--color-accent-dim);
  padding-left: var(--space-md);
  margin: var(--space-lg) 0;
}

.page-content a {
  color: var(--color-accent);
  text-decoration: none;
}

.page-content a:hover {
  text-decoration: underline;
}

/* Back link */
.back-link {
  display: inline-block;
  margin-top: var(--space-lg);
  color: var(--color-text-muted);
  cursor: pointer;
}

.back-link:hover {
  color: var(--color-accent);
}
