/* ================================================================
   Nitāy Vedana — "Matter-inspired UI" editorial dark theme blog
   ================================================================ */

/* ================================================================
   FONTS — sans and sans-serif used in app, needs the mono fonts
   ================================================================ */

@font-face {
  font-family: 'Nunito Sans';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/NunitoSans-Italic.woff2') format('woff2');
}

@font-face {
  font-family: 'Nunito Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/NunitoSans-Regular.woff2') format('woff2');
}

@font-face {
  font-family: 'Nunito Sans';
  font-style: italic;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/NunitoSans-BoldItalic.woff2') format('woff2');
}

@font-face {
  font-family: 'Nunito Sans';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/NunitoSans-Bold.woff2') format('woff2');
}

@font-face {
  font-family: 'Charis SIL';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/CharisSIL-Italic.woff2') format('woff2');
}

@font-face {
  font-family: 'Charis SIL';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/CharisSIL-Regular.woff2') format('woff2');
}

@font-face {
  font-family: 'Charis SIL';
  font-style: italic;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/CharisSIL-BoldItalic.woff2') format('woff2');
}

@font-face {
  font-family: 'Charis SIL';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/CharisSIL-Bold.woff2') format('woff2');
}

/* ================================================================
   DESIGN TOKENS
   ================================================================ */

:root {

  /* ---- Base surfaces (Jacaranda Dark UI palette) ---- */
  --bg:               #151C26; /* Gunmetal Blue — app background */
  --panel:            #250D3B; /* Dark Purple, desaturated slightly — chrome (header/footer/dropdowns) */
  --panel-2:          #101823; /* Dark Blue-Gray — inset surfaces (code, inputs, search groups) */
  --page-surround:    #0A0A0C; /* desktop gutter only, never seen on mobile */
  --code-bg:          #0B1017; /* code background */
  --lighbox-surround: rgba(10, 10, 12, 0.72);  /* lightbox code dark surround */

  /* ---- Text ---- */
  --text:      #E0E0E0; /* Light Gray — article body, default UI text */
  --ink:       #F1ECE2; /* warm off-white — titles, strong emphasis, high-contrast UI */
  --white:     #FFFFFF;
  --muted:     #C5A5C5; /* Dusty Lavender — metadata, quiet secondary text */
  --muted-2:   rgba(197, 165, 197, 0.62); /* even quieter — previews, timestamps */

  /* ---- Accents (used sparingly) ---- */
  --jade:   #00AA6D; /* Jade Green */
  --cyan:   #5CE1E6; /* Neon Cyan   — primary interactive accent (links, focus, active) */
  --violet: #A78BFA; /* Electric Violet */
  --peach:  #E7953E; /* Neon Peach */
  --lime:   #9ADB1E; /* Electric Lime */
  --accent: var(--peach); /* referenced inline by generated template markup — do not rename */
  --accent-green: var(--jade); /* legacy alias kept for continuity with generated inline styles */

  /* ---- Borders / overlays / shadows ---- */
  --border:        rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --overlay-dark:  rgba(0, 0, 0, 0.25);
  --shadow-dark:   rgba(0, 0, 0, 0.45);
  --shade-10:      rgba(255, 255, 255, 0.03);
  --shade-30:      rgba(255, 255, 255, 0.06);
  --focus-ring:    var(--cyan);
  --hit-bg:        rgba(231, 149, 62, 0.85); /* search-hit highlight, warm */
  --success-bg:    rgba(0, 170, 109, 0.14);

  /* ---- Fonts ---- */
  --font-serif: 'Charis SIL', serif;
  --font-sans:  'Nunito Sans', sans-serif;
  /* --font-mono: STILL_MISSING; */

  /* ---- Layout ---- */
  --header-h:      56px;
  --page-pad:      18px;
  --reading-width: 680px;
  --radius-sm:     6px;
  --radius-md:     10px;
  --touch:         44px;

  --transition-fast: 0.15s ease;
  --transition-med:  0.25s ease;
}

/* ================================================================
   RESET / BASE
   ================================================================ */

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
  overscroll-behavior-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--muted) transparent;
  -webkit-text-size-adjust: 100%;
}

html.is-template-view {
  overscroll-behavior-y: contain;
}

html, body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  min-height: 100%;
  margin: 0;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;

  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.6;
  margin: 0;
  padding: calc(var(--header-h) + env(safe-area-inset-top)) 0 0 0;
  -webkit-font-smoothing: antialiased;
}

@media (min-width: 721px) {
  #content::after {
    content: "";
    position: fixed;
    top: 0;
    bottom: 0;
    left: calc(50% - 345px);
    width: 8px;
    height: 100vh;
    background-color: var(--peach);
    pointer-events: none;

    /* soft raised-panel halo */
    box-shadow: 2px 0 4px var(--shadow-dark);

    z-index: 4;

    opacity: 0;
    animation: edge-line-fade-in 0.7s ease 0.15s forwards;
  }

  @keyframes edge-line-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
  }
}

img { max-width: 100%; }

button {
  font: inherit;
  color: inherit;
}

/* ================================================================
   WIDE-SCREEN FRAME — mobile first; desktop gets a centered
   editorial canvas with a quiet surrounding gutter.
   ================================================================ */

@media (min-width: 721px) {
  body {
    background: var(--page-surround);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='46.5' viewBox='0 0 80 93'%3E%3Cg fill-rule='evenodd'%3E%3Cg id='seed-of-life' fill='%23101823' fill-opacity='0.4'%3E%3Cpath d='M6.8 93c0-5.7-1.2-11.7-3.2-17C9 84.3 25.4 93 34 93h12.8c6.2 0 22.7-6.9 29.5-16.7-1.9 5.3-3 11-3 16.7h1.2c0-4.7 2.1-18.8 5.6-22v-2.4c-5.7-8.3-8.5-30.2 0-43.9V22c-3.6-4.9-5.6-16.1-5.6-22h-1.2c.1 5.6 1 11.2 2.9 16.6C70.1 9.1 56.5 0 46.7 0H34C23.6 0 10 9.2 3.8 16.8c1.9-5.4 3-11.1 3-16.8H5.6C5.5 7.7 3.7 15.3.1 22.1v2.3C7.7 38 7 56.4 0 68.5V71c3.7 6.7 5.6 14.4 5.6 22zM40 91.7c-7.4-12.8-7.3-31.1 0-44.1 8.1 13.9 6.6 33.2 0 44.1m-3.8-5.4c-7.3-8.8-17.6-14.8-28.9-16.6C18.6 68 29 62 36.3 53.2c-4.4 9-3.6 25.8-.1 33.1m7.7-33c7.4 8.7 17.7 14.7 29 16.4-11.3 1.8-21.7 7.7-28.9 16.6 1.9-5.4 2.9-10.9 2.9-16.6 0-5.5-1-11.3-3-16.4m-2.8 39c7.7-13.1 22.9-21.7 38-21.9-6.8 13.2-23.6 21.5-38 21.9M79 69c-15.1-.2-30.2-8.7-37.8-21.9 14.3 0 30.9 9.2 37.8 21.9m-2.7-6c-7.4-8.7-17.7-14.8-29-16.5 10.6-1.6 22.1-8 28.9-16.5-4.3 9.9-3.3 25.5.1 33M41.1 45.9c7.6-13.1 23-21.7 38-22-7.3 12.9-23.3 22-38 22m2.8-6c3.3-9 4.3-22.8 0-33 7.3 8.8 17.7 14.6 28.9 16.5-11.2 1.6-21.6 7.7-28.9 16.5M79 22.6c-15.1-.3-30.3-8.8-38-21.9 15.2.4 30.6 8.6 38 21.9M40 1.4c7.6 13.5 7.2 31.5 0 44-7.2-11.6-7.6-31.5 0-44m-3.8 38.3C29 31.1 18.7 25.1 7.6 23.3 18.7 21.4 29 15.5 36.2 6.8c-2 5.3-2.9 10.8-2.9 16.5-.1 5.5.8 11.3 2.9 16.4M39 .7c-7.5 13.1-22.9 21.7-37.9 22C9.2 9.4 23.6 1.1 39 .7m0 45.2c-15.5-.4-29.9-8.8-37.9-22 15.9.3 29.5 8.6 37.9 22M3.8 29.8c7.3 8.9 17.8 15.1 29.2 16.8-10.8 1.6-22.6 8.2-29.3 16.9 4-8.9 4.8-24 .1-33.7M39 47.1C31.4 60 16.2 68.8 1.2 69 9.1 55.9 23.6 47.5 39 47.1m-.1 45.2C24.3 92.2 8.5 83 1.2 70.4c15.3.4 29.9 8.6 37.7 21.9' /%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  }

  header#site-header {
    left: calc(50% - 360px);
    right: calc(50% - 360px);
    width: auto;
    box-shadow: 0 1px 0 var(--border), 0 12px 28px var(--shadow-dark);
  }

  footer {
    max-width: 720px;
    margin: 0 auto;
    box-shadow: 0 12px 28px var(--shadow-dark);
  }
}

/* ================================================================
   CONTENT TRANSITION
   ================================================================ */

#content.content-offscreen-right {
  transform: translateX(16px);
  opacity: 0;
}

#content.content-notransition {
  transition: none;
}

@media (prefers-reduced-motion: reduce) {
  #content { transition: none; }
}

/* ================================================================
   HEADER / TOP NAV
   ================================================================ */

header#site-header {
  background-color: var(--panel);
  color: var(--text);
  box-shadow: 0 1px 0 var(--border);
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  padding-top: env(safe-area-inset-top);
  z-index: 999;
}

#top-nav {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  padding: 6px var(--page-pad);
  gap: 10px;
  min-height: var(--header-h);
  border-bottom: 2px solid var(--accent);
  box-shadow: 0 2px 6px var(--shadow-dark);
}

.nav-left, .nav-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-left { min-width: 0; }

.nav-custom {
  display: flex;
  align-items: center;
  min-width: 0;
  overflow: hidden;
}

.nav-custom .nav-logo {
  display: block;
  width: 100%;
  height: auto;
  max-width: 132px;
  fill: var(--jade);
  opacity: 1;
}

.nav-center {
  position: relative;
  min-width: 0;
}

.nav-right { flex: 0 0 auto; }

.back-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1;
  min-height: var(--touch);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: none;
  cursor: pointer;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  padding: 6px 10px;
  transition: color var(--transition-fast), background-color var(--transition-fast), border-color var(--transition-fast);
}

.back-btn .back-icon {
  flex-shrink: 0;
  display: block;
}

.back-btn:hover,
.back-btn:focus-visible {
  color: var(--ink);
  background: var(--shade-30);
  border-color: var(--border-strong);
}

.back-icon { flex-shrink: 0; }

.nav-menu-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: var(--touch);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 0.98rem;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  max-width: 60vw;
  overflow: hidden;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.nav-menu-btn span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-menu-btn .footer-marquee-track {
  flex: 0 0 max-content;
  width: max-content;
  max-width: none;
  overflow: visible;
}

.nav-menu-btn .footer-marquee-track span {
  flex: 0 0 auto;
  overflow: visible;
  text-overflow: clip;
}

.nav-menu-btn:hover,
.nav-menu-btn:focus-visible {
  color: var(--cyan);
  background: var(--shade-30);
}

/* ---- Animated menu icon ---- */

.nav-menu-icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  overflow: visible;
}

.nav-menu-icon .menu-line {
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
}

.nav-menu-icon .line-top    { transform: translateY(0); }
.nav-menu-icon .line-middle { transform: scaleX(1); opacity: 1; }
.nav-menu-icon .line-bottom { transform: translateY(0); }

.nav-center.is-open .nav-menu-icon .line-top    { transform: translateY(6px) rotate(45deg); }
.nav-center.is-open .nav-menu-icon .line-middle { transform: scaleX(0); opacity: 0; }
.nav-center.is-open .nav-menu-icon .line-bottom { transform: translateY(-6px) rotate(-45deg); }

/* ---- Dropdown menu ---- */

.nav-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  left: auto;

  margin-top: 8px;

  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);

  min-width: 250px;
  max-width: min(90vw, 420px);
  max-height: 60vh;
  overflow-y: auto;

  box-shadow: 0 16px 40px var(--shadow-dark);
  z-index: 1001;
}

.nav-center.is-open .nav-dropdown { display: block; }

.nav-dropdown ul { list-style: none; margin: 0; padding: 6px; }
.nav-dropdown li { margin: 0; }

.nav-folder-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: var(--touch);

  border: 0;
  border-radius: var(--radius-sm);
  background: none;

  padding: 10px 12px;

  color: var(--text);
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.9rem;
  text-align: left;

  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.nav-folder-toggle:hover,
.nav-folder-toggle:focus-visible {
  background: var(--shade-30);
  color: var(--ink);
  outline: none;
}

.nav-folder-chevron {
  flex-shrink: 0;
  color: var(--muted);
  transition: transform 0.2s ease;
}

.nav-folder-toggle[aria-expanded="true"] .nav-folder-chevron {
  transform: rotate(90deg);
}

.nav-dropdown .nav-folder-list {
  padding: 2px 0 2px 22px;
}

.nav-dropdown a {
  display: block;
  min-height: var(--touch);
  display: flex;
  align-items: center;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 400;
  text-decoration: none;
  font-size: 0.9rem;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.nav-dropdown a:hover,
.nav-dropdown a:focus-visible {
  background: var(--shade-30);
  color: var(--ink);
  text-decoration: none;
}

.nav-dropdown .nav-dropdown-empty {
  padding: 12px;
  opacity: 0.6;
  font-size: 0.85rem;
  text-align: center;
}

/* ---- Template search entry point (inside dropdown) ---- */

.nav-search-item {
  display: none;
  margin-bottom: 4px !important;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

html.is-template-view .nav-search-item { display: block; }

.nav-search-btn {
  width: 100%;
  min-height: var(--touch);
  display: flex;
  align-items: center;
  gap: 8px;

  border: 1px solid var(--border);
  border-radius: var(--radius-sm);

  background: var(--panel);
  color: var(--muted);

  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 700;

  padding: 8px 12px;
  cursor: pointer;
  text-align: left;

  transition: background-color var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.nav-search-btn .search-icon {
  width: 17px;
  height: 17px;
  fill: currentColor;
  flex-shrink: 0;
}

.nav-search-btn:hover,
.nav-search-btn:focus-visible {
  background: var(--panel-2);
  color: var(--ink);
  border-color: var(--border-strong);
  outline: none;
}

/* ================================================================
   TEMPLATE SEARCH MODAL
   ================================================================ */

.template-search-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 68px 12px 20px;
  background: rgba(10, 10, 12, 0.55);
  z-index: 2000;
}

.template-search-modal.is-open { display: flex; }

.template-search-panel {
  width: min(520px, 100%);
  background: var(--panel-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: 0 20px 50px var(--shadow-dark);
  padding: 10px;
}

.template-search-row {
  display: flex;
  align-items: stretch;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  overflow: hidden;
}

.template-search-icon {
  flex: 0 0 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel-2);
  border-right: 1px solid var(--border);
  color: var(--muted);
}

.template-search-icon .search-icon {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

#templateSearchInput {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 1rem;
  padding: 11px 10px;
}

.template-search-close {
  flex: 0 0 42px;
  min-height: var(--touch);
  border: 0;
  border-left: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

.template-search-close:hover,
.template-search-close:focus-visible {
  background: var(--shade-30);
  color: var(--ink);
  outline: none;
}

.template-search-navigation {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
}

.template-search-nav-btn {
  flex: 1;
  min-height: var(--touch);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 7px 10px;
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.template-search-nav-btn:hover:not(:disabled),
.template-search-nav-btn:focus-visible:not(:disabled) {
  background: var(--panel);
  color: var(--ink);
  border-color: var(--border-strong);
  outline: none;
}

.template-search-nav-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.template-search-status {
  flex: 0 0 auto;
  min-width: 55px;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  text-align: center;
}

.template-search-hit {
  background: var(--hit-bg);
  color: #1A1204;
  border-radius: 3px;
  text-shadow: none;
}

.template-search-hit-active {
  background: var(--cyan);
  color: #06222B;
  box-shadow: 0 0 0 2px var(--ink);
}

@media (max-width: 600px) {
  .template-search-modal { padding: 58px 8px 12px; }
  .template-search-panel { width: 100%; padding: 8px; }
  #templateSearchInput { font-size: 1rem; }
  .template-search-nav-btn { padding: 9px 8px; }
}

/* ================================================================
   FONT-SIZE CONTROLS
   ================================================================ */

.font-btn {
  background: none;
  border: 1px solid var(--border-strong);
  color: var(--muted);
  border-radius: var(--radius-sm);
  width: var(--touch);
  height: var(--touch);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition-fast), background-color var(--transition-fast), border-color var(--transition-fast);
}

.font-btn:hover,
.font-btn:focus-visible {
  background: var(--shade-30);
  color: var(--ink);
  border-color: var(--cyan);
  outline: none;
}

#fontDecBtn, #fontIncBtn { display: none; }
html.is-template-view #fontDecBtn,
html.is-template-view #fontIncBtn { display: flex; }

/* ================================================================
   FOOTER — dev controls, author card, geek-stats, ticker
   ================================================================ */

footer {
  flex: 0 0 auto;
  align-self: stretch;
  width: 100%;
  max-width: none;
  box-sizing: border-box;

  background-color: var(--panel);
  color: var(--muted);
  margin-top: 0;
  padding: 14px var(--page-pad) calc(14px + env(safe-area-inset-bottom));

  text-align: center;
  box-shadow: 0 -1px 0 var(--border);

  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  gap: 10px 20px;

  z-index: 9;
}

html.is-template-view footer {
  margin-top: 0;
  background-color: var(--panel);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='46.5' viewBox='0 0 80 93'%3E%3Cg fill-rule='evenodd'%3E%3Cg id='seed-of-life' fill='%230A0A0C' fill-opacity='0.12'%3E%3Cpath d='M6.8 93c0-5.7-1.2-11.7-3.2-17C9 84.3 25.4 93 34 93h12.8c6.2 0 22.7-6.9 29.5-16.7-1.9 5.3-3 11-3 16.7h1.2c0-4.7 2.1-18.8 5.6-22v-2.4c-5.7-8.3-8.5-30.2 0-43.9V22c-3.6-4.9-5.6-16.1-5.6-22h-1.2c.1 5.6 1 11.2 2.9 16.6C70.1 9.1 56.5 0 46.7 0H34C23.6 0 10 9.2 3.8 16.8c1.9-5.4 3-11.1 3-16.8H5.6C5.5 7.7 3.7 15.3.1 22.1v2.3C7.7 38 7 56.4 0 68.5V71c3.7 6.7 5.6 14.4 5.6 22zM40 91.7c-7.4-12.8-7.3-31.1 0-44.1 8.1 13.9 6.6 33.2 0 44.1m-3.8-5.4c-7.3-8.8-17.6-14.8-28.9-16.6C18.6 68 29 62 36.3 53.2c-4.4 9-3.6 25.8-.1 33.1m7.7-33c7.4 8.7 17.7 14.7 29 16.4-11.3 1.8-21.7 7.7-28.9 16.6 1.9-5.4 2.9-10.9 2.9-16.6 0-5.5-1-11.3-3-16.4m-2.8 39c7.7-13.1 22.9-21.7 38-21.9-6.8 13.2-23.6 21.5-38 21.9M79 69c-15.1-.2-30.2-8.7-37.8-21.9 14.3 0 30.9 9.2 37.8 21.9m-2.7-6c-7.4-8.7-17.7-14.8-29-16.5 10.6-1.6 22.1-8 28.9-16.5-4.3 9.9-3.3 25.5.1 33M41.1 45.9c7.6-13.1 23-21.7 38-22-7.3 12.9-23.3 22-38 22m2.8-6c3.3-9 4.3-22.8 0-33 7.3 8.8 17.7 14.6 28.9 16.5-11.2 1.6-21.6 7.7-28.9 16.5M79 22.6c-15.1-.3-30.3-8.8-38-21.9 15.2.4 30.6 8.6 38 21.9M40 1.4c7.6 13.5 7.2 31.5 0 44-7.2-11.6-7.6-31.5 0-44m-3.8 38.3C29 31.1 18.7 25.1 7.6 23.3 18.7 21.4 29 15.5 36.2 6.8c-2 5.3-2.9 10.8-2.9 16.5-.1 5.5.8 11.3 2.9 16.4M39 .7c-7.5 13.1-22.9 21.7-37.9 22C9.2 9.4 23.6 1.1 39 .7m0 45.2c-15.5-.4-29.9-8.8-37.9-22 15.9.3 29.5 8.6 37.9 22M3.8 29.8c7.3 8.9 17.8 15.1 29.2 16.8-10.8 1.6-22.6 8.2-29.3 16.9 4-8.9 4.8-24 .1-33.7M39 47.1C31.4 60 16.2 68.8 1.2 69 9.1 55.9 23.6 47.5 39 47.1m-.1 45.2C24.3 92.2 8.5 83 1.2 70.4c15.3.4 29.9 8.6 37.7 21.9' /%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  padding-bottom: calc(30px + env(safe-area-inset-bottom));
}

footer nav { font-size: 0.85rem; line-height: 1.8; font-family: var(--font-sans); }
footer nav.left  { text-align: right; color: var(--muted); }
footer nav.right { text-align: left;  color: var(--muted); opacity: 0.8; }

html.is-template-view footer nav.left,
html.is-template-view footer nav.right { display: none; }

.footer-template-text,
.footer-home-text {
  grid-column: 1 / -1;
  width: 100%;
  box-sizing: border-box;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  line-height: 1.5;
  text-align: center;
}

.footer-home-text {
  display: block;
  color: var(--muted);
  overflow-wrap: anywhere;
  word-break: normal;
}

.footer-template-text {
  display: none;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  color: var(--muted-2);
  -webkit-mask-image: linear-gradient(to right, transparent, black 24px, black calc(100% - 24px), transparent);
  mask-image: linear-gradient(to right, transparent, black 24px, black calc(100% - 24px), transparent);
}

html.is-template-view .footer-template-text { display: block; }
html.is-template-view .footer-home-text     { display: none; }

.footer-marquee-track {
  display: inline-flex;
  white-space: nowrap;
}

.footer-marquee-track span { flex: 0 0 auto; padding-right: 60px; }
.footer-marquee-track span:not(:first-child) { display: none; }
.footer-marquee-track.marquee span { display: inline-block; }

.footer-marquee-track.marquee {
  animation: footer-marquee-loop var(--marquee-duration, 20s) linear infinite;
}

@keyframes footer-marquee-loop {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

@media (prefers-reduced-motion: reduce) {
  .footer-marquee-track.marquee { animation: none; }
}

#sitemapTrigger { display: inline-flex; }
html.is-template-view #sitemapTriggerTop { display: none; }

/* ---- Dev controls ---- */

.footer-dev-controls {
  display: none;
  grid-column: 1 / -1;
  width: 60%;
  margin: 12px auto 0 auto;
  box-sizing: border-box;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

html.is-template-view .footer-dev-controls { display: flex; }

@media (max-width: 520px) {
  html.is-template-view .footer-dev-controls { width: 100%; margin: 0; }
  html.is-template-view .footer-author { width: 95%; }
}

.footer-dev-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  flex-shrink: 0;
}

.footer-dev-icon svg { display: block; width: 32px; height: 32px; fill: currentColor; }

.footer-dev-btn { width: auto; min-width: 32px; padding: 0 7px; font-size: 0.65rem; letter-spacing: 0.03em; }
.footer-dev-brand { margin-left: 4px; }

/* ---- Author card ---- */

.footer-author {
  display: none;
  grid-column: 1 / -1;
  width: 60%;
  margin: 0 auto;
  box-sizing: border-box;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background-color: var(--panel-2);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='40' height='46.5' viewBox='0 0 80 93'%3E%3Cg fill-rule='evenodd'%3E%3Cg id='seed-of-life' fill='%230A0A0C' fill-opacity='0.12'%3E%3Cpath d='M6.8 93c0-5.7-1.2-11.7-3.2-17C9 84.3 25.4 93 34 93h12.8c6.2 0 22.7-6.9 29.5-16.7-1.9 5.3-3 11-3 16.7h1.2c0-4.7 2.1-18.8 5.6-22v-2.4c-5.7-8.3-8.5-30.2 0-43.9V22c-3.6-4.9-5.6-16.1-5.6-22h-1.2c.1 5.6 1 11.2 2.9 16.6C70.1 9.1 56.5 0 46.7 0H34C23.6 0 10 9.2 3.8 16.8c1.9-5.4 3-11.1 3-16.8H5.6C5.5 7.7 3.7 15.3.1 22.1v2.3C7.7 38 7 56.4 0 68.5V71c3.7 6.7 5.6 14.4 5.6 22zM40 91.7c-7.4-12.8-7.3-31.1 0-44.1 8.1 13.9 6.6 33.2 0 44.1m-3.8-5.4c-7.3-8.8-17.6-14.8-28.9-16.6C18.6 68 29 62 36.3 53.2c-4.4 9-3.6 25.8-.1 33.1m7.7-33c7.4 8.7 17.7 14.7 29 16.4-11.3 1.8-21.7 7.7-28.9 16.6 1.9-5.4 2.9-10.9 2.9-16.6 0-5.5-1-11.3-3-16.4m-2.8 39c7.7-13.1 22.9-21.7 38-21.9-6.8 13.2-23.6 21.5-38 21.9M79 69c-15.1-.2-30.2-8.7-37.8-21.9 14.3 0 30.9 9.2 37.8 21.9m-2.7-6c-7.4-8.7-17.7-14.8-29-16.5 10.6-1.6 22.1-8 28.9-16.5-4.3 9.9-3.3 25.5.1 33M41.1 45.9c7.6-13.1 23-21.7 38-22-7.3 12.9-23.3 22-38 22m2.8-6c3.3-9 4.3-22.8 0-33 7.3 8.8 17.7 14.6 28.9 16.5-11.2 1.6-21.6 7.7-28.9 16.5M79 22.6c-15.1-.3-30.3-8.8-38-21.9 15.2.4 30.6 8.6 38 21.9M40 1.4c7.6 13.5 7.2 31.5 0 44-7.2-11.6-7.6-31.5 0-44m-3.8 38.3C29 31.1 18.7 25.1 7.6 23.3 18.7 21.4 29 15.5 36.2 6.8c-2 5.3-2.9 10.8-2.9 16.5-.1 5.5.8 11.3 2.9 16.4M39 .7c-7.5 13.1-22.9 21.7-37.9 22C9.2 9.4 23.6 1.1 39 .7m0 45.2c-15.5-.4-29.9-8.8-37.9-22 15.9.3 29.5 8.6 37.9 22M3.8 29.8c7.3 8.9 17.8 15.1 29.2 16.8-10.8 1.6-22.6 8.2-29.3 16.9 4-8.9 4.8-24 .1-33.7M39 47.1C31.4 60 16.2 68.8 1.2 69 9.1 55.9 23.6 47.5 39 47.1m-.1 45.2C24.3 92.2 8.5 83 1.2 70.4c15.3.4 29.9 8.6 37.7 21.9' /%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

html.is-template-view .footer-author { display: flex; }

.footer-author-img {
  border: 2px solid var(--jade);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.footer-author-text { min-width: 0; flex: 1 1 auto; overflow-wrap: anywhere; }

.footer-author-heading {
  margin: 0;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 700;
  text-align: left;
}

.footer-author-body {
  padding-bottom: 6px;
  margin: 2px 0 0;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  line-height: 1.4;
  text-align: left;
}

@media (max-width: 600px) {
  .footer-author { align-items: flex-start; }
  .footer-author-img { margin-top: 6px; width: 40px; height: 40px; align-self: flex-start; }
  .footer-author-heading { font-size: 0.85rem; }
  .footer-author-body { font-size: 0.75rem; }
}

/* ---- Geek stats (reuses .footer-author shell) ---- */

.footer-author.geek-stats {
  display: none;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  padding: 16px 18px;
  background-color: var(--panel-2);
  border-radius: var(--radius-md);
}

html.is-template-view .footer-author.geek-stats { display: flex; margin: 28px auto; }

.geek-stats .footer-author-title {
  position: relative;
  margin: 0;
  padding-bottom: 8px;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0.02em;
}

.geek-stats .footer-author-title::after {
  content: "";
  display: block;
  width: 100%;
  height: 1px;
  margin-top: 8px;
  background: var(--border);
}

.geek-stats .footer-author-text {
  margin: 0;
  padding: 0;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  line-height: 1.7;
  text-align: left;
}

.geek-stats .stat-val {
  color: var(--peach);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 600px) {
  .footer-author.geek-stats { width: 92%; padding: 12px 14px; }
  .geek-stats .footer-author-title { font-size: 0.82rem; }
  .geek-stats .footer-author-text { font-size: 0.78rem; line-height: 1.65; }
}

/* ================================================================
   WELCOME VIEW / SEARCH
   ================================================================ */

#welcome-view { padding: 14px var(--page-pad) 30px; }

.search-wrap {
  position: relative;
  max-width: 520px;
  margin: 12px auto 14px;
}

.search-icon-wrap {
  position: absolute;
  left: 1px; top: 1px; bottom: 1px;
  width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border-right: 1px solid var(--border);
  border-radius: 9px 0 0 9px;
  color: var(--muted);
  pointer-events: none;
}

.search-icon { width: 18px; height: 18px; fill: currentColor; flex-shrink: 0; }

#searchInput {
  width: 100%;
  min-height: var(--touch);
  box-sizing: border-box;
  padding: 12px 40px 12px 56px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 1rem;
  transition: border-color var(--transition-fast);
}

#searchInput:focus {
  outline: none;
  border-color: var(--cyan);
}

.search-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

.search-clear:hover { color: var(--ink); background: var(--shade-30); }

.search-results { max-width: 520px; margin: 10px auto 0; }

/* ---- Reading queue: quiet, typography-led rows rather than cards ---- */

.search-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 10px;
  background-color: transparent;
  transition: border-color var(--transition-fast), background-color var(--transition-fast);
}

.search-group:last-child { margin-bottom: 0; }

.search-group:hover,
.search-group:focus-within {
  border-color: var(--border-strong);
  background-color: var(--shade-10);
}

.search-group.shade-a { background-color: var(--shade-10); }
.search-group.shade-b { background-color: transparent; }

.search-group-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.search-group-title {
  margin: 0;
  padding-left: 0;
  color: var(--muted);
  font-family: var(--font-serif);
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.3;

  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  white-space: nowrap;
  overflow: hidden;
}

.search-group-title::after {
  content: '';
  box-sizing: border-box;
  flex: 1 0 12px;
  margin-left: 8px;
  height: 0;
  border-bottom: 1px solid var(--ink);
  opacity: 0.4;
}

.search-group-open-btn {
  flex-shrink: 0;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 6px 12px;
  cursor: pointer;
  transition: background-color var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.search-group-open-btn:hover,
.search-group-open-btn:focus-visible {
  background: var(--cyan);
  color: #06222B;
  border-color: var(--cyan);
  outline: none;
}

.search-group-bullets {
  list-style: disk;
  color: var(--muted);
  font-family: var(--font-serif);
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 8px 0 0;
  padding-left: 0;
}

.search-group-bullets li {
  margin-bottom: 4px;
  opacity: 0.85;
  padding-left: 14px;
  position: relative;
}

.search-group-bullets li::before {
  content: "";
  position: absolute;
  left: 0;
  color: var(--jade);
  opacity: 0.7;
}

.search-group-bullets li:last-child { margin-bottom: 0; }

.search-group-bullets li::marker { color: var(--accent-green); }

.search-group-bullets b { color: var(--ink); font-weight: 700; opacity: 1; }

.search-group-note {
  color: var(--muted-2);
  font-size: 0.78rem;
  font-style: italic;
  line-height: 1.4;
  margin: 8px 0 0;
}

.search-sentinel { height: 1px; }

/* "Continuar leyendo" card: heading row, then presentation title + ABRIR */
.search-group-top + .search-group-top { margin-top: 8px; }

.search-group-current {
  flex: 1 1 auto;
  min-width: 0;
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere; /* long titles wrap; ABRIR stays on the right */
}

/* ---- Ribbons (Tabla de Contenido) and continue dot (nav menu) ---- */

.search-group-bullets li.has-ribbon { padding-right: 92px; }

.ribbon {
  position: absolute;
  top: 6px;
  right: 0;
  padding: 2px 8px 0px 16px;
  background: red;
  border-right: 3px solid var(--white);
  box-shadow: 0 8px 0 var(--shadow-dark);
  color: var(--white);
  font-family: var(--font-sans);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1.6;
  pointer-events: none;
  clip-path: polygon(15% 0, 100% 0, 100% 100%, 15% 100%, 2px 50%);
}

.ribbon-continuar {
  background: var(--white);
  color: var(--code-bg);
  clip-path: polygon(10% 0, 100% 0, 100% 100%, 10% 100%, 2px 50%);
  z-index: 2; /* over "NUEVO" when both belong to the same entry */
}

/* Corner ribbon: a plain rectangle rotated 45°, cropped by the parent */
.ribbon-diccionario {
  position: absolute;
  top: 23px;
  right: -37px;
  width: 140px;

  background: var(--jade);
  color: #06222B;

  font-family: var(--font-sans);
  text-align: center;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;

  padding: 2px 0;

  transform: rotate(45deg);

  box-shadow: 0 2px 8px var(--shadow-dark);
  z-index: 1;
}

.has-dot::after {
  content: "";
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  margin-left: auto;
  border-radius: 50%;
  background: var(--cyan);
}

html.is-template-view .has-dot::after { display: none; }

.search-empty { text-align: center; opacity: 0.6; padding: 20px; font-family: var(--font-sans); }

.default-img-wrap {
  display: block;
  width: 100%;
  max-width: 100%;
  margin: 24px 0 0;
  padding: 0;
  box-sizing: border-box;
  text-align: center;
}

/* ---- Welcome slideshow ---- */

.intro-thumb {
  width: 100%;
  max-width: 520px;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 20px 45px var(--shadow-dark);
}

.ken-burns-frame { position: relative; overflow: hidden; }

.ken-burns-frame .slide-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 1.2s ease-in-out;
}

.ken-burns-frame .slide-layer.slide-visible { opacity: 1; z-index: 1; }

.ken-burns-frame .slide-layer .slideshow {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.ken-burns {
  --kb-duration: 9s;
  --kb-scale: 1.15;
  --kb-origin: center;
  --kb-pan-x: 0%;
  --kb-pan-y: 0%;
  display: block;
  transform-origin: var(--kb-origin);
  will-change: transform;
  animation: wo-ken-burns var(--kb-duration) ease-in-out infinite alternate;
}

@keyframes wo-ken-burns {
  from { transform: scale(1) translate(0, 0); }
  to   { transform: scale(var(--kb-scale)) translate(var(--kb-pan-x), var(--kb-pan-y)); }
}

.ken-burns-frame.is-paused .ken-burns { animation-play-state: paused; }

@media (prefers-reduced-motion: reduce) {
  .ken-burns { animation: none; }
}

.slide-caption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 26%;
  background: linear-gradient(to top, rgba(10, 10, 12, 0.82), rgba(0, 0, 0, 0.45));
  border-top: 1px solid var(--border);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  text-align: left;
  padding: 12px 16px;
  box-sizing: border-box;
  transform: translateY(100%);
  transition: transform 0.8s ease-in-out;
  z-index: 2;
}

.slide-layer.slide-visible .slide-caption { transform: translateY(0%); }

.slide-caption-heading {
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 700;
  font-size: 1.4rem;
  margin-bottom: 4px;
  color: var(--ink);
}

.slide-caption-body {
  font-family: var(--font-sans);
  font-size: 1.10rem;
  color: var(--ink);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.slide-caption.slide-caption-empty { display: none; }

@media (max-width: 600px) {
  .slide-caption { height: 32%; }
  .slide-caption-heading { font-size: 1.05rem; }
  .slide-caption-body { font-size: 0.82rem; }
}

/* ================================================================
   ARTICLE / PRESENTATION CONTENT
   ================================================================ */

#content {
  flex: 1 0 auto;
  max-width: var(--reading-width);
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
  touch-action: manipulation;
  background: var(--bg);
  overflow-x: hidden; /* fallback for Safari < 16, which has no "clip" */
  overflow-x: clip;   /* clip at #content's edges without making it a scroll container */
  transition: transform 0.3s ease, opacity 0.3s ease;
  font-size: 17px; /* base — scaled live by #fontIncBtn/#fontDecBtn inline style */
}

#content-body {
  padding: 0 var(--page-pad) 40px;
}

#content p {
  color: var(--text);
  font-family: var(--font-serif);
  line-height: 1.75;
  text-align: left;
  text-indent: 1.3em;
  font-size: 1.1em;
  max-width: 100%;
  margin: 0 0 1.1em;
}

#content p.subtitle {
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 1.05em;
  font-style: italic;
  text-align: left;
  text-transform: none;
  padding: 2px 0 14px;
  margin: 0;
}

#content verse {
  display: block;
  box-sizing: border-box;
  width: fit-content;
  max-width: 100%;

  color: var(--ink);
  font-family: var(--font-serif);
  text-align: center;
  font-style: italic;
  font-size: 1.1em;
  font-weight: 400;
  line-height: 1.7;
  overflow-wrap: break-word;

  padding: 14px 28px;
  margin: 26px auto;
  border-left: 2px solid var(--jade);
  background: var(--shade-10);
}

#content verse strong,
#content verse b { color: var(--ink) !important; text-shadow: none !important; }

#content verse verse-ref {
  display: block;
  text-align: right;
  font-size: 0.82em;
  font-style: normal;
  color: var(--muted);
  margin-top: 10px;
}

@media (max-width: 520px) {
  #content verse { max-width: 100%; padding: 14px 18px; font-size: 1em; }
}

#content blockquote {
  color: var(--text);
  font-family: var(--font-serif);
  line-height: 1.75;
  font-size: 1.05em;
  text-align: left;

  padding: 4px 10px 4px 18px;
  margin: 1.4em 0;
  background-color: var(--panel-2);
  border-left: 3px solid var(--muted);
}

#content blockquote b,
#content blockquote strong { font-style: normal; color: var(--ink); }
#content blockquote i,
#content blockquote em { font-style: italic; color: var(--ink); }

#content definition-card {
  display: block;
  position: relative;
  overflow: hidden;
  margin: 28px auto;
  max-width: 100%;
  padding: 18px 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--jade);
  border-radius: var(--radius-sm);
}

#content definition-card .ribbon {
  position: absolute;
  top: 23px;
  right: -37px;
  width: 140px;

  background: var(--jade);
  color: #06222B;

  font-family: var(--font-sans);
  text-align: center;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;

  padding: 2px 0;

  transform: rotate(45deg);

  box-shadow: 0 2px 8px var(--shadow-dark);
  z-index: 1;
}

#content definition-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}

#content definition-term {
  display: block;
  color: var(--ink);
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 700;
  font-size: 1.3em;
  letter-spacing: -0.01em;
}

#content definition-pos {
  display: block;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.78em;
  text-transform: lowercase;
}

#content definition-pronunciation {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.88em;
}

#content definition-meaning {
  display: block;
  margin: 14px 0 0;
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 1em;
  line-height: 1.7;
}

#content definition-foot {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

#content definition-script {
  color: var(--muted);
  font-family: var(--font-serif);
  font-size: 1em;
}

@media (max-width: 520px) {
  #content definition-card { padding: 14px 16px; }
  #content definition-term { font-size: 1.15em; }
}

#content blockquote blockquote-ref {
  display: block;
  text-align: right;
  margin-top: 8px;
  font-size: 0.82em;
  font-style: normal;
  color: var(--muted);
}

/* ---- Headings — quiet editorial hierarchy ---- */

#content h1, #content h2,
#content h3, #content h4,
#content h5 {
  font-family: var(--font-sans);
  text-align: left;
  font-weight: 700;
  max-width: 100%;
  margin-top: 2.1em !important;
  margin-bottom: 0.6em;
  line-height: 1.3;
}

#content h1 {
  position: relative;
  color: var(--ink);
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 1.85em;
  text-transform: none;
  letter-spacing: 0;
  text-align: center;
  padding: 10px 10px 10px 20px;
  z-index: 2;
}

#content h1::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -32px;
  right: -32px;
  background-color: var(--panel);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  opacity: 0.9;
  z-index: -1;
}

#content h2 {
  position: relative;
  color: var(--violet);
  font-size: 1.4em;
  text-align: center;
  padding: 10px 10px 10px 20px;
  z-index: 2;
}

#content h2::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -32px;
  right: -32px;
  background-color: var(--panel);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  opacity: 0.9;
  z-index: -1;
}

#content h3 {
  position: relative;
  color: var(--jade);
  font-size: 1.15em;
  text-align: center;
  padding: 10px 10px 10px 20px;
  z-index: 2;
}

#content h3::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -32px;
  right: -32px;
  background-color: var(--panel);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  opacity: 0.9;
  z-index: -1;
}

#content h4 {
  position: relative;
  color: var(--peach);
  font-size: 1.05em;
  text-align: center;
  padding: 10px 10px 10px 20px;
  z-index: 2;
}

#content h4::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -32px;
  right: -32px;
  background-color: var(--panel);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  opacity: 0.9;
  z-index: -1;
}

#content h5 {
  position: relative;
  color: var(--cyan);
  font-size: 0.95em;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 10px 10px 20px;
  z-index: 2;
}

#content h5::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -32px;
  right: -32px;
  background-color: var(--panel);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  opacity: 0.9;
  z-index: -1;
}

#content h1 strong, #content h1 b,
#content h1 em, #content h1 i,
#content h2 strong, #content h2 b,
#content h2 em, #content h2 i,
#content h3 strong, #content h3 b,
#content h3 em, #content h3 i,
#content h4 strong, #content h4 b,
#content h4 em, #content h4 i,
#content h5 strong, #content h5 b,
#content h5 em, #content h5 i {
  color: currentColor;
}

#content-body > h1,
#content-body > h2,
#content-body > h3,
#content-body > h4,
#content-body > h5 {
  margin-left: 0;
  margin-right: 0;
  max-width: none;
}

/* The Geek Stats card above the content provides the only separation:
   nothing inside #content-body may add space above its first element. */
#content-body > :first-child { margin-top: 0 !important; }

#content-body > h1.accordion-toggle,
#content-body > h2.accordion-toggle,
#content-body > h3.accordion-toggle,
#content-body > h4.accordion-toggle,
#content-body > h5.accordion-toggle {
  padding-left: 0;
  padding-right: 0;
}

/* ================================================================
   ACCORDION HEADINGS
   ================================================================ */

#content .accordion-toggle {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 24px;
  align-items: start;
  column-gap: 8px;
  cursor: pointer;
  user-select: none;
  min-height: var(--touch);
}

#content .accordion-title { min-width: 0; text-align: center; }

#content .accordion-dots,
#content .accordion-chevron {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  display: inline-flex;
  align-items: flex-start;
  justify-content: center;
  color: var(--muted);
}

#content .accordion-dots  { grid-column: 1; grid-row: 1; }
#content .accordion-title { grid-column: 2; grid-row: 1; }

#content .accordion-preview {
  display: block;
  margin: 8px 0 0 0;
  padding: 0 30px 10px 30px;
  min-width: 0;
  height: 1.4em;
  overflow: hidden;

  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 1em;
  font-weight: normal;
  line-height: 1.4;
  text-align: left;
  white-space: nowrap;

  opacity: 0;
  pointer-events: none;

  -webkit-mask-image: linear-gradient(to right, black 0, black 55%, transparent 100%);
  mask-image: linear-gradient(to right, black 0, black 55%, transparent 100%);

  transition: opacity 0.25s ease;
}

#content .accordion-toggle[aria-expanded="false"] + .accordion-preview { opacity: 0.8; }
#content .accordion-toggle[aria-expanded="true"]  + .accordion-preview { display: none; }

#content .accordion-chevron { grid-column: 3; grid-row: 1; margin-left: 0; vertical-align: top; }

#content .accordion-toggle:hover .accordion-title,
#content .accordion-toggle:focus-visible .accordion-title { color: var(--cyan); }

#content .accordion-toggle:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.accordion-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 8px;
  vertical-align: middle;
  color: currentColor;
  transition: transform 0.25s ease;
}

#content .accordion-toggle[aria-expanded="false"] .accordion-chevron { transform: rotate(-90deg); }

.accordion-body {
  display: grid;
  grid-template-rows: 1fr;
  opacity: 1;
  transition: grid-template-rows 0.35s ease, opacity 0.3s ease;
}

.accordion-body.is-collapsed { grid-template-rows: 0fr; opacity: 0; }

.accordion-body-inner {
  overflow: hidden;
  min-height: 0;
  /* Extend the clip box to #content's edges (#content-body pads 32px, 16px on
     mobile) so items sliding in from the side emerge from the page column's
     edge, not from the text column's. */
  margin: 0 -32px;
  padding: 0 32px;
}

@media (max-width: 600px) {
  .accordion-body-inner { margin: 0 -16px; padding: 0 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .accordion-body, .accordion-chevron { transition: none; }
}

/* ---- Inline elements ---- */

#content a { color: var(--ink); text-decoration: none; transition: color var(--transition-fast); }
#content a:hover,
#content a:focus-visible {
  color: var(--ink);
  text-decoration: none; 
  filter: 
    drop-shadow(1px 0 0 var(--accent)) 
    drop-shadow(-1px 0 0 var(--cyan));
}

#content ul, #content ol {
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 1.05em;
  line-height: 1.7;
  margin: 1em 0 1.4em;
  padding-left: 1.4em;
}

#content ul li, #content ol li { padding-left: 6px; margin-bottom: 8px; }

#content ul li::marker { color: var(--jade); }
#content ol li::marker { color: var(--peach); font-weight: bold; }

#content figure.presentation-image {
  display: block;
  margin: 28px auto;
  max-width: 100%;
  text-align: center;
  color: var(--muted);
}

#content figure.presentation-image img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  cursor: zoom-in;
}

#content figure.presentation-image figcaption {
  color: var(--muted);
  font-family: var(--font-serif);
  font-size: 0.9em;
  font-style: italic;
  text-align: center;
  padding: 10px 10px 0;
}

#content hr {
  width: 100%;
  margin: 2em 0;
  height: 1px;
  border: 0;
  background: linear-gradient(90deg, transparent, var(--peach), transparent);
}

#content strong, #content b { font-weight: 700; color: var(--ink); }
#content em, #content i { font-style: italic; color: var(--ink); }

/* ---- Inline highlight ( |text| ) ---- */

#content .content-highlight {
  color: var(--ink);
  background: rgba(231, 149, 62, 0.12);
  padding: 0 2px;
  border-radius: 3px;
}

/* ================================================================
   CODE BLOCKS
   ================================================================ */

#content pre {
  display: block;
  position: relative;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;

  margin: 24px 0;
  padding: 16px;

  overflow-x: auto;
  overflow-y: hidden;

  background: var(--code-bg);
  color: var(--ink);

  border: 1px solid var(--border);
  border-left: 3px solid var(--cyan);
  border-radius: var(--radius-sm);

  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.9em;
  line-height: 1.18;

  white-space: pre;
  tab-size: 4;
  -webkit-overflow-scrolling: touch;
}

#content pre code {
  display: block;
  margin: 0; padding: 0;
  background: transparent;
  border: 0;
  color: inherit;
  font: inherit;
  line-height: inherit;
  white-space: inherit;
}

@media (hover: hover) and (pointer: fine) {
  #content pre { cursor: grab; }
  #content pre:active { cursor: grabbing; }
  #content pre.is-dragging { cursor: grabbing; user-select: none; }
  #content[contenteditable] pre { cursor: text; }
  #content[contenteditable] pre:active { cursor: text; }
}

.pre-toolbar {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 6px;
  z-index: 2;
}

.pre-copy-btn, .pre-view-btn {
  width: 30px;
  height: 30px;
  padding: 0;
  opacity: 0.6;
  background: var(--bg);
  border-color: var(--border);
}

.pre-copy-btn:hover, .pre-view-btn:hover,
.pre-copy-btn:focus-visible, .pre-view-btn:focus-visible {
  opacity: 1;
  background: var(--panel);
  border-color: var(--cyan);
  color: var(--ink);
  outline: none;
}

/* ================================================================
   TABLES (in case markdown source produces them)
   ================================================================ */

#content table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-family: var(--font-sans);
  font-size: 0.9em;
}

#content th, #content td {
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  text-align: left;
  color: var(--text);
}

#content th {
  color: var(--muted);
  font-weight: 700;
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* ================================================================
   MOBILE ADJUSTMENTS
   ================================================================ */

@media (max-width: 600px) {

  body { padding-left: 0; }

  #top-nav { padding: 6px 12px; gap: 6px; }

  .back-btn span { display: none; }

  .nav-menu-btn { font-size: 0.9rem; max-width: 46vw; }

  #content-body { padding: 0 16px 34px; }

  #content p { font-size: 1.05em; }

  #content p.subtitle { font-size: 1em; }

  #content verse { font-size: 1em; line-height: 1.6; }

  #content blockquote { padding-left: 14px; font-size: 1em; }

  #content ul, #content ol { padding-left: 1.2em; font-size: 1em; }

  #content figure.presentation-image { margin: 20px auto; }

  #content figure.presentation-image figcaption { font-size: 0.85em; }
}

@media (min-width: 601px) {
  #content-body { padding-left: 32px; padding-right: 32px; }
}

/* ================================================================
   CODE LIGHTBOX
   ================================================================ */

.code-lightbox {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 950;
}

.code-lightbox.is-open { display: block; }

html.code-lightbox-active,
html.code-lightbox-active body { overflow: hidden; }

.code-lightbox-overlay {
  position: absolute;
  inset: 0;
  background: var(--lighbox-surround);
  cursor: pointer;
}

.code-lightbox-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;

  width: min(96vw, 1200px);
  height: calc(100vh - 100px);
  height: calc(100dvh - 100px);
  margin: 68px auto 20px;

  background: var(--code-bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: 0 24px 60px var(--shadow-dark);

  overflow: hidden;
}

.code-lightbox-toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 8px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

.code-lightbox-title {
  margin-right: auto;
  color: var(--jade);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
}

.code-lightbox-copy-btn, .code-lightbox-edit-btn, .code-lightbox-font-btn { width: 32px; height: 32px; }

.code-lightbox-close {
  width: 32px; height: 32px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: none;
  color: var(--muted);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

.code-lightbox-close:hover, .code-lightbox-close:focus-visible {
  background: var(--shade-30);
  color: var(--ink);
  border-color: var(--cyan);
  outline: none;
}

.code-lightbox-body {
  flex: 1 1 auto;
  overflow: hidden;
  padding: 16px;
  user-select: none;
}

.code-lightbox-body:not(.is-edit-mode) { touch-action: none; }

.code-lightbox-body.is-edit-mode {
  overflow: scroll;
  user-select: text;
  cursor: text;
}

@media (hover: hover) and (pointer: fine) {
  .code-lightbox-body:not(.is-edit-mode) { cursor: grab; }
  .code-lightbox-body.is-dragging { cursor: grabbing; }
}

.code-lightbox-body pre {
  margin: 0; padding: 0; border: 0; box-shadow: none;
  background: transparent;
  line-height: 1.18;
  font-size: 0.9em;
  white-space: pre;
}

.code-lightbox-body code {
  background: transparent;
  border: 0;
  color: var(--text);
  font: inherit;
  white-space: inherit;
}

.code-lightbox.is-image-mode .code-lightbox-body {
  display: flex;
  align-items: center;
  justify-content: center;
}

.code-lightbox-image {
  display: block;
  max-width: 100%;
  max-height: 100%;
  margin: 0 auto;
  object-fit: contain;
}

.code-lightbox-image[hidden] { display: none; }

.code-lightbox.is-image-mode .lightbox-code-only { display: none; }

@media (max-width: 600px) {
  .code-lightbox-panel {
    width: 100vw;
    height: calc(100vh - 76px);
    height: calc(100dvh - 76px);
    margin: 58px auto 18px;
    border-radius: 0;
  }
}

/* ================================================================
   GLOSSARY TOOLTIPS  ( word((definition)) )
   ================================================================ */

#content .gloss-trigger {
  cursor: pointer;
  border-radius: 3px;
  background-color: rgba(167, 139, 250, 0.10);
  text-decoration: none;
}

#content .gloss-trigger:hover,
#content .gloss-trigger:focus-visible {
  text-decoration-color: var(--jade);
  outline: none;
}

#content .gloss-trigger.gloss-search-target {
  box-shadow: 0 0 0 2px var(--ink), 0 0 0 4px var(--cyan);
}

.gloss-tooltip-content {
  position: fixed;
  z-index: 960;

  max-width: min(320px, calc(100vw - 24px));
  padding: 12px 16px;
  box-sizing: border-box;

  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: 0 16px 40px var(--shadow-dark);

  font-family: var(--font-sans);
  font-size: 0.85rem;
  line-height: 1.5;
  text-align: left;
  text-indent: 0;

  visibility: hidden;
  opacity: 0;
  pointer-events: none;

  transition: opacity 0.2s ease, visibility 0s linear 0.2s;
}

.gloss-tooltip-content.is-open {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transition: opacity 0.2s ease, visibility 0s linear 0s;
}

.gloss-tooltip-content img {
  display: block;
  max-width: 50%;
  max-height: 35vh;
  margin: 0 auto;
  border-radius: var(--radius-sm);
}

.gloss-tooltip-content .tooltip-image { display: block; margin: 0; text-align: center; }

.gloss-tooltip-content .tooltip-caption {
  display: block;
  font-size: 0.8em;
  font-style: italic;
  margin-top: 4px;
  opacity: 0.85;
}

.gloss-tooltip-content a { color: var(--cyan); text-decoration: underline; }

.gloss-tooltip-content::after {
  content: "";
  position: absolute;
  left: var(--gloss-arrow-left, 50%);
  width: 11px; height: 11px;
  background: var(--panel-2);
  transform: translateX(-50%) rotate(45deg);
}

.gloss-tooltip-content:not(.is-below)::after {
  bottom: -6px;
  border-right: 1px solid var(--border-strong);
  border-bottom: 1px solid var(--border-strong);
}

.gloss-tooltip-content.is-below::after {
  top: -6px;
  border-left: 1px solid var(--border-strong);
  border-top: 1px solid var(--border-strong);
}

/* ================================================================
   ACCESSIBILITY
   ================================================================ */

:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ================================================================
   SCROLLBARS
   ================================================================ */

html {
  scrollbar-width: thin;
  scrollbar-color: var(--muted) transparent;
}
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--muted);
  border-radius: 999px;
  transition: background-color var(--transition-fast);
}
*::-webkit-scrollbar-thumb:hover { background: var(--cyan); }

/* ================================================================
   PWA UPDATE BANNER + OFFLINE IMAGES
   (re-uses .search-group / .search-group-open-btn / .search-group-note)
   ================================================================ */

/* Footer update button — sits left of "Tabla de Contenido" */
.footer-home-text.footer-home-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* the mobile rule ".back-btn span { display:none }" is meant for the nav
   "Inicio" label only — this label must stay visible */
#swUpdateBtn .sw-update-label { display: inline; }

/* spinner takes the icon's place while working */
#swUpdateBtn .sw-update-spinner {
  display: none;
  flex-shrink: 0;
  box-sizing: border-box;
  width: 16px;
  height: 16px;
  margin: 2px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--jade);
  border-radius: 50%;
  animation: sw-update-spin 0.75s linear infinite;
}

#swUpdateBtn.is-working .sw-update-spinner { display: inline-block; }
#swUpdateBtn.is-working .sw-update-icon { display: none; }

#swUpdateBtn.is-ready {
  color: var(--jade);
  border-color: var(--jade);
}

#swUpdateBtn:disabled {
  opacity: 0.7;
  cursor: default;
  pointer-events: none;
}

@keyframes sw-update-spin {
  to { transform: rotate(360deg); }
}

#content figure.presentation-image.is-offline img { display: none; }

.img-offline-note {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 28px 16px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--panel-2);
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: 0.85em;
  font-style: italic;
  text-align: center;
}

.img-offline-icon {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  fill: var(--white);
}

.img-offline-icon-slash {
  fill: var(--accent);
}