/* base.css — typography, layout, cards, prose for nicolatech.blog (Lima ácida).
   Treatment rules (companion v5 §1): titles/links/highlights = --accent (lima);
   body copy = --text (#d8e3dc, "cuerpo neutro"), NEVER lima; monochrome (no second hue).
   Reduced-motion is handled globally by tokens.css. */

/* ---- reset ---- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);                 /* cuerpo neutro — body is #d8e3dc, never lima */
  font-family: var(--font-body);
  font-size: 1.0625rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, video, canvas, iframe { max-width: 100%; }
img { height: auto; }

/* ---- links: lima, monochrome affordance ---- */
a { color: var(--accent); text-decoration: none; }
a:hover, a:focus-visible { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

/* ---- headings: display font, lima ---- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  color: var(--accent);               /* titles = lima */
  line-height: 1.2;
  font-weight: 600;
  margin: 2rem 0 0.75rem;
}
h1 { font-size: clamp(2rem, 5vw, 2.85rem); letter-spacing: -0.02em; }
h2 { font-size: clamp(1.5rem, 3.5vw, 2rem); letter-spacing: -0.01em; }
h3 { font-size: 1.35rem; }
h4 { font-size: 1.15rem; }

/* ---- layout ---- */
.site-header, .site-footer {
  max-width: var(--maxw);
  margin-inline: auto;
  padding: 1.5rem 1.25rem;
}
.site-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.site-header .brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.25rem;
  color: var(--accent);
}
.site-header nav a {
  margin-left: 1.25rem;
  font-size: 0.95rem;
  color: var(--text-dim);
}
.site-header nav a:hover { color: var(--accent); }
.site-footer {
  border-top: 1px solid var(--line);
  margin-top: 4rem;
  color: var(--text-dim);
  font-size: 0.9rem;
}

main { max-width: var(--maxw); margin-inline: auto; padding: 2rem 1.25rem; }

/* ---- prose (article body) ---- */
.prose { font-size: 1.0625rem; }
.prose p { margin: 1.1rem 0; color: var(--text); }   /* body neutral */
.prose ul, .prose ol { margin: 1.1rem 0; padding-left: 1.4rem; }
.prose li { margin: 0.35rem 0; }
.prose blockquote {
  margin: 1.5rem 0;
  padding: 0.5rem 1.1rem;
  border-left: 3px solid var(--accent);
  background: var(--surface);
  color: var(--text-dim);
}
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 2.5rem 0; }
.prose img { border-radius: 8px; border: 1px solid var(--line); }
.prose a { text-decoration: underline; text-underline-offset: 2px; }

/* inline code */
.prose :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--surface-2);
  color: var(--ink-green);
  padding: 0.12em 0.4em;
  border-radius: 4px;
  border: 1px solid var(--line);
}

/* ---- code blocks (Shiki) + copy button ---- */
.code-block { position: relative; margin: 1.5rem 0; }
.code-block .copy-btn { top: 0.5rem; right: 0.5rem; }
.code-block pre.shiki,
pre.shiki {
  margin: 0;
  padding: 1rem 1.1rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.6;
}
pre.shiki code { font-family: inherit; }

/* copy button — shared by code blocks and prompt blocks */
.copy-btn {
  position: absolute;
  z-index: 2;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  color: var(--accent);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.25rem 0.55rem;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.copy-btn:hover { background: var(--accent); color: var(--accent-ink); }
.copy-btn[data-copied="true"] { color: var(--accent); border-color: var(--accent); }

/* ---- prompt destacado block (::: prompt) ---- */
.prompt-block {
  position: relative;
  margin: 1.75rem 0;
  padding: 1.1rem 1.1rem 0.4rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 10px;
}
.prompt-block::before {
  content: attr(data-prompt-label);
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  color: var(--ink-green);
  margin-bottom: 0.4rem;
}
.prompt-block .copy-btn { top: 0.75rem; right: 0.75rem; }
.prompt-block .prompt-body { color: var(--text); }
.prompt-block .prompt-body p:first-child { margin-top: 0; }
.prompt-block .prompt-body pre.shiki { margin: 0.5rem 0; }

/* ---- post header ---- */
.post-header { margin-bottom: 2rem; }
.post-header .post-meta {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-dim);
  margin-top: 0.5rem;
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
}
.chip {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-green);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
}

/* ---- immersive interactive posts (WF v9): no card chrome; prose keeps the centered reading
   column (--maxw), and only children opting in via .full-bleed break out edge-to-edge. The site
   header/footer remain. Engine block styles (.prompt-block, .selector-tabs, [data-block], …)
   live in embed.css, linked on these pages. ---- */
body.immersive main { max-width: none; margin: 0; padding: 0; }
/* Immersive prose returns to the reading column (matches `main` near the top of this file);
   wide children break out via .full-bleed below. */
body.immersive .immersive {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding: 2rem 1.25rem;
}
/* Opt-out: wide diagrams / 3D mounts / blueprint figures span the full viewport. */
body.immersive .immersive .full-bleed {
  width: 100vw;
  max-width: 100vw;
  margin-inline: calc(50% - 50vw);
}
/* Interactive/immersive posts sit on the SAME frosted-glass reading panel as markdown posts
   (PM: "el mismo formato todos"). Here `main` widens + centers exactly like main:has(.post-panel)
   does for markdown, and the inner .immersive fills the panel instead of clamping to --maxw. */
body.immersive main:has(.post-panel) { max-width: min(94vw, 1180px); margin-inline: auto; padding: 2rem 1.25rem; }
body.immersive .post-panel .immersive { max-width: none; margin: 0; padding: 0; }

/* Frosted-glass surface primitive — every card/panel/player composes this look via tokens.
   --glass (translucent --surface) + backdrop-filter over the fixed constellation canvas. */
.surface, .post-card, .prompt-block, .audio-player {
  background: var(--surface);          /* fallback for browsers without color-mix() */
  background: var(--glass);
  -webkit-backdrop-filter: blur(var(--card-blur));
  backdrop-filter: blur(var(--card-blur));
}
/* Disable blur on mobile — the always-animating constellation re-blurs every rAF frame,
   causing jank on low-power devices. The translucent --glass fill is kept (cheap). */
@media (max-width: 560px) {
  .surface, .post-card, .prompt-block, .audio-player {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

/* ---- reading panel (markdown posts): header + prose sit on a frosted-glass panel (pmartifact
   chapter look) so long-form text stays readable over the animated constellation. Unlike the
   transparent list cards (--card-opacity 0), this panel carries its OWN translucent fill. ---- */
.post-panel {
  background: var(--surface);   /* opaque fallback where color-mix() is unsupported */
  background: color-mix(in srgb, var(--surface) 25%, transparent);
  -webkit-backdrop-filter: blur(var(--card-blur));
  backdrop-filter: blur(var(--card-blur));
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 2.5rem 2.75rem;
  margin: 0 0 2rem;
}
/* Wider glass than the reading column: the panel spans a wider viewport-relative width while the
   header + prose inside stay at the comfortable reading measure (--maxw), centered on the glass. */
main:has(.post-panel) { max-width: min(94vw, 1180px); }
/* Text expands to fill the wider glass (no inner reading-column clamp). */
@media (max-width: 560px) {
  .post-panel {
    -webkit-backdrop-filter: none;   /* constellation re-blurs every rAF frame -> jank on mobile */
    backdrop-filter: none;
    padding: 1.5rem 1.25rem;
    border-radius: 12px;
  }
}

/* ---- home / category cards ---- */
.post-grid { display: grid; gap: 1.25rem; margin: 2rem 0; }
.post-card {
  display: block;
  /* 15% glass fill (lighter than the 25% post panel) over the cosmic-web clouds (falls back to
     --glass from the shared surface rule where color-mix() is unsupported) */
  background: color-mix(in srgb, var(--surface) 15%, transparent);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.25rem;
  transition: border-color .15s, transform .15s;
}
.post-card:hover { border-color: var(--accent); text-decoration: none; }
.post-card h2 { margin: 0 0 0.4rem; font-size: 1.4rem; }
.post-card .card-excerpt { color: var(--text); margin: 0.4rem 0 0.75rem; }
.post-card .card-meta {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-dim);
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.page-intro { color: var(--text-dim); margin-bottom: 1.5rem; }
.empty-state { color: var(--text-dim); padding: 3rem 0; text-align: center; }

/* ---- reveal-on-scroll (islands/reveal.js). Scoped under `.js` (shell sets it inline before
   paint) so content is NEVER hidden when JS is unavailable — progressive enhancement. ---- */
.js [data-reveal] { opacity: 0; transform: translateY(12px); }
.js .revealed { opacity: 1; transform: none; transition: opacity .5s ease, transform .5s ease; }

/* ---- animated canvas background (islands/backgrounds.js). Fixed behind content; the body's
   solid --bg shows through the transparent areas the canvas clears -> lima-on-near-black. ---- */
.bg-canvas { position: fixed; inset: 0; z-index: 0; pointer-events: none; filter: blur(1.25px); }
.site-header, main, .site-footer { position: relative; z-index: 1; }

/* ---- static audio player (islands/audio.js) ---- */
.audio-player {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.5rem 0;
  padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.audio-player button {
  font-family: var(--font-mono);
  color: var(--accent);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.35rem 0.6rem;
  cursor: pointer;
}
.audio-player button:hover { background: var(--accent); color: var(--accent-ink); }
.audio-player .audio-seek { flex: 1; accent-color: var(--accent); }
.audio-player .audio-time { font-family: var(--font-mono); font-size: 0.8rem; color: var(--text-dim); min-width: 5.5em; }

/* ---- responsive ---- */
@media (max-width: 480px) {
  body { font-size: 1rem; }
  main { padding: 1.25rem 1rem; }
  .site-header { padding: 1.1rem 1rem; }
  h1 { font-size: 1.9rem; }
}
