/* ── Custom properties ── */
:root {
  --bg: #ffffff;
  --text: #111111;
  --accent: #1a3a6e;
  --accent-hover: #24508a;
  --muted: #5a5a5a;
  --rule: #e0e0e0;
  --mono-bg: #f4f4f2;
  --header-bg: #ffffff;
}

html.dark {
  --bg: #0d0d0d;
  --text: #f0f0ee;
  --accent: #4a6fa5;
  --accent-hover: #5b82bc;
  --muted: #888;
  --rule: #2a2a2a;
  --mono-bg: #1a1a1a;
  --header-bg: #0d0d0d;
}

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

/* ── Base ── */
html {
  transition: background 0.2s, color 0.2s;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
  transition: background 0.2s, color 0.2s;
}

/* ── Header ── */
header {
  position: sticky;
  top: 0;
  background: var(--header-bg);
  border-bottom: 1px solid var(--rule);
  z-index: 100;
  padding: 0 2rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 0.2s, border-color 0.2s;
}

.site-name {
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}

nav {
  display: flex;
  align-items: center;
  gap: 1.75rem;
}

nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.775rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: color 0.15s;
  white-space: nowrap;
}

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

/* ── Dark mode toggle ── */
#dark-toggle {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 0.95rem;
  padding: 0.2rem 0.3rem;
  line-height: 1;
  transition: color 0.15s;
  flex-shrink: 0;
}

#dark-toggle:hover {
  color: var(--text);
}

/* ── Main ── */
main {
  min-height: calc(100vh - 56px - 52px);
}

/* ── Home: Identity block ── */
.home-identity {
  max-width: 760px;
  margin: 0 auto;
  padding: 4rem 2rem 3rem;
  border-bottom: 1px solid var(--rule);
}

.home-identity h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 0.3rem;
}

.home-title {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--muted);
  margin-bottom: 1.4rem;
  letter-spacing: 0.01em;
}

.home-statement {
  font-size: 1rem;
  line-height: 1.75;
  color: var(--text);
  max-width: 560px;
}

/* ── Home: Featured project ── */
.featured-project {
  max-width: 760px;
  margin: 0 auto;
  padding: 2.5rem 2rem;
  border-bottom: 1px solid var(--rule);
}

.section-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 1.5rem;
}

.featured-card {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

.featured-number {
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  font-size: 0.75rem;
  color: var(--muted);
  padding-top: 0.25rem;
  flex-shrink: 0;
  min-width: 20px;
}

.featured-body h2 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.3;
  margin-bottom: 0.4rem;
}

.featured-meta {
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  font-size: 0.7rem;
  color: var(--muted);
  margin-bottom: 0.9rem;
  letter-spacing: -0.01em;
}

.featured-body > p:not(.featured-meta) {
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--muted);
  margin-bottom: 1.1rem;
  max-width: 520px;
}

.arrow-link {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: 0.01em;
}

.arrow-link:hover {
  text-decoration: underline;
}

/* ── Home: Secondary projects ── */
.secondary-projects {
  max-width: 760px;
  margin: 0 auto;
  padding: 2.5rem 2rem 5rem;
}

.secondary-item {
  border-top: 1px solid var(--rule);
  padding-top: 1rem;
}

.secondary-number {
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  font-size: 0.7rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

.secondary-item h3 {
  font-size: 0.925rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-bottom: 0.3rem;
  line-height: 1.35;
}

.secondary-meta {
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  font-size: 0.68rem;
  color: var(--muted);
}

/* ── Research page intro ── */
.research-intro {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
  line-height: 1.65;
}

/* ── Case studies (Work page) ── */
.case-study {
  padding: 3rem 0;
  border-bottom: 1px solid var(--rule);
}

.case-study:last-child {
  border-bottom: none;
  padding-bottom: 1rem;
}

.case-study-header {
  display: flex;
  align-items: baseline;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.case-number {
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  font-size: 0.75rem;
  color: var(--muted);
  flex-shrink: 0;
  min-width: 20px;
}

.case-study h2 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.3;
  margin-bottom: 0.35rem;
}

.case-meta {
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  font-size: 0.7rem;
  color: var(--muted);
  letter-spacing: -0.01em;
}

.case-section-label {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  margin-top: 1.5rem;
  margin-bottom: 0.65rem;
  display: block;
}

.case-study > p:not(.case-section-label) {
  font-size: 0.9rem;
  line-height: 1.75;
  color: var(--text);
  margin-bottom: 0.25rem;
  max-width: 640px;
}

.case-study ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.case-study li {
  font-size: 0.9rem;
  line-height: 1.65;
  padding: 0.2rem 0 0.2rem 1.25rem;
  position: relative;
  color: var(--text);
  max-width: 640px;
}

.case-study li::before {
  content: '\2014';
  position: absolute;
  left: 0;
  color: var(--muted);
}

/* ── Page content (About, Contact) ── */
.page-content {
  max-width: 760px;
  margin: 0 auto;
  padding: 3rem 2rem 5rem;
}

.page-content > h1 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 2rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--rule);
}

.page-content h2 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
}

.page-content p {
  font-size: 0.925rem;
  margin-bottom: 1.1rem;
  line-height: 1.8;
  max-width: 600px;
}

.page-content hr {
  border: none;
  border-top: 1px solid var(--rule);
  margin: 2.5rem 0;
}

.page-content ul,
.page-content ol {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}

.page-content li {
  font-size: 0.925rem;
  margin-bottom: 0.4rem;
  line-height: 1.65;
}

.page-content a {
  color: var(--accent);
  text-decoration: none;
}

.page-content a:hover {
  text-decoration: underline;
}

/* ── Contact ── */
.contact-list {
  list-style: none;
  padding: 0;
  margin-top: 0.5rem;
}

.contact-list li {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--rule);
  font-size: 0.9rem;
  transition: border-color 0.2s;
}

.contact-list li:last-child {
  border-bottom: none;
}

.contact-label {
  font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  min-width: 80px;
  flex-shrink: 0;
}

.contact-list a {
  color: var(--accent);
  text-decoration: none;
}

.contact-list a:hover {
  text-decoration: underline;
}

/* ── Footer ── */
footer {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-top: 1px solid var(--rule);
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.02em;
  transition: border-color 0.2s;
}

/* ── Mobile ── */
@media (max-width: 640px) {
  header {
    padding: 0 1.25rem;
  }

  nav {
    gap: 1.25rem;
  }

  .home-identity,
  .featured-project,
  .secondary-projects {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
  }

  .home-identity {
    padding-top: 2.5rem;
    padding-bottom: 2rem;
  }

  .featured-project,
  .secondary-projects {
    padding-top: 2rem;
  }

  .secondary-projects {
    padding-bottom: 3.5rem;
  }

  .page-content {
    padding: 2rem 1.25rem 3.5rem;
  }
}

@media (max-width: 480px) {
  .featured-card {
    flex-direction: column;
    gap: 0.75rem;
  }

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