/* ── Reset ────────────────────────────────────────────────── */

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

/* ── Tokens ───────────────────────────────────────────────── */

:root {
  --bg:         #0c1018;
  --bg-raised:  #111826;
  --card:       #141e2c;
  --card-hover: #172230;
  --border:     rgba(80, 150, 190, 0.09);
  --border-hi:  rgba(110, 175, 210, 0.24);
  --text:       #d4e6f0;
  --text-2:     #6a97b0;
  --text-3:     #344e62;
  --accent:     #7abfd4;
  --tint:       rgba(122, 191, 212, 0.05);
  --code-bg:    #090d13;
  --shadow-sm:  0 1px 4px rgba(0,0,0,0.35);
  --shadow-md:  0 4px 20px rgba(0,0,0,0.50);
  --shadow-lg:  0 10px 40px rgba(0,0,0,0.55);
  --t:          200ms ease;

  --serif:   'Cormorant Garamond', Georgia, serif;
  --body:    'Lora', Georgia, serif;
  --sans:    'DM Sans', system-ui, sans-serif;
  --mono:    ui-monospace, 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
}

[data-theme="light"] {
  --bg:         #f2f6f9;
  --bg-raised:  #e5eef4;
  --card:       #ffffff;
  --card-hover: #f8fbfd;
  --border:     rgba(0, 90, 130, 0.08);
  --border-hi:  rgba(0, 100, 150, 0.20);
  --text:       #0d1c28;
  --text-2:     #2a5878;
  --text-3:     #6a90a8;
  --accent:     #1a6a8a;
  --tint:       rgba(26, 106, 138, 0.05);
  --code-bg:    #eef4f8;
  --shadow-sm:  0 1px 4px rgba(0,40,80,0.07);
  --shadow-md:  0 4px 20px rgba(0,40,80,0.09);
  --shadow-lg:  0 10px 40px rgba(0,40,80,0.10);
}

/* ── Base ─────────────────────────────────────────────────── */

html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  background: var(--bg);
  background-image: linear-gradient(to bottom, var(--bg) 0%, var(--bg-raised) 100%);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  transition: background var(--t), color var(--t);
}

/* very subtle depth gradient — light from above */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse 75% 45% at 50% -5%, rgba(60, 120, 180, 0.06) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ── Particles ────────────────────────────────────────────── */

#particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.5;
}

/* ── Z-stack ──────────────────────────────────────────────── */

body > header, main, footer { position: relative; z-index: 1; }
body > header { z-index: 10; }

/* ── Header ───────────────────────────────────────────────── */

body > header {
  position: sticky;
  top: 0;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: rgba(12, 16, 24, 0.82);
  border-bottom: 1px solid var(--border);
  transition: background var(--t), border-color var(--t);
}

[data-theme="light"] body > header {
  background: rgba(242, 246, 249, 0.88);
}

.nav-container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 2rem;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ── Logo ─────────────────────────────────────────────────── */

.site-logo {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--accent);
}

.logo-mark {
  flex-shrink: 0;
  color: var(--accent);
  display: block;
}

.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.logo-title {
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text);
}


/* ── Nav right cluster ────────────────────────────────────── */

.nav-right {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.nav-link {
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--text-3);
  text-decoration: none;
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  transition: color var(--t);
}

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

/* ── Theme toggle ─────────────────────────────────────────── */

.theme-toggle {
  background: none;
  border: none;
  padding: 0.3rem;
  cursor: pointer;
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color var(--t);
}

.theme-toggle:hover { color: var(--accent); }

/* show sun in dark mode, moon in light mode */
[data-theme="dark"]  .icon-moon { display: none; }
[data-theme="light"] .icon-sun  { display: none; }

/* ── Main ─────────────────────────────────────────────────── */

main { min-height: calc(100vh - 68px - 52px); }

/* ── Page transition ──────────────────────────────────────── */

.page-in { animation: fadeUp 0.28s ease forwards; }

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

/* ── Home ─────────────────────────────────────────────────── */

.home {
  max-width: 1120px;
  margin: 0 auto;
  padding: 5rem 2rem 7rem;
}

.hero {
  text-align: center;
  margin-bottom: 5rem;
}

.hero h1 {
  font-family: var(--serif);
  font-size: clamp(2.6rem, 6vw, 4.5rem);
  font-weight: 300;
  letter-spacing: 0.01em;
  line-height: 1.05;
  color: var(--text);
  margin-bottom: 1rem;
}

.hero-sub {
  font-family: var(--sans);
  font-size: 0.875rem;
  font-weight: 400;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* ── Grid ─────────────────────────────────────────────────── */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 1.75rem;
}

/* ── Card ─────────────────────────────────────────────────── */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: transform var(--t), border-color var(--t), box-shadow var(--t);
  outline: none;
}

.card:hover,
.card:focus-visible {
  transform: translateY(-3px);
  border-color: var(--border-hi);
  box-shadow: var(--shadow-lg);
}

.card-img {
  aspect-ratio: 16 / 9;
  overflow: hidden;
  position: relative;
}

.card-img img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 500ms ease;
}

.card:hover .card-img img,
.card:focus-visible .card-img img {
  transform: scale(1.04);
}

/* placeholder — sonar rings as background, initial letter */
.card-placeholder {
  width: 100%; height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 50% 50%,
      transparent 16%,
      rgba(122, 191, 212, 0.04) 17%, transparent 24%,
      rgba(122, 191, 212, 0.03) 25%, transparent 34%,
      rgba(122, 191, 212, 0.02) 35%, transparent 46%
    ),
    linear-gradient(160deg, #0c1825 0%, #0f1f30 60%, #0a1420 100%);
}

[data-theme="light"] .card-placeholder {
  background:
    radial-gradient(circle at 50% 50%,
      transparent 16%,
      rgba(26, 106, 138, 0.05) 17%, transparent 24%,
      rgba(26, 106, 138, 0.04) 25%, transparent 34%,
      rgba(26, 106, 138, 0.02) 35%, transparent 46%
    ),
    linear-gradient(160deg, #daeaf4 0%, #c8dded 60%, #d4e8f0 100%);
}

.card-placeholder::after {
  content: attr(data-letter);
  font-family: var(--serif);
  font-size: 5rem;
  font-weight: 300;
  color: var(--accent);
  opacity: 0.12;
  user-select: none;
}

.card-body {
  padding: 1.4rem 1.5rem 1.6rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.card-date {
  font-family: var(--sans);
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
}

.card-title {
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: 500;
  line-height: 1.25;
  color: var(--text);
  letter-spacing: 0.01em;
}

.card-desc {
  font-family: var(--sans);
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--text-2);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: auto;
  padding-top: 0.25rem;
}

/* ── Article page ─────────────────────────────────────────── */

.article {
  max-width: 720px;
  margin: 0 auto;
  padding: 3.5rem 2rem 8rem;
}

.article-nav { margin-bottom: 3rem; }

.btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--text-3);
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: color var(--t);
}

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

.article-cover {
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 3rem;
  border: 1px solid var(--border);
}

.article-cover img {
  width: 100%;
  height: 400px;
  object-fit: cover;
  display: block;
}

.article-head {
  margin-bottom: 3.5rem;
  padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--border);
}

.article-date {
  display: block;
  font-family: var(--sans);
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 1.1rem;
}

.article-head h1 {
  font-family: var(--serif);
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 400;
  letter-spacing: 0.01em;
  line-height: 1.12;
  margin-bottom: 1.25rem;
  color: var(--text);
}

.article-lead {
  font-family: var(--body);
  font-size: 1.1rem;
  font-style: italic;
  font-weight: 400;
  color: var(--text-2);
  line-height: 1.7;
}

/* ── Article body ─────────────────────────────────────────── */

.article-body {
  font-family: var(--body);
  font-size: 1.05rem;
  line-height: 1.85;
  color: var(--text);
}

.article-body h1,
.article-body h2,
.article-body h3,
.article-body h4 {
  font-family: var(--serif);
  color: var(--text);
  line-height: 1.25;
  margin: 3rem 0 1.1rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.article-body h1 { font-size: 2.1rem; font-weight: 400; }

.article-body h2 {
  font-size: 1.65rem;
  font-weight: 400;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}

.article-body h3 { font-size: 1.3rem; }

.article-body h4 {
  font-family: var(--sans);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
  margin: 2.5rem 0 0.75rem;
}

.article-body p { margin-bottom: 1.6rem; }

.article-body a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 3px;
  transition: text-decoration-color var(--t);
}

.article-body a:hover { text-decoration-color: var(--accent); }

.article-body strong {
  font-weight: 600;
  color: var(--text);
}

.article-body em { font-style: italic; }

.article-body ul,
.article-body ol {
  margin: 0.5rem 0 1.6rem 1.5rem;
}

.article-body li { margin-bottom: 0.5rem; }

.article-body li > ul,
.article-body li > ol { margin-top: 0.35rem; margin-bottom: 0.35rem; }

.article-body blockquote {
  border-left: 2px solid var(--accent);
  margin: 2.5rem 0;
  padding: 0.75rem 1.75rem;
  color: var(--text-2);
  font-style: italic;
  background: var(--tint);
  border-radius: 0 4px 4px 0;
}

.article-body blockquote p { margin-bottom: 0; }

/* inline code */
.article-body :not(pre) > code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--code-bg);
  color: var(--accent);
  padding: 0.13em 0.4em;
  border-radius: 3px;
  border: 1px solid var(--border);
}

/* code blocks */
.article-body pre {
  margin: 2.2rem 0;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

.article-body pre code {
  font-family: var(--mono);
  font-size: 0.855rem;
  line-height: 1.65;
  padding: 1.4rem 1.6rem;
  display: block;
  overflow-x: auto;
}

/* media */
.article-body img {
  max-width: 100%;
  border-radius: 6px;
  margin: 2rem 0 0.6rem;
  border: 1px solid var(--border);
  display: block;
}

/* italic immediately after an image = caption */
.article-body img + em,
.article-body img + p > em:only-child {
  display: block;
  font-family: var(--sans);
  font-style: normal;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  color: var(--text-3);
  text-align: center;
  margin-bottom: 2rem;
}

.article-body video,
.article-body iframe {
  max-width: 100%;
  border-radius: 6px;
  margin: 2rem 0;
  border: 1px solid var(--border);
  display: block;
}

.article-body iframe {
  width: 100%;
  aspect-ratio: 16 / 9;
}

/* tables */
.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 2.5rem 0;
  font-family: var(--sans);
  font-size: 0.88rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.article-body th {
  background: var(--bg-raised);
  color: var(--text-3);
  font-weight: 500;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.85rem 1.1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-hi);
}

.article-body td {
  padding: 0.8rem 1.1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  vertical-align: top;
}

.article-body tr:last-child td { border-bottom: none; }

.article-body hr {
  border: none;
  margin: 3.5rem auto;
  width: 48px;
  height: 1px;
  background: var(--border-hi);
}

/* paragraph that contains only an italic = figure caption */
.article-body p:has(> em:only-child) {
  font-family: var(--sans);
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  color: var(--text-3);
  text-align: center;
  margin-top: -1.2rem;
  margin-bottom: 2rem;
}

.article-body p:has(> em:only-child) em {
  font-style: normal;
}

/* ── About page ──────────────────────────────────────────── */

.about {
  max-width: 720px;
  margin: 0 auto;
  padding: 5rem 2rem 8rem;
}

.about-head {
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.about-head h1 {
  font-family: var(--serif);
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 400;
  letter-spacing: 0.01em;
  color: var(--text);
}

.about-body {
  font-family: var(--body);
  font-size: 1.05rem;
  line-height: 1.85;
  color: var(--text);
}

.about-body p { margin-bottom: 1.6rem; }

.about-body h2 {
  font-family: var(--serif);
  font-size: 1.45rem;
  font-weight: 400;
  color: var(--text);
  margin: 2.5rem 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
}

@media (max-width: 640px) {
  .about { padding: 3rem 1.25rem 5rem; }
}

/* ── Contact form ─────────────────────────────────────────── */

.contact-form {
  margin-top: 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.field label {
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-3);
}

.field input,
.field textarea {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-family: var(--body);
  font-size: 1rem;
  line-height: 1.6;
  padding: 0.7rem 0.9rem;
  width: 100%;
  transition: border-color var(--t), background var(--t);
  resize: vertical;
}

.field input::placeholder,
.field textarea::placeholder {
  color: var(--text-3);
}

.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--card);
}

.contact-submit {
  align-self: flex-start;
  background: none;
  border: 1px solid var(--border-hi);
  border-radius: 4px;
  color: var(--text-2);
  cursor: pointer;
  font-family: var(--sans);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  padding: 0.55rem 1.4rem;
  transition: border-color var(--t), color var(--t), background var(--t);
}

.contact-submit:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--tint);
}

.contact-confirm {
  font-family: var(--body);
  font-size: 1rem;
  color: var(--text-2);
  margin-top: 2.5rem;
  padding: 1.25rem 1.5rem;
  border: 1px solid var(--border);
  border-left: 2px solid var(--accent);
  border-radius: 0 4px 4px 0;
  background: var(--tint);
}

.contact-error {
  font-family: var(--sans);
  font-size: 0.85rem;
  color: #b06070;
  margin: 0;
}

/* ── Status / Loading ─────────────────────────────────────── */

.status {
  text-align: center;
  padding: 6rem 2rem;
  color: var(--text-3);
  font-family: var(--sans);
  font-size: 0.8rem;
  letter-spacing: 0.10em;
  text-transform: uppercase;
}

.status.error { color: #b06070; }

/* ── Footer ───────────────────────────────────────────────── */

footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem;
  text-align: center;
  font-family: var(--sans);
  font-size: 0.68rem;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* ── Scrollbar ────────────────────────────────────────────── */

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 2px; }

/* ── Selection ────────────────────────────────────────────── */

::selection { background: rgba(122, 191, 212, 0.15); color: var(--text); }

/* ── hljs override ────────────────────────────────────────── */

.hljs { padding: 1.4rem 1.6rem !important; background: var(--code-bg) !important; }

/* ── Responsive ───────────────────────────────────────────── */

@media (max-width: 640px) {
  .home { padding: 3rem 1.25rem 5rem; }
  .hero { margin-bottom: 3rem; }
  .grid { grid-template-columns: 1fr; gap: 1.25rem; }
  .article { padding: 2.5rem 1.25rem 5rem; }
  .article-cover img { height: 220px; }
  .nav-container { padding: 0 1.25rem; }

  .article-head h1 { font-size: 1.9rem; }
}

@media (max-width: 900px) and (min-width: 641px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
}
