@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,400;0,500;0,600;0,700;0,800;1,400&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Caveat:wght@500;600;700&display=swap');

:root[data-theme="light"] {
  --bg: #faf9f4;
  --fg: #201f1b;
  --muted: #7c756c;
  --border: rgba(32, 31, 27, 0.10);
  --border-strong: rgba(32, 31, 27, 0.18);
  --accent: #c1552f;
  --accent-fg: #ffffff;
  --card-bg: #ffffff;
  --card-shadow: 0 1px 2px rgba(20,21,26,0.04), 0 8px 24px rgba(20,21,26,0.04);
  --grid-line: rgba(32, 31, 27, 0.045);
  --code-bg: #ffffff;
  --code-fg: #201f1b;
  --code-accent: #c1552f;
}

:root[data-theme="dark"] {
  --bg: #1c1a17;
  --fg: #f2ede4;
  --muted: #a39a8d;
  --border: rgba(242, 237, 228, 0.08);
  --border-strong: rgba(242, 237, 228, 0.16);
  --accent: #e8916c;
  --accent-fg: #201510;
  --card-bg: #242220;
  --card-shadow: 0 1px 2px rgba(0,0,0,0.35), 0 8px 24px rgba(0,0,0,0.4);
  --grid-line: rgba(242, 237, 228, 0.035);
  --code-bg: #15130f;
  --code-fg: #e9dfce;
  --code-accent: #e8916c;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
}

/* ---------- FOCUS STATES (a11y polish) ---------- */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- READING PROGRESS BAR ---------- */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: transparent;
  z-index: 60;
  pointer-events: none;
}
.reading-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent);
  box-shadow: 0 0 8px color-mix(in srgb, var(--accent) 60%, transparent);
  transition: width .08s linear;
}

body {
  margin: 0;
  background-color: var(--bg);
  color: var(--fg);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 42px 42px;
  transition: background-color .25s ease, color .25s ease;
  min-height: 100vh;
}

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

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

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 32px;
}

/* Centered reading column for static text pages (about / cv),
   matching how .project-body centers the project detail page */
.text-page {
  max-width: 90ch;
  margin: 0 auto;
}

/* ---------- NAV ---------- */
.nav {
  border-bottom: 1px solid transparent;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 50;
  transition: border-color .2s ease, box-shadow .2s ease;
}
.nav.scrolled {
  border-bottom-color: var(--border);
}
.nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.brand {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 2px;
}
.brand .dollar { color: var(--accent); }
.cursor {
  display: inline-block;
  width: 7px;
  height: 15px;
  background: var(--accent);
  margin-left: 6px;
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.nav-right {
  display: flex;
  align-items: center;
  gap: 28px;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 26px;
  font-size: 13.5px;
  color: var(--muted);
}
.nav-links a { transition: color .15s ease; position: relative; }
.nav-links a:hover { color: var(--fg); }
.nav-links a.active { color: var(--accent); }

.theme-toggle {
  border: none;
  background: transparent;
  color: var(--muted);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color .15s ease, background-color .15s ease, transform .15s ease;
}
.theme-toggle:hover { color: var(--fg); background: var(--border-strong); }
.theme-toggle:active { transform: scale(.92); }
.theme-toggle svg { width: 16px; height: 16px; }

/* ---------- HAMBURGER (mobile nav) ---------- */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 38px;
  height: 38px;
  border: none;
  background: transparent;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  transition: background-color .15s ease;
}
.hamburger:hover { background: var(--border-strong); }
.hamburger:active { transform: scale(.92); }
.hamburger span {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: var(--fg);
  transition: transform .25s cubic-bezier(.22,1,.36,1), opacity .2s ease;
}
.nav.nav-open .hamburger span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav.nav-open .hamburger span:nth-child(2) { opacity: 0; }
.nav.nav-open .hamburger span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ---------- HERO ---------- */
.hero {
  margin-top: 25px;
  padding: 96px 0 72px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 48px;
  align-items: start;
}
.status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 26px;
  animation: fadeUp .55s cubic-bezier(.22,1,.36,1) 0s both;
}
.status-line .cm { color: var(--accent); font-weight: 700; }
.hero h1 {
  font-size: 58px;
  line-height: 1.02;
  letter-spacing: -0.03em;
  margin: 0 0 22px;
  font-weight: 800;
  animation: fadeUp .55s cubic-bezier(.22,1,.36,1) .1s both;
}
.hero .tagline {
  font-size: 15.5px;
  color: var(--accent);
  margin-bottom: 20px;
  animation: fadeUp .55s cubic-bezier(.22,1,.36,1) .2s both;
}
.hero .tagline .sep { color: var(--muted); margin: 0 8px; }
.hero .motto {
  font-family: 'Caveat', cursive;
  font-size: 27px;
  font-weight: 600;
  color: var(--fg);
  margin: 0 0 18px 8px;
  letter-spacing: .01em;
  line-height: 1.2;
  transform: rotate(-1.2deg);
  transform-origin: left center;
  opacity: .92;
  animation: fadeUp .55s cubic-bezier(.22,1,.36,1) .25s both;
}
.hero .motto::before,
.hero .motto::after {
  color: var(--accent);
  font-weight: 700;
}
.hero .motto::before {
  content: "\201C";
  margin-right: 0.3em;
}
.hero .motto::after {
  content: "\201D";
  margin-left: 0.3em;
}
.hero p.bio {
  font-size: 15.5px;
  line-height: 1.75;
  color: var(--fg);
  max-width: 68ch;
  margin: 0 0 12px;
  animation: fadeUp .55s cubic-bezier(.22,1,.36,1) .35s both;
}
.btn-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 28px; animation: fadeUp .55s cubic-bezier(.22,1,.36,1) .55s both; }
.btn {
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: .01em;
  padding: 12px 22px;
  border-radius: 9px;
  cursor: pointer;
  border: none;
  background: var(--card-bg);
  color: var(--muted);
  transition: color .15s ease, background-color .15s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.btn:hover { color: var(--fg); background: var(--border-strong); }
.btn:active { transform: scale(.96); }
.btn.primary {
  background: var(--accent);
  color: var(--accent-fg);
}
.btn.primary:hover {
  filter: brightness(1.06);
  background: var(--accent);
  color: var(--accent-fg);
}
.btn.primary:active { filter: brightness(1); transform: scale(.96); }

.social-row { display: flex; gap: 4px; animation: fadeUp .55s cubic-bezier(.22,1,.36,1) .45s both; margin-bottom: 12px; }
.social-row a {
  width: 40px; height: 40px;
  border: none;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  transition: color .15s ease, background-color .15s ease;
  color: var(--muted);
}
.social-row a:hover { color: var(--fg); background: var(--border-strong); }
.social-row a:active { transform: scale(.92); }
.social-row svg { width: 17px; height: 17px; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- TERMINAL WIDGET ---------- */
.term {
  width: 100%;
  background: var(--code-bg);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--card-shadow);
  border: 1px solid var(--border);
  animation: fadeUp .7s ease .1s both;
  transition: background-color .25s ease, color .25s ease;
  margin-top: 121px;
  margin-bottom: 50px;
}
.term-bar {
  display: flex; gap: 7px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.term-bar span { width: 11px; height: 11px; border-radius: 50%; }
.term-bar span:nth-child(1) { background: #ff5f56; }
.term-bar span:nth-child(2) { background: #ffbd2e; }
.term-bar span:nth-child(3) { background: #27c93f; }
.term-body {
  padding: 20px 20px 26px;
  font-size: 13px;
  line-height: 2;
  color: var(--code-fg);
  min-height: 230px;
}
.term-body .prompt { color: var(--code-accent); }
.term-body .line { white-space: pre-wrap; }
.term-body .muted-line { color: var(--muted); }
.term-caret {
  display: inline-block;
  width: 8px;
  height: 1em;
  background: var(--code-accent);
  vertical-align: text-bottom;
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* ---------- SECTION HEADERS ---------- */
.section-head { padding: 60px 0 8px; }
.section-head .kicker {
  color: var(--accent);
  font-size: 12.5px;
  margin-bottom: 10px;
}
.section-head h2 {
  font-size: 34px;
  letter-spacing: -0.02em;
  margin: 0 0 10px;
  font-weight: 800;
}
.section-head p { color: var(--muted); font-size: 14.5px; margin: 0 0 8px; }

/* ---------- PORTFOLIO GRID ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  padding: 28px 0 100px;
}
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 26px;
  box-shadow: var(--card-shadow);
  transition: box-shadow .18s ease, transform .18s ease;
  display: flex;
  flex-direction: column;
  gap: 12px;
  cursor: pointer;
}
.card:hover {
  box-shadow: 0 2px 4px rgba(20,21,26,0.06), 0 12px 32px rgba(20,21,26,0.08);
  transform: translateY(-3px);
}
.card-cover {
  margin: -26px -26px 4px;
  border-radius: 14px 14px 0 0;
  overflow: hidden;
  aspect-ratio: 16/9;
  background: var(--border);
}
.card-cover img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s ease; }
.card:hover .card-cover img { transform: scale(1.05); }
.card .card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.card h3 { margin: 0; font-size: 18px; letter-spacing: -0.01em; }
.card .arrow {
  color: var(--muted);
  transition: color .15s ease, transform .15s ease;
}
.card:hover .arrow { color: var(--accent); transform: translateX(2px); }
.card p { margin: 0; font-size: 13.5px; line-height: 1.7; color: var(--fg); white-space: pre-line; }
.clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.status-pill {
  align-self: flex-start;
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
  font-weight: 600;
}
.tags { display: flex; gap: 7px; flex-wrap: wrap; margin-top: auto; padding-top: 6px; }
.tag {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  color: var(--muted);
}
.empty-state, .loading-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
  font-size: 14px;
  border: 1px dashed var(--border-strong);
  border-radius: 14px;
}

/* ---------- ABOUT / CV PROSE ---------- */
.prose {
  padding: 8px 0 100px;
  font-size: 15px;
  line-height: 1.9;
  color: var(--fg);
  max-width: 90ch;
}
.prose p { color: var(--fg); margin: 0 0 18px; white-space: pre-line; }
.prose h3 { margin: 34px 0 10px; font-size: 18px; }
.prose strong { color: var(--fg); }
.prose .placeholder { font-style: italic; color: var(--muted); }
.prose blockquote {
  border-left: 3px solid var(--accent);
  margin: 26px 0;
  padding: 4px 0 4px 16px;
  color: var(--muted);
  font-style: italic;
}


/* ---------- PROJECT DETAIL PAGE ---------- */
.project-body {
  max-width: 90ch;
  margin: 0 auto;
}
.project-cover {
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--card-shadow);
  margin: 8px 0 36px;
}
.project-cover img { width: 100%; display: block; }
.project-content { padding-bottom: 0; white-space: pre-line; }
.project-content a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.project-content ul, .project-content ol { color: var(--muted); padding-left: 22px; margin: 0 0 18px; }
.project-content li { margin-bottom: 6px; }
.project-content blockquote {
  border-left: 3px solid var(--accent);
  margin: 0 0 18px;
  padding: 4px 0 4px 16px;
  color: var(--muted);
  font-style: italic;
}
.project-content code {
  background: var(--code-bg);
  color: var(--code-accent);
  padding: 2px 6px;
  border-radius: 5px;
  font-size: 13px;
}
.project-content pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  overflow-x: auto;
  margin: 0 0 18px;
}
.project-content img,
.content-img {
  width: 100%;
  border-radius: 12px;
  margin: 6px 0 18px;
  display: block;
  border: 1px solid var(--border);
}
.project-content hr { border: none; border-top: 1px solid var(--border); margin: 26px 0; }

.cv-download {
  margin: 26px 0 40px;
}

.cv-entry { display: flex; gap: 22px; padding: 16px 0; border-bottom: 1px solid var(--border); }
.cv-entry:last-child { border-bottom: none; }
.cv-date { color: var(--muted); font-size: 12.5px; width: 110px; flex-shrink: 0; padding-top: 2px; }
.cv-content h4 { margin: 0 0 4px; font-size: 15px; }
.cv-content .cv-org { color: var(--accent); font-size: 13px; margin-bottom: 6px; }
.cv-content p { color: var(--fg); font-size: 13.5px; line-height: 1.7; margin: 0; }

.stack-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 0; }
.stack-item {
  font-size: 12.5px;
  border: 1px solid var(--border-strong);
  padding: 5px 11px;
  border-radius: 7px;
  color: var(--muted);
}

/* ---------- FOOTER ---------- */
.footer {
  /* border-top: 1px solid var(--border); */
  padding: 26px 0 26px;
}
.footer .wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 15px;
}

/* ---------- ADMIN & FORMS ---------- */
.admin-panel { padding: 8px 0 100px; }
.admin-box {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--card-shadow);
  padding: 28px;
  max-width: 420px;
  margin: 30px auto;
}
.admin-box.wide { max-width: 100%; margin: 0 0 30px; }
.admin-box h2 { margin-top: 0; font-size: 18px; font-weight: 800; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.field input, .field textarea {
  width: 100%;
  font-family: inherit;
  font-size: 13.5px;
  padding: 11px 13px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
}
.field textarea { resize: vertical; min-height: 70px; overflow-y: hidden; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); }
.field-hint { font-size: 11.5px; color: var(--muted); margin-top: 6px; line-height: 1.6; }
.content-preview-label { font-size: 11.5px; color: var(--muted); margin: 14px 0 8px; }
.content-preview {
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  padding: 16px;
  max-width: 100%;
  min-height: 44px;
  background: var(--bg);
  font-size: 13.5px;
  white-space: pre-line;
}
.content-preview a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.field-label-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.field-label-row label { margin-bottom: 0; }
.html-badge {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  color: var(--accent);
  white-space: nowrap;
}
.content-preview:empty::before { content: "preview will appear here..."; color: var(--muted); font-style: italic; }
.admin-error { color: #c1443b; font-size: 12.5px; margin-top: 10px; }
.row-actions a {
  border: 1px solid var(--border-strong); border-radius: 7px;
  padding: 7px 12px; font-size: 12px; color: var(--muted);
  transition: all .15s ease;
}
.row-actions a:hover { border-color: var(--accent); color: var(--accent); }
.admin-topbar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.admin-topbar h2 { margin: 0; font-size: 22px; }
.project-row {
  display: flex; justify-content: space-between; align-items: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 10px;
  background: var(--card-bg);
  gap: 12px;
  flex-wrap: wrap;
}
.project-row .p-title { font-size: 14px; font-weight: 600; }
.project-row .p-desc { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.row-actions { display: flex; gap: 8px; }
.row-actions button {
  background: transparent; border: 1px solid var(--border-strong); border-radius: 7px;
  padding: 7px 12px; font-size: 12px; cursor: pointer; color: var(--muted);
  font-family: inherit; transition: all .15s ease;
}
.row-actions button:hover { border-color: var(--accent); color: var(--accent); }
.row-actions button.danger:hover { color: #c1443b; border-color: #c1443b; }
.subheading { font-size: 15px; color: var(--muted); margin: 8px 0 14px; }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 1080px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .hero h1 { font-size: 42px; }
  .admin-box.wide { padding: 20px; }

  /* nav-links collapses into the hamburger dropdown */
  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--card-shadow);
    padding: 6px 24px 18px;
  }
  .nav.nav-open .nav-links { display: flex; }
  .nav-links a {
    padding: 14px 2px;
    font-size: 15px;
    color: var(--fg);
    border-bottom: 1px solid var(--border);
  }
  .nav-links a:last-child { border-bottom: none; }
  .nav-links a.active { color: var(--accent); }
  .hamburger { display: flex; }
}

@media (max-width: 600px) {
  .grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .wrap { padding: 0 20px; }
  .hero { margin-top: 10px; padding: 56px 0 44px; gap: 32px; }
  .hero h1 { font-size: 34px; }
  .hero p.bio { font-size: 14.5px; }
  .hero .motto { font-size: 23px; }
  .term { margin-top: 48px; margin-bottom: 32px; }
  .term-body { min-height: 160px; padding: 16px; }
  .section-head { padding: 40px 0 4px; }
  .section-head h2 { font-size: 26px; }
  .card-cover { aspect-ratio: 16/10; }
  .project-row { flex-direction: column; align-items: flex-start; }
  .row-actions { width: 100%; }
  .cv-entry { flex-direction: column; gap: 6px; }
  .cv-date { width: auto; }
  .admin-topbar { flex-direction: column; align-items: flex-start; }
  .field-label-row { flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .wrap { padding: 0 16px; }
  .nav-inner { height: 56px; }
  .nav-right { gap: 6px; }
  .brand { font-size: 13px; }
  .nav-links { padding: 4px 16px 14px; }
  .nav-links a { font-size: 14px; padding: 12px 2px; }
  .hero h1 { font-size: 27px; }
  .hero .tagline { font-size: 13.5px; }
  .hero .motto { font-size: 21px; }
  .status-line { font-size: 11.5px; margin-bottom: 20px; }
  .btn { padding: 10px 15px; font-size: 12.5px; }
  .btn-row { gap: 8px; }
  .social-row a { width: 34px; height: 34px; }
  .social-row svg { width: 15px; height: 15px; }
  .admin-box { padding: 18px; margin: 18px auto; }
  /* 16px prevents iOS Safari from auto-zooming in on focus */
  .field input, .field textarea { font-size: 16px; padding: 10px 12px; }
  .field-hint { font-size: 11px; }
  .footer .wrap { font-size: 13px; flex-direction: column; gap: 6px; }
  .status-pill { font-size: 10.5px; }
  .card { padding: 18px; }
  .card-cover { margin: -18px -18px 4px; }
}