/* ==========================================================================
   Atma devlog — baista.dev
   Values mirror reference/atma-blog-reference.html in the design handoff.

   Note: no global `box-sizing: border-box` reset, deliberately. The reference
   renders with the browser default (content-box), so `.wrap` measures
   960px of content plus 24px of padding on each side. Changing the box model
   here would narrow every column by 48px.
   ========================================================================== */

/* --- Tokens -------------------------------------------------------------- */

:root {
  --bg:   #f3efe6;
  --ink:  #171b1d;
  --mut:  #6a716f;
  --acc:  #0d6b60;
  --line: rgba(23, 27, 29, .16);
  --code: rgba(23, 27, 29, .055);
}

html[data-theme="dark"] {
  --bg:   #10171a;
  --ink:  #e7e4da;
  --mut:  #8d9793;
  --acc:  #5ecfba;
  --line: rgba(231, 228, 218, .16);
  --code: rgba(231, 228, 218, .06);
}

/* Fixed in both themes (header + hero are always dark). */
:root {
  --navy:       #0a1c22;
  --hero-text:  #f0ece1;
  --hero-head:  #f6f2e7;
  --mint:       #8fd8c8;
  --cta:        #5ecfba;
  --cta-hover:  #8fdccc;
  --header-bg:  rgba(9, 22, 27, .88);
}

/* --- Base ---------------------------------------------------------------- */

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Instrument Sans', sans-serif;
  transition: background .25s, color .25s;
}

a { color: var(--acc); text-underline-offset: 3px; }
a:hover { color: var(--ink); }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }

input::placeholder { color: var(--mut); }

.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding-left: 24px;
  padding-right: 24px;
}

.spacer { flex: 1; }

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}

/* --- Header (always dark) ------------------------------------------------ */

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(240, 236, 225, .08);
}

.nav {
  padding-top: 11px;
  padding-bottom: 11px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  color: var(--hero-text);
  font-size: 14px;
}

.brand {
  font-family: 'Instrument Serif', serif;
  font-size: 22px;
  letter-spacing: .01em;
}

.nav-link {
  opacity: .7;
  font-size: 13px;
  color: var(--hero-text);
  text-decoration: none;
}
.nav-link:hover {
  opacity: 1;
  color: var(--hero-text);
  text-decoration: underline;
}

/* Sliding switch. The knob carries the icon of the theme you are CURRENTLY in,
   and sits on that side of the track — left for light, right for dark. */
.theme-toggle {
  position: relative;
  flex-shrink: 0;
  width: 46px;
  height: 24px;
  background: rgba(240, 236, 225, .12);
  border: none;
  border-radius: 999px;
  padding: 0;
  cursor: pointer;
}
.theme-toggle:hover { background: rgba(240, 236, 225, .24); }

.theme-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  background: var(--hero-text);
  color: var(--navy);
  border-radius: 999px;
  transition: transform .25s ease;
}
html[data-theme="dark"] .theme-knob { transform: translateX(22px); }

.theme-toggle svg {
  width: 11px;
  height: 11px;
  grid-area: 1 / 1;
}
/* Show only the icon for the active theme. */
html[data-theme="dark"]  .theme-sun,
html[data-theme="light"] .theme-moon { display: none; }

@media (prefers-reduced-motion: reduce) {
  .theme-knob { transition-duration: .01ms; }
}

.cta {
  background: var(--cta);
  color: var(--navy);
  text-decoration: none;
  font-weight: 600;
  font-size: 13.5px;
  border-radius: 999px;
  padding: 8px 18px;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(94, 207, 186, .22);
}
.cta:hover { background: var(--cta-hover); color: var(--navy); }

/* --- Hero (always dark) --------------------------------------------------- */

.hero {
  position: relative;
  overflow: hidden;
  background: var(--navy);
}

/* hero-sea.jpg is pre-cropped (see README); the transform below only restores
   the reference framing, it is no longer doing the HUD crop. */
.hero-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 45% 45%;
  transform: scale(1.18);
  transform-origin: 45% 45%;
  opacity: .55;
  filter: saturate(.75);
}

.hero-veil {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg,
    rgba(8, 18, 22, .35) 0%,
    rgba(8, 18, 22, .25) 45%,
    rgba(8, 18, 22, .82) 100%);
}

.hero-inner {
  position: relative;
  padding-top: min(10vw, 90px);
  padding-bottom: min(14vw, 72px);
}

.hero-kicker {
  font-size: 12px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: rgba(240, 236, 225, .75);
}

.hero-title {
  margin: 14px 0 0;
  font-family: 'Instrument Serif', serif;
  font-weight: 400;
  font-size: clamp(40px, 8vw, 76px);
  line-height: 1.02;
  color: var(--hero-head);
  max-width: 14ch;
}
.hero-dot { color: var(--mint); }

.hero-lede {
  margin: 18px 0 0;
  font-size: 16px;
  line-height: 1.6;
  color: rgba(240, 236, 225, .85);
  max-width: 52ch;
}

.hero-sub {
  margin: 26px 0 0;
  font-size: 13.5px;
  text-align: center;
  color: rgba(240, 236, 225, .66);
  max-width: 52ch;
}

/* --- Page body ----------------------------------------------------------- */

.page { padding-bottom: 72px; }

.log-head {
  display: flex;
  align-items: baseline;
  gap: 18px;
  flex-wrap: wrap;
  padding: 34px 0 12px;
  border-bottom: 1px solid var(--ink);
}

.section-title {
  margin: 0;
  font-family: 'Instrument Serif', serif;
  font-weight: 400;
  font-size: 30px;
}

.tag-chip {
  font-family: 'Instrument Sans', sans-serif;
  font-size: 11px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--acc);
  background: none;
  border: 1px solid var(--acc);
  border-radius: 999px;
  padding: 5px 12px;
  cursor: pointer;
}
.tag-chip:hover { color: var(--ink); border-color: var(--ink); }

.log-controls {
  display: flex;
  align-items: baseline;
  gap: 18px;
  flex-wrap: wrap;
}

/* Matches the search field: transparent, one bottom rule, custom caret so it
   doesn't drag in the OS select chrome. */
.tag-select {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: none;
  border-bottom: 1px solid var(--line);
  font-family: 'Instrument Sans', sans-serif;
  font-size: 14px;
  color: var(--ink);
  padding: 6px 20px 6px 2px;
  cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: right 7px top 55%, right 2px top 55%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.tag-select:hover { color: var(--acc); }
/* The open list is drawn by the OS, so it needs explicit colours in dark mode. */
.tag-select option { background: var(--bg); color: var(--ink); }

.search {
  background: none;
  border: none;
  border-bottom: 1px solid var(--line);
  font-family: 'Instrument Sans', sans-serif;
  font-size: 14px;
  color: var(--ink);
  padding: 6px 2px;
  width: min(220px, 60vw);
}

/* --- Feed ---------------------------------------------------------------- */

/* Filter animation: rows are never removed from the DOM, they collapse.
   `visibility` is delayed until the collapse finishes so a hidden post also
   drops out of the tab order. */
.post-wrap {
  display: grid;
  grid-template-rows: 1fr;
  opacity: 1;
  transition: grid-template-rows .4s ease, opacity .35s ease;
}
.post-clip {
  overflow: hidden;
  min-height: 0;
  visibility: visible;
  transition: visibility 0s;
}
.post-wrap.is-filtered {
  grid-template-rows: 0fr;
  opacity: 0;
}
.post-wrap.is-filtered .post-clip {
  visibility: hidden;
  transition: visibility 0s .4s;
}

.post {
  display: flex;
  gap: 26px;
  border-bottom: 1px solid var(--line);
  padding: 30px 0;
}

.post-num {
  flex: 0 0 52px;
  font-family: 'Instrument Serif', serif;
  font-style: italic;
  font-size: 22px;
  color: var(--mut);
}

.post-main { flex: 1; min-width: 0; }

.post-meta {
  display: flex;
  gap: 16px;
  align-items: baseline;
  flex-wrap: wrap;
}

.post-tag {
  font-family: 'Instrument Sans', sans-serif;
  font-size: 11px;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--acc);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}
.post-tag:hover { text-decoration: underline; text-underline-offset: 3px; }

.post-date {
  font-size: 13px;
  color: var(--mut);
  font-family: 'Instrument Serif', serif;
  font-style: italic;
}

.post-title { margin: 8px 0 0; }

.post-title-btn {
  display: block;
  width: 100%;
  text-align: left;
  font-family: 'Instrument Serif', serif;
  font-weight: 400;
  font-size: clamp(24px, 4vw, 32px);
  line-height: 1.15;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}
.post-title-btn:hover { color: var(--acc); }

.post-teaser {
  margin: 10px 0 0;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--mut);
  max-width: 64ch;
}

.post-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .4s ease;
}
.post-body-clip {
  overflow: hidden;
  min-height: 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity .35s ease, visibility 0s .4s;
}
.post.is-open .post-body { grid-template-rows: 1fr; }
.post.is-open .post-body-clip {
  opacity: 1;
  visibility: visible;
  transition: opacity .35s ease, visibility 0s;
}

.post-body-inner {
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 13px;
  max-width: 66ch;
}
.post-body-inner p {
  margin: 0;
  font-size: 15.5px;
  line-height: 1.75;
}

.post-figure {
  margin: 6px 0;
}
.post-figure img {
  display: block;
  width: 100%;
  height: auto;
}
.post-caption {
  margin: 8px 0 0;
  font-family: 'Instrument Serif', serif;
  font-style: italic;
  font-size: 13px;
  line-height: 1.5;
  color: var(--mut);
  text-align: center;
}

.post-actions {
  display: flex;
  align-items: baseline;
  gap: 22px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.post-close,
.post-permalink {
  font-family: 'Instrument Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  color: var(--acc);
  background: none;
  border: none;
  border-bottom: 1px solid var(--acc);
  padding: 0 0 2px;
  cursor: pointer;
  text-decoration: none;
}
.post-close:hover,
.post-permalink:hover { color: var(--ink); border-bottom-color: var(--ink); }

.empty {
  padding: 34px 0;
  font-family: 'Instrument Serif', serif;
  font-style: italic;
  font-size: 18px;
  color: var(--mut);
}

/* --- Post pages ----------------------------------------------------------
   posts/<slug>/index.html — one per post, generated by build.js.
   ------------------------------------------------------------------------- */

.brand-link { color: var(--hero-text); text-decoration: none; }
.brand-link:hover { color: var(--hero-text); }

.post-page { padding-top: 34px; }

.back-link {
  display: inline-block;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  margin-bottom: 26px;
}
.back-link:hover { text-decoration: underline; }

.post-page-title {
  margin: 10px 0 0;
  font-family: 'Instrument Serif', serif;
  font-weight: 400;
  font-size: clamp(32px, 5.5vw, 52px);
  line-height: 1.08;
  max-width: 20ch;
}

.post-page-teaser {
  margin: 16px 0 0;
  font-size: 17px;
  line-height: 1.6;
  color: var(--mut);
  max-width: 60ch;
}

.post-content {
  margin-top: 30px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
  max-width: 66ch;
}

/* --- Rich content (shared by post pages and expanded feed bodies) --------- */

.post-content > p,
.post-content > ul,
.post-content > ol,
.post-content > blockquote,
.post-content > pre,
.post-content > figure,
.post-content > hr {
  margin: 0 0 13px;
}
.post-content > *:last-child { margin-bottom: 0; }

.post-content p,
.post-body-inner p { font-size: 15.5px; line-height: 1.75; }

.post-content h2, .post-body-inner h2,
.post-content h3, .post-body-inner h3,
.post-content h4, .post-body-inner h4,
.post-content h5, .post-body-inner h5 {
  font-family: 'Instrument Serif', serif;
  font-weight: 400;
  line-height: 1.2;
  margin: 26px 0 10px;
}
.post-content > *:first-child,
.post-body-inner > *:first-child { margin-top: 0; }
.post-content h2, .post-body-inner h2 { font-size: 26px; }
.post-content h3, .post-body-inner h3 { font-size: 22px; }
.post-content h4, .post-body-inner h4,
.post-content h5, .post-body-inner h5 { font-size: 18px; }

.post-content ul, .post-body-inner ul,
.post-content ol, .post-body-inner ol {
  padding-left: 22px;
}
.post-content li, .post-body-inner li {
  font-size: 15.5px;
  line-height: 1.75;
  margin-bottom: 4px;
}

.post-content blockquote, .post-body-inner blockquote {
  margin-left: 0;
  padding-left: 18px;
  border-left: 2px solid var(--acc);
  color: var(--mut);
}
.post-content blockquote p, .post-body-inner blockquote p { margin: 0 0 8px; }
.post-content blockquote p:last-child,
.post-body-inner blockquote p:last-child { margin-bottom: 0; }

.post-content code, .post-body-inner code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .88em;
  background: var(--code);
  padding: 2px 5px;
  border-radius: 3px;
}

.post-content pre, .post-body-inner pre {
  background: var(--code);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 14px 16px;
  overflow-x: auto;
}
.post-content pre code, .post-body-inner pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: 13.5px;
  line-height: 1.6;
}

.post-content hr, .post-body-inner hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 26px 0;
}

/* --- 404 ----------------------------------------------------------------- */

.notfound { padding: 80px 0 100px; }
.notfound-title {
  margin: 0;
  font-family: 'Instrument Serif', serif;
  font-weight: 400;
  font-size: clamp(32px, 6vw, 52px);
  line-height: 1.08;
}
.notfound-text {
  margin: 18px 0 26px;
  font-size: 15.5px;
  line-height: 1.75;
  color: var(--mut);
  max-width: 52ch;
}

/* --- Older / newer ------------------------------------------------------- */

.post-nav {
  display: flex;
  justify-content: space-between;
  gap: 26px;
  flex-wrap: wrap;
  margin-top: 48px;
  padding-top: 26px;
  border-top: 1px solid var(--line);
}
.post-nav a {
  font-family: 'Instrument Serif', serif;
  font-size: 18px;
  line-height: 1.3;
  text-decoration: none;
  max-width: 34ch;
}
.post-nav a:hover { text-decoration: underline; }
.post-nav-next { text-align: right; }

/* --- About --------------------------------------------------------------- */

.about {
  margin-top: 56px;
  border-top: 1px solid var(--ink);
  padding-top: 34px;
  display: flex;
  gap: 34px;
  flex-wrap: wrap;
}

.about-title { flex: 0 0 170px; }

.about-body {
  flex: 1 1 380px;
  min-width: 260px;
  max-width: 62ch;
  display: flex;
  flex-direction: column;
  gap: 13px;
}
.about-body p {
  margin: 0;
  font-size: 15.5px;
  line-height: 1.75;
}

/* --- Footer -------------------------------------------------------------- */

.site-footer {
  display: flex;
  gap: 20px;
  align-items: baseline;
  flex-wrap: wrap;
  padding-top: 40px;
}

.footer-sign {
  font-family: 'Instrument Serif', serif;
  font-style: italic;
  font-size: 22px;
}

.footer-link { font-size: 14px; }

.footer-copy {
  font-size: 13px;
  color: var(--mut);
}

/* --- Reduced motion ------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
  html, body,
  .post-wrap, .post-clip, .post-body, .post-body-clip {
    transition-duration: .01ms;
  }
}
