/* ============================================================
   Portfolio — style.css
   Plain CSS, no frameworks, no JavaScript.
   Edit the tokens below to re-theme the whole site.
   ============================================================ */

:root {
  /* Type */
  --font-display: "Space Grotesk", "Segoe UI", sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", "Consolas", monospace;

  /* Palette — warm paper + ink, one accent (terracotta) */
  --paper: #faf7f2;
  --paper-alt: #f2ede4;
  --ink: #191713;
  --ink-soft: #4c473e;
  --ink-muted: #756e62;
  --line: #e2dbcd;
  --accent: #c1502e;
  --accent-deep: #a23e1f;
  --accent-tint: #f6e3d9;
  --terminal-bg: #1e1b16;
  --terminal-ink: #e8e2d6;
  --terminal-green: #7fb069;

  /* Spacing & shape */
  --container: 72rem;
  --gutter: 1.5rem;
  --section-pad: clamp(4rem, 10vw, 7.5rem);
  --radius: 6px;
  --radius-lg: 10px;
}

/* ---------- Dark theme (toggle in header, pure CSS :has()) ---------- */

:root:has(#dark-toggle:checked) {
  --paper: #17140f;
  --paper-alt: #201c16;
  --ink: #ece5d8;
  --ink-soft: #b7af9f;
  --ink-muted: #8a8274;
  --line: #35302a;
  --accent: #e4764a;
  --accent-deep: #eb9670;
  --accent-tint: #2b1e14;
  --terminal-bg: #100e0b;
  --terminal-ink: #e8e2d6;
  --terminal-green: #7fb069;
}

/* Primary button needs dark ink on the lighter accent in dark mode */
:root:has(#dark-toggle:checked) .btn-primary {
  color: #1a1410;
}

:root:has(#dark-toggle:checked) .terminal {
  box-shadow: 0 24px 48px -24px rgba(0, 0, 0, 0.65);
}

/* ---------- Theme toggle ---------- */

.header-actions {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.theme-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  user-select: none;
}

.theme-toggle-label svg {
  width: 15px;
  height: 15px;
  flex: none;
}

.icon-sun {
  color: var(--ink-muted);
}

.icon-moon {
  color: var(--ink-muted);
}

.theme-toggle-track {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  border-radius: 999px;
  background: var(--paper-alt);
  border: 1px solid var(--line);
  transition: background-color 160ms ease, border-color 160ms ease;
}

.theme-toggle-track input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}

.theme-toggle-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  transition: transform 180ms ease, background-color 160ms ease;
}

:root:has(#dark-toggle:checked) .theme-toggle-knob {
  transform: translateX(20px);
}

:root:has(#dark-toggle:checked) .icon-moon {
  color: var(--accent-deep);
}

.theme-toggle-label:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ---------- Reset & base ---------- */

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.65;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

img,
svg {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
}

ul,
ol {
  list-style: none;
}

.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* Visible focus for keyboard users */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ink);
  color: var(--paper);
  padding: 0.75rem 1.25rem;
  z-index: 100;
}

.skip-link:focus {
  left: 1rem;
  top: 1rem;
}

/* ---------- Typography primitives ---------- */

h1,
h2,
h3 {
  font-family: var(--font-display);
  line-height: 1.15;
  font-weight: 700;
  text-wrap: balance;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-deep);
}

.note-placeholder {
  color: var(--ink-muted);
  font-style: italic;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px; /* touch target */
  padding: 0.75rem 1.5rem;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1rem;
  text-decoration: none;
  border-radius: var(--radius);
  transition: background-color 160ms ease, color 160ms ease,
    border-color 160ms ease, transform 160ms ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-deep);
}

.btn-ghost {
  border: 1px solid var(--line);
  color: var(--ink);
  background: transparent;
}

.btn-ghost:hover {
  border-color: var(--ink);
  background: var(--paper-alt);
}

/* ---------- Header ---------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 4.5rem;
}

.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.125rem;
  text-decoration: none;
}

.brand-dot {
  color: var(--accent);
}

.nav-list {
  display: flex;
  gap: 2rem;
}

.nav-list a {
  font-size: 0.9375rem;
  text-decoration: none;
  color: var(--ink-soft);
  padding: 0.5rem 0;
  border-bottom: 2px solid transparent;
  transition: color 160ms ease, border-color 160ms ease;
}

.nav-list a:hover {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

/* ---------- Hero ---------- */

.hero {
  padding-block: clamp(3.5rem, 9vw, 6.5rem) var(--section-pad);
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: clamp(2.5rem, 6vw, 5rem);
  align-items: center;
}

.hero-copy .eyebrow {
  margin-bottom: 1.25rem;
}

.hero-title {
  font-size: clamp(2.25rem, 5vw, 3.5rem);
  letter-spacing: -0.015em;
  margin-bottom: 1.5rem;
}

.hero-text {
  color: var(--ink-soft);
  max-width: 34rem;
  margin-bottom: 2.25rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

/* ---------- Terminal card ---------- */

.terminal {
  background: var(--terminal-bg);
  color: var(--terminal-ink);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 24px 48px -24px rgba(25, 23, 19, 0.35);
  font-family: var(--font-mono);
}

.terminal-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

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

.terminal-name {
  margin-left: auto;
  font-size: 0.75rem;
  color: #8f887a;
}

.terminal-body {
  padding: 1.5rem;
  font-size: 0.875rem;
  line-height: 1.7;
  overflow-x: auto;
}

.t-prompt {
  color: var(--terminal-green);
}

.t-comment {
  color: #8f887a;
}

.t-ok {
  color: var(--terminal-green);
}

/* Learning progress board */
.t-label {
  color: var(--terminal-ink);
}

.t-bar {
  color: var(--terminal-green);
}

.t-dim {
  color: #57534a;
}

.cursor {
  display: inline-block;
  width: 0.55em;
  height: 1.05em;
  vertical-align: text-bottom;
  background: var(--terminal-ink);
  animation: blink 1.1s steps(1) infinite;
}

@keyframes blink {
  0%, 55% { opacity: 1; }
  56%, 100% { opacity: 0; }
}

/* ---------- Sections ---------- */

.section {
  padding-block: var(--section-pad);
}

.section-alt {
  background: var(--paper-alt);
  border-block: 1px solid var(--line);
}

.section-head {
  margin-bottom: clamp(2.5rem, 5vw, 4rem);
}

.section-title {
  font-size: clamp(1.75rem, 3.5vw, 2.25rem);
  letter-spacing: -0.01em;
}

.section-note {
  margin-top: 0.75rem;
  color: var(--ink-muted);
  max-width: 42rem;
}

/* ---------- Projects ---------- */

.project-list {
  border-top: 1px solid var(--line);
}

.project {
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: 1.5rem 2rem;
  padding-block: clamp(1.75rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--line);
}

.project-meta {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--ink-muted);
  padding-top: 0.35rem; /* align with title baseline */
}

.project-index {
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--accent);
  line-height: 1.2;
}

.project-title {
  font-size: clamp(1.25rem, 2.5vw, 1.625rem);
  letter-spacing: -0.01em;
}

.project-title a {
  text-decoration: none;
  transition: color 160ms ease;
}

.project-title a:hover {
  color: var(--accent-deep);
}

.project-text {
  margin-top: 0.75rem;
  color: var(--ink-soft);
  max-width: 44rem;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

.tag-list li {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  background: var(--paper);
}

/* ---------- Stack ---------- */

.stack-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(2rem, 5vw, 3.5rem);
}

.stack-label {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-deep);
  margin-bottom: 1.25rem;
}

.stack-items {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.stack-items li {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  background: var(--paper-alt);
}

/* ---------- About ---------- */

.about-grid {
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 2rem clamp(2.5rem, 6vw, 5rem);
}

.about-copy p + p {
  margin-top: 1.25rem;
}

.about-copy p {
  color: var(--ink-soft);
  max-width: 40rem;
}

/* ---------- Contact ---------- */

.section-contact {
  border-top: 1px solid var(--line);
  background:
    radial-gradient(
      120% 100% at 50% 0%,
      var(--accent-tint) 0%,
      var(--paper) 65%
    );
}

.contact-inner {
  max-width: 46rem;
}

.contact-inner .eyebrow {
  margin-bottom: 1rem;
}

.contact-title {
  font-size: clamp(2rem, 4.5vw, 3rem);
  letter-spacing: -0.015em;
  margin-bottom: 1.25rem;
}

.contact-text {
  color: var(--ink-soft);
  max-width: 34rem;
  margin-bottom: 2rem;
}

.contact-email {
  display: inline-block;
  font-family: var(--font-display);
  font-size: clamp(1.125rem, 2.5vw, 1.5rem);
  font-weight: 500;
  color: var(--accent-deep);
  text-decoration: none;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 0.15rem;
  transition: color 160ms ease, border-color 160ms ease;
}

.contact-email:hover {
  color: var(--accent);
  border-bottom-color: var(--accent-deep);
}

.contact-phone {
  margin-top: 1rem;
  font-family: var(--font-mono);
  font-size: 0.9375rem;
  color: var(--ink-soft);
}

/* Inline text link (used in section notes) */
.text-link {
  color: var(--accent-deep);
  text-decoration: none;
  border-bottom: 1px solid var(--accent);
  transition: color 160ms ease;
}

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

/* "View source on GitHub" row under projects */
.project-link {
  margin-top: 1.25rem;
}

.project-link a {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--accent-deep);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  padding: 0.25rem 0;
  transition: color 160ms ease, border-color 160ms ease;
}

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

.project-link .arrow {
  transition: transform 160ms ease;
}

.project-link a:hover .arrow {
  transform: translateX(3px);
}

.social-list {
  display: flex;
  gap: 1.75rem;
  margin-top: 2.5rem;
}

.social-list a {
  font-size: 0.9375rem;
  color: var(--ink-soft);
  text-decoration: none;
  padding: 0.5rem 0; /* keep 44px-ish hit area with line-height */
  transition: color 160ms ease;
}

.social-list a:hover {
  color: var(--ink);
}

/* ---------- Footer ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  padding-block: 2rem;
}

.footer-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.footer-inner p {
  font-size: 0.875rem;
  color: var(--ink-muted);
}

.to-top {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--ink-soft);
  text-decoration: none;
}

.to-top:hover {
  color: var(--accent-deep);
}

/* ---------- Responsive ---------- */

@media (max-width: 60rem) {
  .hero-grid {
    grid-template-columns: 1fr;
  }

  .terminal {
    order: 2;
  }

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

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

@media (max-width: 46rem) {
  /* Six nav links don't fit beside the brand on small phones —
     contact section is always reachable at the page bottom */
  .nav-list {
    display: none;
  }
}

@media (max-width: 52rem) {
  .nav-list {
    gap: 0.85rem;
  }

  .nav-list a {
    font-size: 0.8125rem;
  }

  .theme-toggle-label {
    gap: 0.35rem;
  }

  .theme-toggle-label svg {
    width: 13px;
    height: 13px;
  }
}

@media (max-width: 40rem) {
  .project {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .project-meta {
    flex-direction: row;
    align-items: baseline;
    gap: 0.75rem;
  }

  .stack-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .hero-actions .btn {
    width: 100%;
  }

  .footer-inner {
    justify-content: center;
    text-align: center;
  }
}

/* ---------- Motion preferences ---------- */

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

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

  .cursor {
    animation: none;
    opacity: 1;
  }
}
