/* Tun Khairi blog. Bump ?v= in every page's <link> when this file changes. */

@font-face {
  font-family: "Fraunces";
  src: url("../fonts/fraunces.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
}
@font-face {
  font-family: "Inter";
  src: url("../fonts/inter.woff2") format("woff2");
  font-weight: 400 600;
  font-display: swap;
}

:root {
  --bg: #faf8f4;
  --surface: #ffffff;
  --ink: #1b1a17;
  --muted: #6b675f;
  --line: #e7e2d8;
  --accent: #2554c7;
  --accent-soft: #e8eefc;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --wrap: 1080px;
  --read: 680px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141412;
    --surface: #1c1c19;
    --ink: #eeebe4;
    --muted: #a19c92;
    --line: #2d2c28;
    --accent: #7ea2ff;
    --accent-soft: #1d2640;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141412;
  --surface: #1c1c19;
  --ink: #eeebe4;
  --muted: #a19c92;
  --line: #2d2c28;
  --accent: #7ea2ff;
  --accent-soft: #1d2640;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 17px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration-color: var(--line); text-underline-offset: 3px; }
a:hover { color: var(--accent); text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 20px; }
.read { max-width: var(--read); margin: 0 auto; padding: 0 20px; }
.eyebrow {
  font: 600 12px/1 var(--sans);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 18px;
}
.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 16px; background: var(--surface); padding: 8px 12px; z-index: 10; }

/* Header */
.site-header { border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 68px; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font: 700 20px/1 var(--serif); letter-spacing: -.01em; }
.brand img { width: 34px; height: 34px; border-radius: 50%; }
.nav { display: flex; align-items: center; gap: 22px; font-size: 15px; font-weight: 500; }
.nav a { text-decoration: none; color: var(--muted); }
.nav a:hover, .nav a[aria-current="page"] { color: var(--ink); }
.nav-menu { position: relative; }
.nav-menu summary { list-style: none; cursor: pointer; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.nav-menu summary::-webkit-details-marker { display: none; }
.nav-menu summary::after { content: ""; width: 6px; height: 6px; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: translateY(-2px) rotate(45deg); }
.nav-menu[open] summary::after { transform: translateY(1px) rotate(-135deg); }
.nav-menu summary:hover, .nav-menu[open] summary, .nav-menu summary[aria-current="page"] { color: var(--ink); }
.nav-menu-panel {
  position: absolute; top: calc(100% + 14px); right: -12px; z-index: 20; min-width: 240px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .1); display: grid;
}
.nav-menu-panel a { color: var(--ink); padding: 10px 12px; border-radius: 8px; white-space: nowrap; }
.nav-menu-panel a:hover { background: var(--accent-soft); color: var(--ink); }
.nav-menu-panel .all { color: var(--muted); border-top: 1px solid var(--line); border-radius: 0 0 8px 8px; margin-top: 4px; }
.theme-toggle {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  width: 34px; height: 34px; border-radius: 50%; cursor: pointer; display: grid; place-items: center;
}
.theme-toggle:hover { color: var(--ink); }
.theme-toggle svg { width: 16px; height: 16px; }

/* Hero */
.hero { padding: 72px 0 64px; border-bottom: 1px solid var(--line); }
.hero .wrap { display: grid; grid-template-columns: 1fr 260px; gap: 56px; align-items: center; }
.hero h1 {
  font: 600 clamp(36px, 5.4vw, 60px)/1.06 var(--serif);
  letter-spacing: -.025em; margin: 0 0 22px;
}
.hero h1 em { font-style: italic; color: var(--accent); font-weight: 500; }
.hero p { font-size: 19px; color: var(--muted); margin: 0 0 28px; max-width: 34em; }
.hero-photo { width: 260px; aspect-ratio: 1; border-radius: 50%; object-fit: cover; background: var(--line); }
.btn {
  display: inline-flex; align-items: center; gap: 8px; text-decoration: none;
  background: var(--ink); color: var(--bg); font-weight: 600; font-size: 15px;
  padding: 12px 20px; border-radius: 999px;
}
.btn:hover { color: var(--bg); background: var(--accent); }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--surface); color: var(--ink); border-color: var(--ink); }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }

/* Sections */
.section { padding: 64px 0; }
.section + .section { border-top: 1px solid var(--line); }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; margin-bottom: 28px; }
.section-head h2 { font: 600 28px/1.2 var(--serif); letter-spacing: -.015em; margin: 0; }
.section-head a { font-size: 15px; font-weight: 500; color: var(--muted); }

/* Featured post */
.featured {
  display: grid; grid-template-columns: 1.1fr 1fr; gap: 40px; align-items: center;
  text-decoration: none; background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px; padding: 16px;
}
.featured:hover { color: inherit; border-color: var(--ink); }
.featured .cover { border-radius: 12px; aspect-ratio: 16/10; }
.featured h3 { font: 600 clamp(26px, 3vw, 34px)/1.15 var(--serif); letter-spacing: -.02em; margin: 10px 0 14px; }
.featured p { color: var(--muted); margin: 0 0 18px; }
.featured .body { padding: 8px 16px 8px 0; }

/* Covers: generated pattern until a real image exists */
.cover {
  background: var(--accent-soft);
  background-image:
    radial-gradient(circle at 20% 30%, color-mix(in srgb, var(--accent) 35%, transparent) 0 18%, transparent 19%),
    radial-gradient(circle at 75% 70%, color-mix(in srgb, var(--accent) 18%, transparent) 0 26%, transparent 27%);
  display: grid; place-items: center; overflow: hidden;
}
.cover span { font: 600 13px/1 var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.cover img { width: 100%; height: 100%; object-fit: cover; }

/* Post list */
.posts { list-style: none; margin: 0; padding: 0; }
.posts li { border-top: 1px solid var(--line); }
.posts li:last-child { border-bottom: 1px solid var(--line); }
.post-row {
  display: grid; grid-template-columns: 120px 1fr auto; gap: 24px; align-items: baseline;
  padding: 24px 0; text-decoration: none;
}
.post-row:hover { color: inherit; }
.post-row:hover h3 { color: var(--accent); }
.post-row time { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; }
.post-row h3 { font: 600 22px/1.3 var(--serif); letter-spacing: -.01em; margin: 0 0 6px; transition: color .15s; }
.post-row p { margin: 0; color: var(--muted); font-size: 16px; }
.tag {
  display: inline-block; font: 600 12px/1 var(--sans); letter-spacing: .04em;
  color: var(--accent); background: var(--accent-soft); padding: 6px 10px; border-radius: 999px;
  text-decoration: none; white-space: nowrap;
}
.meta { display: flex; gap: 12px; align-items: center; font-size: 14px; color: var(--muted); flex-wrap: wrap; }

/* Topics */
.topics { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.topic {
  display: block; text-decoration: none; padding: 20px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line);
}
.topic:hover { border-color: var(--ink); color: inherit; }
.topic strong { display: block; font: 600 19px/1.3 var(--serif); margin-bottom: 4px; }
.topic span { font-size: 14px; color: var(--muted); }

/* About strip */
.about-strip { display: grid; grid-template-columns: 96px 1fr; gap: 28px; align-items: start; max-width: 760px; }
.about-strip img { width: 96px; height: 96px; border-radius: 50%; }
.about-strip p { margin: 0 0 14px; font-size: 18px; }

/* Article */
.article-head { padding-top: 64px; padding-bottom: 36px; }
.article-head h1 { font: 600 clamp(32px, 4.6vw, 48px)/1.12 var(--serif); letter-spacing: -.025em; margin: 16px 0 18px; }
.article-head .lede { font-size: 20px; color: var(--muted); margin: 0 0 24px; }
.byline { display: flex; align-items: center; gap: 12px; font-size: 15px; color: var(--muted); }
.byline img { width: 40px; height: 40px; border-radius: 50%; }
.byline strong { color: var(--ink); font-weight: 600; }
.prose { font-size: 18.5px; line-height: 1.75; padding-bottom: 56px; }
.prose > * { margin-top: 0; margin-bottom: 0; }
.prose > * + * { margin-top: 1.2em; }
.prose > h2 { font: 600 28px/1.25 var(--serif); letter-spacing: -.015em; margin-top: 2em; }
.prose > h3 { font: 600 22px/1.3 var(--serif); margin-top: 1.6em; }
.prose a { color: var(--accent); text-decoration-color: currentColor; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li + li { margin-top: .4em; }
.prose blockquote {
  margin-left: 0; margin-right: 0; padding: 4px 0 4px 22px; border-left: 3px solid var(--accent);
  font: 500 22px/1.5 var(--serif); font-style: italic;
}
.prose img { border-radius: 12px; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.4em 0; }
.prose code { font-size: .9em; background: var(--accent-soft); padding: 2px 6px; border-radius: 4px; }
.placeholder-note {
  background: var(--accent-soft); border-radius: 12px; padding: 16px 18px; font-size: 16px; color: var(--ink);
}
.article-foot { border-top: 1px solid var(--line); padding: 40px 0 64px; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); padding: 36px 0 48px; font-size: 14px; color: var(--muted); }
.site-footer .wrap { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.site-footer nav { display: flex; gap: 18px; }
.site-footer a { text-decoration: none; }

/* Products */
.products { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; padding-bottom: 72px; }
.product-card {
  display: grid; grid-template-rows: auto 1fr; text-decoration: none; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
}
.product-card:hover { color: inherit; border-color: var(--ink); }
.product-card img { width: 100%; aspect-ratio: 1; object-fit: contain; background: var(--accent-soft); padding: 12px; }
.product-card > div { padding: 20px 22px 24px; display: flex; flex-direction: column; }
.product-card h2 { font: 600 22px/1.25 var(--serif); margin: 0 0 8px; }
.product-card p { margin: 0 0 18px; color: var(--muted); font-size: 16px; }
.product-link { margin-top: auto; font-weight: 600; font-size: 15px; color: var(--accent); }

/* Page title (archive, about) */
.page-head { padding: 64px 0 32px; }
.page-head h1 { font: 600 clamp(34px, 4.8vw, 52px)/1.1 var(--serif); letter-spacing: -.025em; margin: 0 0 14px; }
.page-head p { font-size: 19px; color: var(--muted); margin: 0; max-width: 36em; }
.topic-group { scroll-margin-top: 24px; }
.topic-group + .topic-group { margin-top: 48px; }
.topic-group h2 { font: 600 24px/1.2 var(--serif); margin: 0 0 8px; }

@media (max-width: 820px) {
  .hero { padding: 44px 0 48px; }
  .hero .wrap { grid-template-columns: 1fr; gap: 28px; }
  .hero-photo { width: 132px; order: -1; }
  .featured { grid-template-columns: 1fr; gap: 8px; }
  .featured .body { padding: 8px 8px 12px; }
  .post-row { grid-template-columns: 1fr; gap: 6px; padding: 20px 0; }
  .post-row .tag { justify-self: start; }
  .about-strip { grid-template-columns: 1fr; gap: 16px; }
  .section { padding: 48px 0; }
}
@media (max-width: 480px) {
  .nav { gap: 14px; font-size: 14px; }
  .nav-menu-panel { position: fixed; top: 60px; left: 16px; right: 16px; min-width: 0; }
  .nav-menu-panel a { white-space: normal; }
  .brand span { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
