/* ============================================================
   NELIX — Main Stylesheet
   nelix.co.uk
   ============================================================ */

/* ── Google Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;700&family=DM+Sans:wght@300;400;500&display=swap');

/* ============================================================
   THEME TOKENS
   ============================================================ */

:root {
  /* Brand */
  --clr-accent:        #00e5c0;
  --clr-accent-dim:    #00b89a;
  --clr-accent-faint:  rgba(0, 229, 192, 0.08);
  --clr-accent-border: rgba(0, 229, 192, 0.25);

  /* Dark mode (default) */
  --clr-bg:            #0d1117;
  --clr-bg-surface:    #161b22;
  --clr-bg-elevated:   #1c2333;
  --clr-bg-code:       #0a0e14;
  --clr-border:        #1e3a33;
  --clr-border-subtle: #1a2030;

  --clr-text-primary:   #e6edf3;
  --clr-text-secondary: #8b949e;
  --clr-text-muted:     #4a7c70;
  --clr-text-accent:    #00e5c0;

  /* Typography */
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;
  --font-body: 'DM Sans', system-ui, sans-serif;

  /* Spacing scale */
  --sp-1:  4px;
  --sp-2:  8px;
  --sp-3:  12px;
  --sp-4:  16px;
  --sp-5:  24px;
  --sp-6:  32px;
  --sp-7:  48px;
  --sp-8:  64px;
  --sp-9:  96px;
  --sp-10: 128px;

  /* Radii */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast: 150ms;
  --dur-mid:  250ms;
  --dur-slow: 400ms;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.6);
  --shadow-accent: 0 0 24px rgba(0, 229, 192, 0.12);

  /* Layout */
  --max-w: 1100px;

  /* Nav height — tracks the fluid logo height + padding */
  --nav-h: clamp(60px, 10vw, 80px);
}

/* ── Light mode overrides ── */
[data-theme="light"] {
  /* Backgrounds */
  --clr-bg:            #f0f4f2;
  --clr-bg-surface:    #ffffff;
  --clr-bg-elevated:   #e4eeea;
  --clr-bg-code:       #e8f0ed;
  --clr-border:        #9dc4b8;
  --clr-border-subtle: #c6ddd6;

  /* Text — strong dark values, not washed-out mid-tones */
  --clr-text-primary:   #0a0f0d;
  --clr-text-secondary: #1e3d35;
  --clr-text-muted:     #3a6b5e;
  --clr-text-accent:    #007a65;

  /* Accent — deeper teal so it pops on white */
  --clr-accent:        #00b89a;
  --clr-accent-dim:    #009980;
  --clr-accent-faint:  rgba(0, 184, 154, 0.1);
  --clr-accent-border: rgba(0, 184, 154, 0.4);

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.12);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.15);
  --shadow-accent: 0 0 24px rgba(0, 184, 154, 0.2);
}

/* ============================================================
   RESET & BASE
   ============================================================ */

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

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.7;
  color: var(--clr-text-primary);
  background: var(--clr-bg);
  transition: background var(--dur-mid) var(--ease),
              color var(--dur-mid) var(--ease);
  min-height: 100vh;
}

a {
  color: var(--clr-accent);
  text-decoration: none;
  transition: color var(--dur-fast) var(--ease),
              opacity var(--dur-fast) var(--ease);
}
a:hover { opacity: 0.8; }

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

ul { list-style: none; }

/* ============================================================
   TYPOGRAPHY
   ============================================================ */

h1, h2, h3, h4 {
  font-family: var(--font-mono);
  font-weight: 700;
  line-height: 1.2;
  color: var(--clr-text-primary);
}

h1 { font-size: clamp(2rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.4rem, 3vw, 2rem); }
h3 { font-size: 1.1rem; }

p { color: var(--clr-text-secondary); max-width: 60ch; }

.mono { font-family: var(--font-mono); }

.label {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--clr-text-muted);
}

/* ============================================================
   LAYOUT UTILITIES
   ============================================================ */

.container {
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--sp-6);
}

.flex          { display: flex; }
.flex-col      { flex-direction: column; }
.items-center  { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--sp-2); }
.gap-4 { gap: var(--sp-4); }
.gap-5 { gap: var(--sp-5); }
.gap-6 { gap: var(--sp-6); }

/* ============================================================
   NAV
   ============================================================ */

.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  z-index: 100;
  background: var(--clr-bg);
  border-bottom: 1px solid var(--clr-border-subtle);
  transition: background var(--dur-mid) var(--ease),
              border-color var(--dur-mid) var(--ease);
}

.nav__inner {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Logo link */
.nav__logo {
  display: flex;
  align-items: center;
  text-decoration: none;
  margin-right: var(--sp-5);
}

/*
 * Inline SVG logo — theme-aware text colours.
 * Dark mode default; light mode overridden below.
 */
.logo-wordmark { fill: #e6edf3; }
.logo-tagline  { fill: #4a7c70; }

[data-theme="light"] .logo-wordmark { fill: #0a0f0d; }
[data-theme="light"] .logo-tagline  { fill: #2a5a50; }

/*
 * Responsive logo sizing.
 * viewBox is 480×120 (4:1). Height is fluid; width follows via auto.
 * max-width: 40vw prevents squashing nav links on mid-size windows.
 */
.nav__logo-img {
  display: block;
  width: auto;
  height: clamp(32px, 8vw, 56px);
  max-width: 40vw;
  flex-shrink: 0;
}

.nav__links {
  display: flex;
  align-items: center;
  gap: var(--sp-6);
}

.nav__link {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  color: var(--clr-text-muted);
  transition: color var(--dur-fast) var(--ease);
  white-space: nowrap;
}
.nav__link:hover { color: var(--clr-accent); opacity: 1; }

/* Theme toggle */
.theme-toggle {
  width: 44px;
  height: 24px;
  background: var(--clr-bg-elevated);
  border: 1px solid var(--clr-border);
  border-radius: 12px;
  cursor: pointer;
  position: relative;
  transition: background var(--dur-mid) var(--ease),
              border-color var(--dur-mid) var(--ease);
  flex-shrink: 0;
}

.theme-toggle__knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--clr-accent);
  transition: transform var(--dur-mid) var(--ease),
              background var(--dur-mid) var(--ease);
}

[data-theme="light"] .theme-toggle__knob {
  transform: translateX(20px);
}

.theme-toggle__icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  pointer-events: none;
  transition: opacity var(--dur-fast) var(--ease);
}
.theme-toggle__icon--moon { right: 6px; opacity: 1; }
.theme-toggle__icon--sun  { left: 6px;  opacity: 0; }

[data-theme="light"] .theme-toggle__icon--moon { opacity: 0; }
[data-theme="light"] .theme-toggle__icon--sun  { opacity: 1; }

/* ============================================================
   HERO
   ============================================================ */

.hero {
  padding-top: calc(var(--nav-h) + var(--sp-10));
  padding-bottom: var(--sp-10);
  position: relative;
  overflow: hidden;
}

/* Scanline texture overlay */
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(0, 229, 192, 0.015) 3px,
    rgba(0, 229, 192, 0.015) 4px
  );
  pointer-events: none;
}

/* Corner accent brackets */
.hero::after {
  content: '';
  position: absolute;
  top: calc(var(--nav-h) + 32px);
  right: 48px;
  width: 120px;
  height: 120px;
  border-top: 1px solid var(--clr-accent-border);
  border-right: 1px solid var(--clr-accent-border);
  pointer-events: none;
  transition: border-color var(--dur-mid) var(--ease);
}

.hero__prompt {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--clr-text-muted);
  letter-spacing: 0.08em;
  margin-bottom: var(--sp-4);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.hero__prompt::before {
  content: '~/nelix';
  color: var(--clr-accent);
}

.hero__prompt::after {
  content: '';
  display: inline-block;
  width: 10px;
  height: 18px;
  background: var(--clr-accent);
  border-radius: 2px;
  animation: blink 1.1s step-end infinite;
  margin-left: 2px;
}

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

.hero__title {
  margin-bottom: var(--sp-5);
}

.hero__title em {
  font-style: normal;
  color: var(--clr-accent);
}

.hero__sub {
  font-size: 1.1rem;
  font-weight: 300;
  color: var(--clr-text-secondary);
  margin-bottom: var(--sp-7);
  max-width: 52ch;
}

.hero__actions {
  display: flex;
  gap: var(--sp-4);
  flex-wrap: wrap;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
  text-decoration: none;
}

.btn--primary {
  background: var(--clr-accent);
  color: #0d1117;
  border-color: var(--clr-accent);
}
.btn--primary:hover {
  background: var(--clr-accent-dim);
  border-color: var(--clr-accent-dim);
  opacity: 1;
  box-shadow: var(--shadow-accent);
}

.btn--ghost {
  background: transparent;
  color: var(--clr-text-secondary);
  border-color: var(--clr-border);
}
.btn--ghost:hover {
  border-color: var(--clr-accent-border);
  color: var(--clr-accent);
  opacity: 1;
}

/* ============================================================
   SECTION
   ============================================================ */

.section {
  padding: var(--sp-9) 0;
  border-top: 1px solid var(--clr-border-subtle);
}

.section__header {
  margin-bottom: var(--sp-7);
}

.section__header .label {
  margin-bottom: var(--sp-3);
}

/* ============================================================
   PROJECT CARDS
   ============================================================ */

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--sp-5);
}

.card {
  background: var(--clr-bg-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-6);
  position: relative;
  overflow: hidden;
  transition: border-color var(--dur-mid) var(--ease),
              box-shadow var(--dur-mid) var(--ease),
              transform var(--dur-mid) var(--ease);
}

.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--clr-accent);
  opacity: 0;
  transition: opacity var(--dur-mid) var(--ease);
}

.card:hover {
  border-color: var(--clr-accent-border);
  box-shadow: var(--shadow-accent);
  transform: translateY(-2px);
}

.card:hover::before {
  opacity: 1;
}

.card__tag {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  color: var(--clr-accent);
  background: var(--clr-accent-faint);
  border: 1px solid var(--clr-accent-border);
  border-radius: var(--radius-sm);
  padding: 2px 8px;
  display: inline-block;
  margin-bottom: var(--sp-4);
}

.card__title {
  font-size: 1rem;
  margin-bottom: var(--sp-3);
}

.card__desc {
  font-size: 0.9rem;
  color: var(--clr-text-muted);
  line-height: 1.6;
  max-width: none;
}

.card__footer {
  margin-top: var(--sp-5);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--clr-border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card__stack {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.pill {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  color: var(--clr-text-muted);
  background: var(--clr-bg-elevated);
  border-radius: 100px;
  padding: 2px 10px;
}

.card__link {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  color: var(--clr-accent);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ============================================================
   ABOUT / TERMINAL BLOCK
   ============================================================ */

.terminal {
  background: var(--clr-bg-code);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 0.88rem;
  line-height: 1.8;
  transition: background var(--dur-mid) var(--ease),
              border-color var(--dur-mid) var(--ease);
}

.terminal__bar {
  background: var(--clr-bg-elevated);
  border-bottom: 1px solid var(--clr-border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.terminal__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.terminal__dot:nth-child(1) { background: #ff5f57; }
.terminal__dot:nth-child(2) { background: #febc2e; }
.terminal__dot:nth-child(3) { background: #28c840; }

.terminal__title {
  font-size: 0.72rem;
  color: var(--clr-text-muted);
  letter-spacing: 0.08em;
  margin-left: auto;
  margin-right: auto;
}

.terminal__body {
  padding: var(--sp-6);
  color: var(--clr-text-secondary);
  overflow-x: auto;
}

.terminal__line { display: flex; gap: var(--sp-3); }

.terminal__prompt { color: var(--clr-text-muted); user-select: none; }
.terminal__cmd    { color: var(--clr-text-primary); }
.terminal__comment { color: var(--clr-text-muted); }
.terminal__str    { color: #a8d8a0; }
.terminal__key    { color: #79b8ff; }
.terminal__out    { color: var(--clr-text-muted); padding-left: calc(var(--sp-3) + 1ch); }

/* In light mode keep terminal string/key colours readable */
[data-theme="light"] .terminal__str { color: #2a7a40; }
[data-theme="light"] .terminal__key { color: #1a5fa8; }

/* ============================================================
   PALETTE SWATCH SECTION
   ============================================================ */

.palette {
  display: flex;
  gap: var(--sp-3);
  flex-wrap: wrap;
  margin-top: var(--sp-5);
}

.swatch {
  flex: 1;
  min-width: 80px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--clr-border-subtle);
}

.swatch__color {
  height: 64px;
}

.swatch__info {
  padding: var(--sp-2) var(--sp-3);
  background: var(--clr-bg-surface);
}

.swatch__name {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--clr-text-secondary);
  display: block;
}

.swatch__hex {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--clr-text-muted);
}

/* ============================================================
   FOOTER
   ============================================================ */

.footer {
  border-top: 1px solid var(--clr-border-subtle);
  padding: var(--sp-7) 0;
  transition: border-color var(--dur-mid) var(--ease);
}

.footer__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--sp-4);
}

.footer__copy {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--clr-text-muted);
  letter-spacing: 0.06em;
}

.footer__links {
  display: flex;
  gap: var(--sp-5);
}

.footer__link {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--clr-text-muted);
  letter-spacing: 0.06em;
}
.footer__link:hover { color: var(--clr-accent); opacity: 1; }

/* ============================================================
   SCROLL REVEAL ANIMATION
   ============================================================ */

.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity var(--dur-slow) var(--ease),
              transform var(--dur-slow) var(--ease);
}
.reveal.visible {
  opacity: 1;
  transform: none;
}

/* Stagger delays */
.reveal:nth-child(1) { transition-delay: 0ms; }
.reveal:nth-child(2) { transition-delay: 80ms; }
.reveal:nth-child(3) { transition-delay: 160ms; }
.reveal:nth-child(4) { transition-delay: 240ms; }

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* Medium — hide some nav links before they crowd the logo */
@media (max-width: 860px) {
  .nav__links li:nth-child(n+3) { display: none; }
}

/* Small — hide all nav links, tighten container padding */
@media (max-width: 600px) {
  .nav__links { display: none; }
  .container  { padding: 0 var(--sp-4); }
  .hero       { padding-top: calc(var(--nav-h) + var(--sp-8)); }
  .hero::after { display: none; }
  .projects-grid { grid-template-columns: 1fr; }
  .palette { gap: var(--sp-2); }
  .footer__inner { flex-direction: column; align-items: flex-start; }
}