/* ============================================================
   PORTFOLIO — Tokyo Night Theme
   ============================================================ */

/* --- Custom Properties ------------------------------------ */
:root {
  /* Colors — Tokyo Night */
  --bg: #1a1b26;
  --bg-alt: #16161e;
  --fg: #c0caf5;
  --fg-muted: #a9b1d6;
  --fg-dim: #737aa2; /* adjusted from #565f89 for WCAG AA (5.09:1 vs --bg) */
  --accent: #7aa2f7;
  --accent-warm: #e0af68;
  --success: #9ece6a;
  --danger: #f7768e;

  /* Typography */
  --font-mono: 'JetBrains Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;
  --text-sm: 0.875rem;   /* 14px */
  --text-base: 1rem;     /* 16px */
  --text-lg: 1.125rem;   /* 18px */
  --text-xl: 1.25rem;    /* 20px */
  --text-2xl: 1.5rem;    /* 24px */

  /* Spacing — 4px base */
  --space-1: 0.25rem;    /* 4px */
  --space-2: 0.5rem;     /* 8px */
  --space-3: 0.75rem;    /* 12px */
  --space-4: 1rem;       /* 16px */
  --space-5: 1.5rem;     /* 24px */
  --space-6: 2rem;       /* 32px */
  --space-7: 3rem;       /* 48px */
  --space-8: 4rem;       /* 64px */

  /* Layout */
  --max-width: 900px;
}

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

/* --- Base ------------------------------------------------- */
html {
  font-size: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-mono);
  font-size: var(--text-base);
  line-height: 1.7;
  color: var(--fg);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

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

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

/* --- Skip link (hidden, visible on focus) ----------------- */
.skip-link {
  position: absolute;
  top: -100%;
  left: var(--space-4);
  padding: var(--space-2) var(--space-4);
  background: var(--accent);
  color: var(--bg);
  font-size: var(--text-sm);
  font-weight: 700;
  text-decoration: none;
  border-radius: 0 0 4px 4px;
  z-index: 100;
}

.skip-link:focus {
  top: 0;
}

/* --- Container -------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin-inline: auto;
  padding-inline: var(--space-5);
}

/* --- Links ------------------------------------------------ */
a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--accent-warm);
}

/* --- Header ----------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background-color: var(--bg-alt);
  border-bottom: 1px solid rgba(115, 122, 162, 0.15);
  padding-block: var(--space-4);
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--fg);
  text-decoration: none;
}

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

.logo-symbol {
  color: var(--accent-warm);
}

/* --- Navigation ------------------------------------------- */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-2);
  color: var(--fg);
}

.hamburger {
  display: block;
  width: 20px;
  height: 2px;
  background-color: var(--fg);
  position: relative;
  transition: background-color 0.2s ease;
}

.hamburger::before,
.hamburger::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 2px;
  background-color: var(--fg);
  transition: transform 0.2s ease;
}

.hamburger::before {
  top: -6px;
}

.hamburger::after {
  top: 6px;
}

.nav-list {
  display: flex;
  gap: var(--space-5);
  list-style: none;
}

.nav-link {
  font-size: var(--text-sm);
  color: var(--fg-muted);
  text-decoration: none;
  transition: color 0.2s ease;
}

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

/* --- Hero / Terminal -------------------------------------- */
.hero {
  padding-block: var(--space-7) var(--space-6);
}

/* Visually hidden but accessible to screen readers */
.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;
}

/* Visible skip link — terminal-style hint */
.terminal-skip {
  display: inline-block;
  font-size: var(--text-sm);
  color: var(--fg-dim);
  margin-bottom: var(--space-5);
  padding: var(--space-2) var(--space-3);
  border: 1px solid rgba(115, 122, 162, 0.2);
  border-radius: 4px;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.terminal-skip:hover,
.terminal-skip:focus-visible {
  color: var(--accent);
  border-color: var(--accent);
}

.terminal-skip-arrow {
  color: var(--accent-warm);
  margin-inline: var(--space-1);
}

/* Terminal window */
.terminal {
  background-color: var(--bg-alt);
  border: 1px solid rgba(115, 122, 162, 0.15);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* Title bar */
.terminal-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background-color: rgba(22, 22, 30, 0.8);
  border-bottom: 1px solid rgba(115, 122, 162, 0.1);
}

.terminal-dots {
  display: flex;
  gap: 6px;
}

.terminal-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.terminal-dot--red {
  background-color: var(--danger);
}

.terminal-dot--amber {
  background-color: var(--accent-warm);
}

.terminal-dot--green {
  background-color: var(--success);
}

.terminal-title {
  font-size: 0.75rem;
  color: var(--fg-dim);
}

/* Body */
.terminal-body {
  padding: var(--space-5);
  min-height: 280px;
  max-height: 480px;
  overflow-y: auto;
}

/* Pre-printed lines */
.terminal-pre {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.8;
  color: var(--fg);
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.terminal-line {
  display: block;
}

.terminal-prompt {
  color: var(--success);
  font-weight: 500;
}

.terminal-cmd {
  color: var(--fg);
}

.terminal-output-text {
  color: var(--fg-muted);
  padding-left: 0;
}

/* Typing animation — each command span starts hidden */
.terminal-cmd {
  overflow: hidden;
  max-width: 0;
  white-space: nowrap;
  transition: max-width 0s;
}

.terminal-cmd.is-typed {
  max-width: 100%;
  white-space: nowrap;
}

/* Output text lines start hidden, revealed by JS */
.terminal-output-text {
  opacity: 0;
}

.terminal-output-text.is-visible {
  opacity: 1;
  transition: opacity 0.3s ease;
}

/* No-JS fallback: show all terminal content immediately */
.no-js .terminal-cmd {
  max-width: 100%;
  overflow: visible;
}

.no-js .terminal-output-text {
  opacity: 1;
}

/* Interactive area */
.terminal-interact {
  margin-top: var(--space-4);
}

.terminal-input-line {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.terminal-input-wrap {
  position: relative;
  flex: 1;
}

.terminal-input {
  width: 100%;
  background: transparent;
  border: none;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--fg);
  outline: none;
  padding: 0;
  caret-color: transparent;
}

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

.terminal-input::placeholder {
  color: var(--fg-dim);
}

/* Blinking cursor */
.terminal-cursor {
  display: inline-block;
  width: 0.55em;
  height: 1.15em;
  background-color: var(--fg);
  vertical-align: text-bottom;
  animation: cursor-blink 1s step-end infinite;
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

.terminal-input:focus ~ .terminal-cursor {
  animation: cursor-blink 1s step-end infinite;
}

/* When user is typing, hide cursor */
.terminal-input:not(:placeholder-shown) ~ .terminal-cursor {
  display: none;
}

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

/* Output from interactive commands */
.terminal-output {
  margin-top: var(--space-3);
  font-size: var(--text-sm);
  line-height: 1.8;
}

.terminal-output-line {
  display: block;
  color: var(--fg-muted);
}

.terminal-output-line--error {
  color: var(--danger);
}

.terminal-output-line--success {
  color: var(--success);
}

.terminal-output-line--accent {
  color: var(--accent);
}

.terminal-output-line--warm {
  color: var(--accent-warm);
}

/* History of executed commands (shown above current input) */
.terminal-history-line {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  line-height: 1.8;
  color: var(--fg);
}

.terminal-history-line .terminal-prompt {
  flex-shrink: 0;
}

.terminal-history-cmd {
  color: var(--fg);
}

/* --- Sections --------------------------------------------- */
.section {
  padding-block: var(--space-7);
  border-top: 1px solid rgba(115, 122, 162, 0.08);
}

/* Terminal-style comment prefix for each section */
.section-comment {
  font-size: var(--text-sm);
  color: var(--fg-dim);
  margin-bottom: var(--space-5);
}

/* --- About ------------------------------------------------- */
.about-content p {
  color: var(--fg-muted);
  margin-bottom: var(--space-4);
  max-width: 640px;
  font-size: var(--text-base);
  line-height: 1.8;
}

.about-content p:last-child {
  margin-bottom: 0;
}

/* --- Projects --------------------------------------------- */
.project-list {
  display: grid;
  gap: var(--space-5);
  list-style: none;
}

.project-card {
  background-color: var(--bg-alt);
  border: 1px dashed rgba(115, 122, 162, 0.3);
  border-radius: 4px;
  padding: var(--space-5);
  transition: border-color 0.2s ease;
}

.project-card:hover {
  border-color: var(--accent);
}

.project-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}

.project-name {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--fg);
}

.project-links {
  display: flex;
  gap: var(--space-3);
}

.project-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--fg-dim);
  font-size: var(--text-sm);
  transition: color 0.2s ease;
}

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

.project-desc {
  color: var(--fg-muted);
  margin-bottom: var(--space-4);
  line-height: 1.7;
  font-size: var(--text-base);
}

.project-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.project-tech {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  list-style: none;
}

.project-tech li {
  font-size: 0.8rem;
  color: var(--fg-muted);
  background-color: rgba(122, 162, 247, 0.08);
  padding: var(--space-1) var(--space-3);
  border-radius: 3px;
  border: 1px solid rgba(122, 162, 247, 0.15);
  font-weight: 500;
}

.project-status {
  font-size: 0.8rem;
  font-weight: 500;
  padding: var(--space-1) var(--space-3);
  border-radius: 3px;
  white-space: nowrap;
}

.project-status--progress {
  color: var(--accent-warm);
  background-color: rgba(224, 175, 104, 0.1);
  border: 1px solid rgba(224, 175, 104, 0.2);
}

.project-status--done {
  color: var(--success);
  background-color: rgba(158, 206, 106, 0.1);
  border: 1px solid rgba(158, 206, 106, 0.2);
}

/* --- Stack ------------------------------------------------- */
.stack-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
  gap: var(--space-6);
}

.stack-group-title {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--fg);
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid rgba(115, 122, 162, 0.15);
}

.stack-list {
  list-style: none;
}

.stack-list li {
  font-size: var(--text-sm);
  color: var(--fg-muted);
  padding-block: var(--space-2);
  line-height: 1.6;
}

.stack-marker {
  color: var(--accent-warm);
  margin-right: var(--space-2);
}

/* --- Contact ----------------------------------------------- */
.contact-text {
  color: var(--fg-muted);
  margin-bottom: var(--space-6);
  font-size: var(--text-base);
  line-height: 1.7;
  max-width: 540px;
}

.contact-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.contact-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--fg-muted);
  font-size: var(--text-base);
  padding: var(--space-3) var(--space-4);
  border: 1px solid rgba(115, 122, 162, 0.15);
  border-radius: 4px;
  transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
  width: fit-content;
}

.contact-link:hover {
  color: var(--accent);
  border-color: var(--accent);
  background-color: rgba(122, 162, 247, 0.05);
}

.contact-link svg {
  flex-shrink: 0;
  color: var(--accent);
}

/* --- Footer ----------------------------------------------- */
.site-footer {
  padding-block: var(--space-6);
  border-top: 1px solid rgba(115, 122, 162, 0.12);
  text-align: center;
}

.footer-text {
  font-size: var(--text-sm);
  color: var(--fg-dim);
  margin-bottom: var(--space-2);
}

.footer-text strong {
  color: var(--fg-muted);
}

.footer-copy {
  font-size: 0.75rem;
  color: var(--fg-dim);
}

/* ============================================================
   RESPONSIVE — Mobile-first breakpoints
   ============================================================ */

/* Tablet: 640px+ */
@media (min-width: 640px) {
  .terminal-pre {
    font-size: var(--text-sm);
  }
}

/* Desktop: 768px+ */
@media (min-width: 768px) {
  .nav-toggle {
    display: none;
  }

  .nav-list {
    gap: var(--space-6);
  }
}

/* Mobile: below 768px — hamburger menu */
@media (max-width: 767px) {
  .nav-toggle {
    display: block;
  }

  .nav-list {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    background-color: var(--bg-alt);
    border-bottom: 1px solid rgba(115, 122, 162, 0.15);
    padding: var(--space-4) var(--space-5);
    gap: var(--space-4);
  }

  .nav-list.is-open {
    display: flex;
  }

  .nav-toggle[aria-expanded="true"] .hamburger {
    background-color: transparent;
  }

  .nav-toggle[aria-expanded="true"] .hamburger::before {
    transform: rotate(45deg);
    top: 0;
  }

  .nav-toggle[aria-expanded="true"] .hamburger::after {
    transform: rotate(-45deg);
    top: 0;
  }

  .hero {
    padding-block: var(--space-6) var(--space-5);
  }

  .terminal-body {
    padding: var(--space-4);
    min-height: 240px;
  }

  .terminal-pre {
    font-size: 0.8rem;
  }

  .terminal-input {
    font-size: 0.8rem;
  }

  .terminal-skip {
    font-size: 0.8rem;
  }
}

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

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

  /* Show all terminal commands immediately — no typing effect */
  .terminal-cmd {
    max-width: 100% !important;
    white-space: nowrap !important;
    overflow: visible !important;
  }

  /* Show all output text immediately */
  .terminal-output-text {
    opacity: 1 !important;
  }

  /* Pause cursor blink */
  .terminal-cursor {
    animation: none;
    opacity: 1;
  }
}
