﻿/* ============ Design tokens ============ */
:root {
  --bg: #ffffff;
  --bg-alt: #f6f7f9;
  --surface: #ffffff;
  --text: #1a1d21;
  --muted: #5c6470;
  --border: #e4e7eb;
  --accent: #d4a017;
  --accent-strong: #b8860b;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(0, 0, 0, 0.05);
  --radius: 14px;
  --font: "Playfair Display", Georgia, "Times New Roman", serif;
  --font-serif: "Playfair Display", Georgia, "Times New Roman", serif;
  --content-width: 1080px;
}

@font-face {
  font-family: "Playfair Display";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/playfair-display-v40-latin-700.woff2") format("woff2");
}

@font-face {
  font-family: "Playfair Display";
  font-style: normal;
  font-weight: 900;
  font-display: swap;
  src: url("../fonts/playfair-display-v40-latin-900.woff2") format("woff2");
}

@font-face {
  font-family: "Playfair Display";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/playfair-display-v40-latin-regular.woff2") format("woff2");
}

@font-face {
  font-family: "Playfair Display";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/playfair-display-v40-latin-600.woff2") format("woff2");
}

@font-face {
  font-family: "Playfair Display";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/playfair-display-v40-latin-italic.woff2") format("woff2");
}

[data-theme="dark"] {
  --bg: #0f1115;
  --bg-alt: #161a20;
  --surface: #1a1f26;
  --text: #e8eaed;
  --muted: #9aa3ad;
  --border: #2a3038;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.3);
}

/* ============ Base ============ */
* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  transition: background 0.25s ease, color 0.25s ease;
}

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

a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* ============ Header & nav ============ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.nav-wrap {
  display: flex;
  align-items: center;
  gap: 24px;
  height: 64px;
}

.brand {
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: 0.06em;
  color: var(--text);
}
.brand:hover { text-decoration: none; opacity: 0.85; }

.site-nav {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.site-nav a {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.95rem;
  padding: 8px 14px;
  border-radius: 999px;
}
.site-nav a:hover { color: var(--text); text-decoration: none; background: var(--bg-alt); }
.site-nav a.active { color: var(--text); background: var(--bg-alt); }

.theme-toggle, .nav-toggle {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  width: 40px;
  height: 40px;
  font-size: 1.05rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.15s ease;
}
.theme-toggle:hover, .nav-toggle:hover { transform: scale(1.06); }

.nav-toggle { display: none; }

/* ============ Hero & page heroes ============ */
.hero {
  padding: 96px 0 72px;
  text-align: center;
  background:
    radial-gradient(600px 260px at 20% 0%, color-mix(in srgb, var(--accent) 14%, transparent), transparent),
    radial-gradient(600px 260px at 80% 10%, color-mix(in srgb, var(--accent) 10%, transparent), transparent),
    var(--bg);
}

.hero-kicker {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-strong);
  margin-bottom: 12px;
}

.hero h1 { font-family: var(--font-serif); font-weight: 700; font-size: clamp(2.6rem, 7vw, 4.2rem); line-height: 1.15; letter-spacing: -0.01em; }
.hero-tagline {
  max-width: 560px;
  margin: 16px auto 32px;
  font-size: 1.2rem;
  color: var(--muted);
}

.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.page-hero {
  padding: 72px 0 40px;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
}
.page-hero h1 { font-size: clamp(2rem, 5vw, 3rem); letter-spacing: -0.02em; }
.page-hero .lead { max-width: 620px; margin-top: 8px; color: var(--muted); }

/* ============ Buttons ============ */
.btn {
  display: inline-block;
  padding: 12px 24px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.95rem;
  border: 1px solid transparent;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }

.btn-primary { background: var(--accent); color: #1a1d21; box-shadow: var(--shadow); }
.btn-primary:hover { box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 40%, transparent); }

.btn-outline { border-color: var(--border); color: var(--text); background: var(--surface); }
.btn-outline:hover { border-color: var(--muted); }

/* ============ Sections & cards ============ */
.section { padding: 64px 0; }
.section-alt { background: var(--bg-alt); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}
.section-head h2 { font-size: 1.6rem; letter-spacing: -0.01em; }

.lead { font-size: 1.1rem; color: var(--muted); max-width: 680px; }
.muted { color: var(--muted); }

.text-link { font-weight: 600; }
.text-link:hover { text-decoration: underline; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08); }
.card h3 { font-size: 1.15rem; margin-bottom: 6px; }
.card h3 a { color: var(--text); }
.card h3 a:hover { text-decoration: none; color: var(--accent-strong); }
.card p { color: var(--muted); font-size: 0.95rem; }

.card-meta {
  font-size: 0.82rem !important;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted) !important;
  margin-bottom: 8px;
}

/* ============ Profile page ============ */
.profile-grid {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 40px;
  align-items: start;
}

.profile-card {
  position: sticky;
  top: 88px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  text-align: center;
}

.avatar {
  width: 96px;
  height: 96px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #1a1d21;
  font-size: 2rem;
  font-weight: 800;
  display: grid;
  place-items: center;
}

.profile-card h2 { font-size: 1.35rem; }
.profile-card hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.profile-card h3 { font-size: 0.95rem; margin-bottom: 10px; text-align: left; }

.link-list { list-style: none; text-align: left; }
.link-list li { padding: 4px 0; font-size: 0.95rem; }

.profile-main h2 { font-size: 1.5rem; margin: 36px 0 14px; letter-spacing: -0.01em; }
.profile-main h2:first-child { margin-top: 0; }
.profile-main p { color: var(--muted); margin-bottom: 12px; }
.profile-main .card p { margin-bottom: 0; }

.timeline { list-style: none; border-left: 2px solid var(--border); padding-left: 24px; }
.timeline li { position: relative; margin-bottom: 28px; }
.timeline li::before {
  content: "";
  position: absolute;
  left: -31px;
  top: 6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
}

/* ============ Blog listing ============ */
.post-list { display: flex; flex-direction: column; gap: 20px; max-width: 760px; }
.post-list .card h2 { font-size: 1.35rem; margin-bottom: 6px; }
.post-list .card h2 a { color: var(--text); }
.post-list .card h2 a:hover { color: var(--accent-strong); text-decoration: none; }
.post-list .card p { margin-bottom: 12px; }
.post-list code { background: var(--bg-alt); padding: 2px 6px; border-radius: 6px; font-size: 0.9em; }

/* ============ Post page ============ */
.post { padding: 56px 0 80px; }
.post-container { max-width: 720px; }
.post-header { margin-bottom: 32px; }
.post-header h1 { font-size: clamp(1.9rem, 4.5vw, 2.6rem); letter-spacing: -0.02em; line-height: 1.2; }
.post h2 { font-size: 1.4rem; margin: 36px 0 12px; }
.post p { margin-bottom: 16px; color: var(--muted); }
.post a { font-weight: 600; }
.post ol, .post ul { margin: 0 0 16px 24px; color: var(--muted); }
.post li { margin-bottom: 6px; }
.post blockquote {
  border-left: 4px solid var(--accent);
  background: var(--bg-alt);
  padding: 16px 20px;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 24px 0;
  font-style: italic;
  color: var(--text);
}
.post pre {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  overflow-x: auto;
  margin: 16px 0 24px;
}
.post code { font-family: "Cascadia Code", Consolas, monospace; font-size: 0.92em; }
.post p code, .post li code { background: var(--bg-alt); padding: 2px 6px; border-radius: 6px; }
.post hr { border: none; border-top: 1px solid var(--border); margin: 40px 0; }

/* ============ Footer ============ */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 32px 0;
  color: var(--muted);
  font-size: 0.92rem;
}
.site-footer .container { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.footer-links a { color: var(--muted); }
.footer-links a:hover { color: var(--text); }

/* ============ Responsive ============ */
@media (max-width: 860px) {
  .profile-grid { grid-template-columns: 1fr; }
  .profile-card { position: static; }

  .nav-toggle { display: grid; margin-left: auto; }

  .site-nav {
    position: absolute;
    top: 64px;
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 12px 24px 20px;
    gap: 4px;
    display: none;
  }
  .site-nav.open { display: flex; }
  .site-nav a { border-radius: 10px; }

  .nav-wrap { flex-wrap: wrap; }
  .theme-toggle { order: -1; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}

/* ============ Admin entrance (homepage) ============ */
.admin-entry {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.admin-entry:hover {
  color: var(--text);
  border-color: var(--muted);
}

.admin-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.45);
  padding: 24px;
}

.admin-modal[hidden] {
  display: none;
}

.admin-modal-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  position: relative;
  text-align: center;
}

.admin-modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.admin-modal-close:hover {
  color: var(--text);
}

.admin-modal-card h2 {
  font-size: 1.5rem;
  margin-bottom: 4px;
}

.admin-modal-card .muted {
  margin-bottom: 16px;
}

.admin-modal form {
  text-align: left;
}

.admin-modal-field {
  display: block;
  margin-bottom: 12px;
  font-weight: 700;
  font-size: 0.92rem;
}

.admin-modal-field input {
  width: 100%;
  margin-top: 6px;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

.admin-modal-field input:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.admin-modal .btn {
  width: 100%;
  margin-top: 4px;
}

.admin-modal-error {
  color: #b3261e;
  min-height: 1.2em;
  font-weight: 600;
  margin-top: 10px;
  text-align: center;
}
