/* ============================================================
   blog.css — The Reading Room
   A tiling workspace: polybar, gaps, windows. Colours come from
   the shared semantic tokens, so this page follows whichever side
   the visitor chose on the landing page.
   ============================================================ */

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

html {
  background-color: var(--bg);
  scroll-behavior: smooth;
  scroll-padding-top: 4.5rem;
  scroll-padding-bottom: var(--switch-room);
}
html.no-motion { scroll-behavior: auto; }

body {
  font-family: var(--font-body);
  font-size: var(--text-body);
  line-height: var(--leading-body);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
  background: var(--bg);
  min-height: 100vh;
}

::selection { background: var(--text); color: var(--invert-text); }
img, svg { display: block; max-width: 100%; }
a { color: inherit; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; border-radius: 2px; }
a:not([href]) { cursor: default; }
.ph { border-bottom: 1px dotted var(--dotted); }

.skip-link {
  position: fixed; top: -4rem; left: 1rem; z-index: 100;
  padding: 0.6rem 1rem;
  background: var(--text); color: var(--invert-text);
  border-radius: 0.5rem; text-decoration: none;
  transition: top 200ms ease;
}
.skip-link:focus { top: 3.4rem; }

.container { max-width: var(--container); margin-inline: auto; padding-inline: var(--gutter); }

/* ---------- polybar ---------------------------------------------- */
/* The bar lives in bar.css now, shared with the record, the projects
   directory and every article page. */

/* ---------- room ------------------------------------------------- */
.room {
  max-width: 82rem;
  margin-inline: auto;
  padding: clamp(6rem, 12vh, 8.5rem) clamp(1rem, 3.5vw, 2.5rem) clamp(3rem, 8vh, 5rem);
}
.room__head { text-align: center; margin-bottom: clamp(2.5rem, 6vh, 4rem); }
.room__title {
  font-family: var(--font-display);
  font-size: var(--text-h2);
  font-weight: 540;
  font-variation-settings: "opsz" 90;
  letter-spacing: -0.01em;
  margin-bottom: var(--space-2);
}
.room__sub { color: var(--text-2); max-width: 52ch; margin-inline: auto; }
.room__keys {
  margin-top: 0.9rem;
  font-family: var(--font-mono);
  font-size: var(--text-micro);
  color: var(--text-3);
}

/* ---------- tiles — the workspace -------------------------------- */
.tiles {
  display: grid;
  grid-auto-flow: dense; /* a tiler leaves no holes */
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: clamp(0.8rem, 1.6vw, 1.15rem); /* i3-gaps */
  perspective: 1400px;
}
.tile--w2 { grid-column: span 2; }
.tile--w3 { grid-column: span 3; }
.tile--w4 { grid-column: span 4; }

.tile {
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0.8rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 14px 30px -18px rgba(0, 0, 0, 0.25);
  overflow: hidden;
  cursor: pointer;
  /* NO transform in this list — GSAP is the sole transform writer on tiles */
  transition:
    box-shadow var(--dur-breath) var(--ease-sand),
    border-color var(--dur-breath) var(--ease-sand);
}
.tile:hover, .tile.is-focused {
  /* the raise itself is JS-driven (GSAP is the sole transform writer) */
  border-color: var(--line-strong); /* the active window border */
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.06), 0 22px 44px -18px rgba(0, 0, 0, 0.32), 0 0 0 1px var(--panel-line);
}
.tile:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
.tile.is-hidden { display: none; }

.tile__bar {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: 0.5rem 0.9rem;
  font-family: var(--font-mono);
  font-size: var(--text-micro);
  color: var(--text-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line-soft);
}
.tile__file { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile__date { white-space: nowrap; }

.tile__title {
  font-family: var(--font-display);
  font-size: clamp(1.15rem, 1.9vw, 1.45rem);
  font-weight: 540;
  font-variation-settings: "opsz" 40;
  line-height: 1.22;
  padding: 0.9rem 1rem 0.35rem;
}
.tile--w4 .tile__title, .tile--w3 .tile__title { font-size: clamp(1.3rem, 2.2vw, 1.7rem); }
.tile__excerpt {
  color: var(--text-2);
  font-size: var(--text-small);
  line-height: var(--leading-slow);
  padding: 0 1rem 0.9rem;
  flex: 1;
}
.tile__meta {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.55rem 1rem 0.7rem;
  font-family: var(--font-mono);
  font-size: var(--text-micro);
  color: var(--text-3);
  border-top: 1px dashed var(--line-soft);
}
.tile__tags { color: var(--text); }
.tile__open {
  margin-left: auto;
  opacity: 0;
  transform: translateX(-4px);
  transition: opacity var(--dur-breath) var(--ease-sand), transform var(--dur-breath) var(--ease-sand);
}
.tile:hover .tile__open, .tile.is-focused .tile__open { opacity: 1; transform: none; }

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

.room__empty {
  margin-top: 3rem;
  text-align: center;
  font-family: var(--font-mono);
  font-size: var(--text-small);
  color: var(--text-3);
}

/* The footer lives in bar.css too. */

/* ---------- responsive ------------------------------------------- */
@media (max-width: 980px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile--w2, .tile--w3, .tile--w4 { grid-column: span 1; }
  .tile--w4 { grid-column: span 2; }
  .room__keys { display: none; } /* keyboard hints mean nothing on touch */
}

@media (max-width: 900px) {
  .bar { flex-wrap: wrap; gap: 0.5rem 1rem; padding-block: 0.5rem; }
  .bar__ws { order: 3; width: 100%; margin-inline: 0; justify-content: flex-start; overflow-x: auto; }
  .bar__right { margin-left: auto; }
  .bar__path { display: none; }
  .room { padding-top: 7.5rem; }
}

@media (max-width: 620px) {
  .tiles { grid-template-columns: 1fr; }
  .tile--w4 { grid-column: span 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- post page (generated from content/posts) ------------- */
.tile__title a { color: inherit; text-decoration: none; }
.room--post { max-width: 46rem; }
.post__head { text-align: center; margin-bottom: clamp(2rem, 5vh, 3rem); }
.post__meta { font-family: var(--font-mono); font-size: var(--text-micro); color: var(--text-3); margin-bottom: 0.8rem; }
.post__title {
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 4.5vw, 3rem);
  font-weight: 540;
  font-variation-settings: "opsz" 90;
  line-height: 1.12;
  letter-spacing: -0.01em;
}
.post__prose {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 1rem 1.5rem 1.1rem 1.6rem;
  padding: clamp(1.8rem, 5vw, 3rem);
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.05), 0 22px 44px -20px rgba(36, 36, 36, 0.22);
}
.post__prose p { line-height: var(--leading-slow); color: var(--text-2); margin-bottom: 1.2rem; }
.post__prose p:last-child { margin-bottom: 0; }
.post__prose h2, .post__prose h3, .post__prose h4 {
  font-family: var(--font-display); font-weight: 540; line-height: 1.2;
  margin: 1.8rem 0 0.7rem; color: var(--text);
}
.post__prose h2 { font-size: 1.6rem; }
.post__prose h3 { font-size: 1.35rem; }
.post__prose h4 { font-size: 1.15rem; }
.post__prose ul { margin: 0 0 1.2rem 0; list-style: none; }
.post__prose li { position: relative; padding-left: 1.2rem; margin-bottom: 0.4rem; color: var(--text-2); }
.post__prose li::before { content: ""; position: absolute; left: 0; top: 0.62em; width: 0.6rem; height: 2px; background: var(--text-3); }
.post__prose blockquote { border-left: 2px solid rgba(98, 98, 98, 0.35); padding-left: 1.1rem; margin: 0 0 1.2rem; font-style: italic; }
.post__prose code { font-family: var(--font-mono); font-size: 0.85em; background: var(--line-soft); padding: 0.1em 0.35em; border-radius: 0.3em; }
.post__prose pre {
  background: var(--panel-bg); color: var(--panel-text);
  font-family: var(--font-mono); font-size: var(--text-small);
  padding: 1rem 1.2rem; border-radius: 0.6rem;
  overflow-x: auto; margin-bottom: 1.2rem;
}
.post__prose pre code { background: none; padding: 0; color: inherit; }
.post__prose a { color: var(--text); text-underline-offset: 3px; }
.post__end { margin-top: 2rem; text-align: center; }
.post__end a { text-decoration: none; }

/* The way back to the shelf. It used to borrow .bar__tag.is-active, whose
   colours belong to the polybar: near-white ink on a translucent white
   shade, which is right on a dark panel and unreadable out here — 1.1:1
   against the paper in digital mode. Same shape, same voice, but drawn from
   the page's own tokens, so it follows whichever side the visitor chose
   instead of assuming a dark ground. The padding is what carries it past a
   44px tap target at 390px; the old one was 38px. */
.post__return {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border-radius: 0.45rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  transition: color var(--dur-breath) var(--ease-sand), background var(--dur-breath) var(--ease-sand), border-color var(--dur-breath) var(--ease-sand);
}
/* the inverted pair — the same solid-button treatment used elsewhere */
.post__return:hover { color: var(--invert-text); background: var(--invert-bg); border-color: var(--invert-bg); }
