/* ==========================================================================
   RedCamel — Refined Minimalism Stylesheet
   ========================================================================== */

:root {
  color-scheme: light dark;

  /* Raw light & dark color tokens */
  --bg-light: #fafafa;
  --bg-dark: #0a0a0c;

  --surface-light: #ffffff;
  --surface-dark: #111114;

  --surface-hover-light: rgba(17, 17, 19, 0.03);
  --surface-hover-dark: rgba(255, 255, 255, 0.035);

  --text-light: #111113;
  --text-dark: #ededef;

  --text-secondary-light: #52525b;
  --text-secondary-dark: #a1a1aa;

  --text-muted-light: #71717a;
  --text-muted-dark: #71717a;

  --border-light: rgba(17, 17, 19, 0.09);
  --border-dark: rgba(255, 255, 255, 0.09);

  --border-strong-light: rgba(17, 17, 19, 0.18);
  --border-strong-dark: rgba(255, 255, 255, 0.18);

  --accent-light: #dc2626;
  --accent-dark: #ef4444;

  --accent-soft-light: rgba(220, 38, 38, 0.08);
  --accent-soft-dark: rgba(239, 68, 68, 0.12);

  --glow-light: rgba(220, 38, 38, 0.045);
  --glow-dark: rgba(239, 68, 68, 0.075);

  /* Fallback default (light) */
  --bg: var(--bg-light);
  --surface: var(--surface-light);
  --surface-hover: var(--surface-hover-light);
  --text: var(--text-light);
  --text-secondary: var(--text-secondary-light);
  --text-muted: var(--text-muted-light);
  --border: var(--border-light);
  --border-strong: var(--border-strong-light);
  --accent: var(--accent-light);
  --accent-soft: var(--accent-soft-light);
  --glow: var(--glow-light);

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Layout */
  --max-width: 720px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

/* Reflect explicit meta[name="color-scheme"] override in CSS */
:root:has(> head > meta[name="color-scheme"][content="dark"]) {
  color-scheme: dark;
}

:root:has(> head > meta[name="color-scheme"][content="light"]) {
  color-scheme: light;
}

/* Fallback for browsers without light-dark() */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--bg-dark);
    --surface: var(--surface-dark);
    --surface-hover: var(--surface-hover-dark);
    --text: var(--text-dark);
    --text-secondary: var(--text-secondary-dark);
    --text-muted: var(--text-muted-dark);
    --border: var(--border-dark);
    --border-strong: var(--border-strong-dark);
    --accent: var(--accent-dark);
    --accent-soft: var(--accent-soft-dark);
    --glow: var(--glow-dark);
  }
}

/* Modern light-dark() tokens */
@supports (color: light-dark(white, black)) {
  :root {
    --bg: light-dark(var(--bg-light), var(--bg-dark));
    --surface: light-dark(var(--surface-light), var(--surface-dark));
    --surface-hover: light-dark(var(--surface-hover-light), var(--surface-hover-dark));
    --text: light-dark(var(--text-light), var(--text-dark));
    --text-secondary: light-dark(var(--text-secondary-light), var(--text-secondary-dark));
    --text-muted: light-dark(var(--text-muted-light), var(--text-muted-dark));
    --border: light-dark(var(--border-light), var(--border-dark));
    --border-strong: light-dark(var(--border-strong-light), var(--border-strong-dark));
    --accent: light-dark(var(--accent-light), var(--accent-dark));
    --accent-soft: light-dark(var(--accent-soft-light), var(--accent-soft-dark));
    --glow: light-dark(var(--glow-light), var(--glow-dark));
  }
}

/* Theme toggle icon visibility driven purely by active color-scheme */
.theme-icon--to-light,
.theme-label--to-light {
  display: none;
}

.theme-icon--to-dark,
.theme-label--to-dark {
  display: inline-flex;
}

@media (prefers-color-scheme: dark) {
  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) .theme-icon--to-light,
  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) .theme-label--to-light {
    display: inline-flex;
  }

  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) .theme-icon--to-dark,
  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) .theme-label--to-dark {
    display: none;
  }
}

:root:has(> head > meta[name="color-scheme"][content="dark"]) .theme-icon--to-light,
:root:has(> head > meta[name="color-scheme"][content="dark"]) .theme-label--to-light {
  display: inline-flex;
}

:root:has(> head > meta[name="color-scheme"][content="dark"]) .theme-icon--to-dark,
:root:has(> head > meta[name="color-scheme"][content="dark"]) .theme-label--to-dark {
  display: none;
}

/* Base Reset */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  accent-color: var(--accent);
}

body {
  margin: 0;
  min-height: 100dvh;
  background-color: var(--bg);
  background-image: radial-gradient(640px 320px at 50% -80px, var(--glow), transparent 72%);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.65;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

::selection {
  background-color: var(--accent-soft);
  color: var(--text);
}

a {
  color: inherit;
  text-decoration: none;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.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;
}

.skip-link {
  position: absolute;
  top: -48px;
  left: 16px;
  padding: 8px 14px;
  background: var(--text);
  color: var(--bg);
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  z-index: 100;
  transition: top 160ms var(--ease);
}

.skip-link:focus {
  top: 16px;
}

/* Container */
.page {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 40px 24px 80px;
}

/* Header */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 56px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text);
}

.brand-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.nav-link {
  font-size: 13.5px;
  color: var(--text-secondary);
  transition: color 160ms var(--ease);
}

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

.arrow {
  display: inline-block;
  margin-left: 2px;
  font-size: 0.9em;
  opacity: 0.65;
  transition: transform 180ms var(--ease), opacity 180ms var(--ease);
}

a:hover .arrow {
  transform: translate(2px, -2px);
  opacity: 1;
}

.icon-link,
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 160ms var(--ease), border-color 160ms var(--ease), background-color 160ms var(--ease);
}

.icon-link:hover,
.theme-toggle:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background-color: var(--surface-hover);
}

.icon-link--subtle {
  border-color: transparent;
}

.icon-link--subtle:hover {
  border-color: var(--border);
}

/* Hero */
.hero {
  padding: 20px 0 56px;
}

.hero-title {
  margin: 0 0 12px;
  font-size: clamp(2rem, 4.8vw, 2.5rem);
  font-weight: 500;
  line-height: 1.16;
  letter-spacing: -0.03em;
  text-wrap: balance;
}

.hero-lead {
  margin: 0;
  max-width: 54ch;
  font-size: 15.5px;
  line-height: 1.7;
  color: var(--text-secondary);
  text-wrap: pretty;
}

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

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.section-title {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--text);
}

.section-meta {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
}

/* Projects */
.project-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.project-item {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 18px;
  padding: 20px 16px;
  margin: 0 -16px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  transition: background-color 180ms var(--ease), border-color 180ms var(--ease);
}

.project-item:hover {
  background-color: var(--surface-hover);
  border-color: var(--border);
}

.project-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin-top: 2px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background-color: var(--surface);
  transition: border-color 180ms var(--ease), transform 180ms var(--ease);
}

.project-logo img {
  display: block;
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.project-item:hover .project-logo {
  border-color: var(--border-strong);
}

.project-logo:hover {
  transform: translateY(-1px);
}

.project-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.project-name {
  margin: 0;
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.project-name a {
  transition: color 160ms var(--ease);
}

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

.project-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
}

.project-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--accent);
}

.project-desc {
  margin: 0 0 16px;
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--text-secondary);
  text-wrap: pretty;
}

.project-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-muted);
}

.project-links {
  display: inline-flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  font-weight: 500;
}

.project-links a {
  color: var(--text);
  border-bottom: 1px solid var(--border-strong);
  padding-bottom: 1px;
  transition: color 160ms var(--ease), border-color 160ms var(--ease);
}

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

/* Footer */
.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 24px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
}

.footer-copy {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 12px;
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.footer-email {
  margin-right: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  transition: color 160ms var(--ease);
}

.footer-email:hover {
  color: var(--text);
}

/* Responsive */
@media (max-width: 600px) {
  .page {
    padding: 28px 20px 64px;
  }

  .site-header {
    padding-bottom: 40px;
  }

  .header-nav {
    gap: 14px;
  }

  .hero {
    padding: 8px 0 48px;
  }

  .project-item {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 18px 12px;
    margin: 0 -12px;
  }

  .site-footer {
    flex-direction: column;
    align-items: flex-start;
  }
}

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

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