@import url('https://fonts.googleapis.com/css2?family=EB+Garamond:ital,wght@0,400;0,500;0,600;1,400&family=Inter:wght@400;500;600&display=swap');

:root {
  --bg: #faf9f7;
  --surface: #ffffff;
  --text: #2c2c2c;
  --text-muted: #6b6b6b;
  --accent: #e85d26;
  --accent-hover: #d04f1c;
  --accent-soft: rgba(232, 93, 38, 0.12);
  --border: #e5e2dd;
  --code-bg: #f0eeeb;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 6px 18px rgba(0,0,0,0.08);
  --measure: 700px;
}

[data-theme="dark"] {
  --bg: #171717;
  --surface: #222222;
  --text: #e8e6e3;
  --text-muted: #9c9c9c;
  --accent: #f0824d;
  --accent-hover: #f59464;
  --accent-soft: rgba(240, 130, 77, 0.16);
  --border: #353535;
  --code-bg: #2c2c2c;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-lg: 0 6px 18px rgba(0,0,0,0.4);
}

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

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-size: 17px;
  transition: background 0.3s, color 0.3s;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s;
}

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

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

/* ---- navigation ---- */

nav {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 1.25rem 1.25rem 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

nav .brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--text);
  min-width: 0;
}

nav .brand:hover .logo-text {
  color: var(--accent);
}

.logo-icon {
  height: 2.4rem;
  width: auto;
  max-width: 3.8rem;
  object-fit: contain;
  display: block;
  flex: none;
}

nav .logo-text {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 1.55rem;
  font-weight: 600;
  font-style: italic;
  letter-spacing: -0.02em;
  line-height: 1;
  transition: color 0.2s;
  white-space: nowrap;
}

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

nav .nav-link {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-weight: 500;
  padding: 0.25rem 0;
  border-bottom: 1.5px solid transparent;
}

nav .nav-link:hover,
nav .nav-link.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 2.1rem;
  height: 2.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  color: var(--text);
  transition: all 0.2s;
}

.theme-toggle:hover {
  border-color: var(--accent);
  background: var(--code-bg);
}

/* ---- layout ---- */

main {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 2.5rem 1.25rem 5rem;
}

.hero {
  margin-bottom: 2.5rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}

.hero h1 {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 2.9rem;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.025em;
  margin-bottom: 0.75rem;
}

.hero p {
  color: var(--text-muted);
  font-size: 1.05rem;
  max-width: 540px;
}

.hero-home {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}

.hero-home .hero-text {
  flex: 1 1 auto;
  min-width: 0;
}

.hero-art {
  flex: 0 0 auto;
  width: clamp(200px, 40%, 300px);
  height: auto;
  object-fit: contain;
  display: block;
}

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

/* ---- post cards ---- */

.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem 1.6rem;
  margin-bottom: 1rem;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
  box-shadow: var(--shadow);
  display: block;
  color: var(--text);
}

.post-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent);
  color: var(--text);
}

.post-card .post-date {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.45rem;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.post-card .post-title {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 1.45rem;
  font-weight: 600;
  margin-bottom: 0.45rem;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.post-card .post-excerpt {
  color: var(--text-muted);
  font-size: 0.93rem;
  line-height: 1.6;
}

.post-card .post-tag {
  display: inline-block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--code-bg);
  color: var(--text-muted);
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  margin: 0.8rem 0.3rem 0 0;
  font-weight: 600;
}

/* ---- article ---- */

article {
  animation: fadeIn 0.4s ease;
}

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

article .post-header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

article .post-header h1 {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 2.5rem;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
  text-wrap: balance;
}

article .post-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

article .post-meta .dot {
  opacity: 0.4;
}

article h2 {
  font-family: 'EB Garamond', Georgia, serif;
  font-size: 1.85rem;
  font-weight: 600;
  margin-top: 3rem;
  margin-bottom: 0.9rem;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

article h3 {
  font-weight: 600;
  font-size: 1.12rem;
  margin-top: 2.25rem;
  margin-bottom: 0.6rem;
  line-height: 1.3;
}

article p {
  margin-bottom: 1.3rem;
}

article p a,
article li a {
  text-decoration: underline;
  text-decoration-color: var(--accent-soft);
  text-underline-offset: 3px;
}

article p a:hover,
article li a:hover {
  text-decoration-color: var(--accent);
}

article strong {
  font-weight: 600;
}

article code {
  background: var(--code-bg);
  padding: 0.12rem 0.38rem;
  border-radius: 4px;
  font-size: 0.86em;
  font-family: 'SF Mono', 'Fira Code', ui-monospace, Menlo, monospace;
  overflow-wrap: anywhere;
}

article pre {
  background: var(--code-bg);
  padding: 1.1rem 1.25rem;
  border-radius: 10px;
  overflow-x: auto;
  margin-bottom: 1.3rem;
  font-size: 0.84em;
  line-height: 1.6;
  border: 1px solid var(--border);
}

article pre code {
  background: none;
  padding: 0;
  overflow-wrap: normal;
}

article ul, article ol {
  margin-bottom: 1.3rem;
  padding-left: 1.4rem;
}

article li {
  margin-bottom: 0.5rem;
}

article li::marker {
  color: var(--text-muted);
}

article blockquote {
  border-left: 3px solid var(--accent);
  padding: 0.25rem 0 0.25rem 1.1rem;
  margin: 1.5rem 0;
  color: var(--text-muted);
  font-style: italic;
}

article hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.75rem 0;
}

/* tables: site.js wraps each one in .table-wrap so wide ones scroll */
.table-wrap {
  overflow-x: auto;
  margin-bottom: 1.3rem;
  -webkit-overflow-scrolling: touch;
}

article table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9em;
  min-width: 480px;
}

article table th {
  text-align: left;
  font-weight: 600;
  padding: 0.6rem 0.75rem;
  border-bottom: 2px solid var(--border);
  font-size: 0.78em;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

article table td {
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

article table td code {
  white-space: nowrap;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
  font-weight: 500;
}

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

/* ---- figures & inline SVG diagrams ---- */

article figure {
  margin: 1.75rem 0;
}

article figure .diagram-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  padding: 0.75rem;
}

article figure .diagram {
  width: 100%;
  min-width: 560px;
  height: auto;
  display: block;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

article figcaption {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.7rem;
  text-align: center;
  line-height: 1.5;
  padding: 0 0.5rem;
}

.d-box { fill: var(--surface); stroke: var(--border); stroke-width: 1.2; }
.d-box-soft { fill: var(--code-bg); stroke: var(--border); stroke-width: 1.2; }
.d-box-accent { fill: var(--accent); stroke: none; }
.d-box-outline { fill: none; stroke: var(--accent); stroke-width: 1.4; }
.d-text { fill: var(--text); font-size: 12px; }
.d-text-b { fill: var(--text); font-size: 12px; font-weight: 600; }
.d-text-sm { fill: var(--text-muted); font-size: 10.5px; }
.d-text-inv { fill: #ffffff; font-size: 12px; font-weight: 600; }
.d-text-accent { fill: var(--accent); font-size: 11px; font-weight: 600; }
.d-mono { font-family: 'SF Mono', 'Fira Code', ui-monospace, Menlo, monospace; font-size: 10.5px; fill: var(--text); }
.d-line { stroke: var(--text-muted); stroke-width: 1.3; fill: none; }
.d-line-accent { stroke: var(--accent); stroke-width: 1.6; fill: none; }
.d-dash { stroke-dasharray: 4 3; }
.d-arrowhead { fill: var(--text-muted); }
.d-arrowhead-accent { fill: var(--accent); }
.d-good { fill: #2e9e5b; }
.d-bad { fill: #d03b3b; }
.d-warn { fill: #e0a100; }
.d-aws { fill: var(--surface); stroke: #e0a100; stroke-width: 1.4; }
.d-lane { fill: var(--code-bg); stroke: none; opacity: 0.55; }

article .callout {
  border-left: 3px solid var(--accent);
  background: var(--surface);
  border-radius: 0 10px 10px 0;
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  box-shadow: var(--shadow);
}

article .callout p:last-child {
  margin-bottom: 0;
}

article .callout .callout-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 0.35rem;
}

/* ---- footer ---- */

footer {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 1.75rem 1.25rem 2.5rem;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.82rem;
}

footer .footer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

footer .footer-links {
  display: flex;
  gap: 1.25rem;
}

/* ---- responsive ---- */

@media (max-width: 640px) {
  body { font-size: 16px; }
  nav { padding: 1rem 1rem 0; }
  main { padding: 1.75rem 1rem 3.5rem; }
  .logo-icon { height: 2rem; }
  nav .logo-text { font-size: 1.3rem; }
  nav .nav-right { gap: 0.75rem; }
  nav .nav-link { font-size: 0.85rem; }
  .hero h1 { font-size: 2.1rem; }
  .hero { margin-bottom: 2rem; padding-bottom: 1.5rem; }
  .hero-home { flex-direction: column-reverse; align-items: flex-start; gap: 1rem; }
  .hero-art { width: min(70%, 240px); align-self: center; }
  .post-card { padding: 1.2rem 1.25rem; border-radius: 12px; }
  .post-card .post-title { font-size: 1.25rem; }
  article .post-header h1 { font-size: 1.85rem; }
  article h2 { font-size: 1.55rem; margin-top: 2.5rem; }
  article h3 { font-size: 1.05rem; }
  article pre { padding: 0.9rem 1rem; border-radius: 8px; }
  article figure .diagram-scroll { padding: 0.5rem; border-radius: 10px; }
  article hr { margin: 2.25rem 0; }
}

@media (max-width: 380px) {
  nav .logo-text { display: none; }
}
