/* =========================================================
   parlox.cc — editorial directory
   Fraunces (display) + DM Sans (body) on warm cream/black
   with paper grain. Hover-accordion (desktop) and wallet
   stack (mobile). Brand-as-accent per panel.
   ========================================================= */

/* ---------- Modern reset ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
* {
  margin: 0;
  padding: 0;
}
html,
body {
  height: 100%;
}
ul {
  list-style: none;
}
a {
  color: inherit;
  text-decoration: none;
}
button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}
svg,
img {
  display: block;
  max-width: 100%;
}

/* ---------- Tokens ---------- */
:root {
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-8: 3rem;

  --fs-xs: clamp(0.7rem, 0.66rem + 0.18vw, 0.8rem);
  --fs-sm: clamp(0.875rem, 0.83rem + 0.2vw, 1rem);
  --fs-base: clamp(1rem, 0.96rem + 0.2vw, 1.0625rem);
  --fs-md: clamp(1.0625rem, 1rem + 0.4vw, 1.25rem);
  --fs-lg: clamp(1.5rem, 1.2rem + 1.4vw, 2rem);
  --fs-xl: clamp(2rem, 1.5rem + 2.4vw, 3rem);

  /* Warm paper palette */
  --bg: #f5f1e8;
  --bg-elev: #fbf8f1;
  --bg-elev-2: #ece6d8;
  --fg: #1a1612;
  --fg-muted: #6e6258;
  --fg-soft: #a39c8e;
  --line: rgba(26, 22, 18, 0.10);
  --line-strong: rgba(26, 22, 18, 0.22);
  --focus: #b85228;
  --heart: #c1413f;

  --grain-blend: multiply;
  --grain-opacity: 0.08;

  --radius: 14px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --dur-fast: 180ms;
  --dur: 380ms;

  --container: 84rem;
  --topbar-h: clamp(60px, 7vh, 76px);
  --bottombar-h: clamp(48px, 6vh, 56px);

  /* Mobile wallet stack tab height */
  --tab-h-mobile: 68px;

  --font-display: "Fraunces", "Times New Roman", Georgia, serif;
  --font-body: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
}

/* OS-driven dark when user hasn't picked. */
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #0e0c0a;
    --bg-elev: #181613;
    --bg-elev-2: #211e19;
    --fg: #f0e9da;
    --fg-muted: #a39c8e;
    --fg-soft: #6e6258;
    --line: rgba(240, 233, 218, 0.10);
    --line-strong: rgba(240, 233, 218, 0.22);
    --focus: #f4a261;
    --heart: #f4828c;
    --grain-blend: screen;
    --grain-opacity: 0.05;
  }
}
:root[data-theme="dark"] {
  --bg: #0e0c0a;
  --bg-elev: #181613;
  --bg-elev-2: #211e19;
  --fg: #f0e9da;
  --fg-muted: #a39c8e;
  --fg-soft: #6e6258;
  --line: rgba(240, 233, 218, 0.10);
  --line-strong: rgba(240, 233, 218, 0.22);
  --focus: #f4a261;
  --heart: #f4828c;
  --grain-blend: screen;
  --grain-opacity: 0.05;
}
:root[data-theme="light"] {
  --bg: #f5f1e8;
  --bg-elev: #fbf8f1;
  --bg-elev-2: #ece6d8;
  --fg: #1a1612;
  --fg-muted: #6e6258;
  --fg-soft: #a39c8e;
  --line: rgba(26, 22, 18, 0.10);
  --line-strong: rgba(26, 22, 18, 0.22);
  --focus: #b85228;
  --heart: #c1413f;
  --grain-blend: multiply;
  --grain-opacity: 0.08;
}

/* ---------- Brand colors per panel ----------
   Declared as CSS variables on the data-area selector so the inline
   <li style=...> isn't needed. See project_brand_colors memory for
   the reasoning behind each hex. */
.panel[data-area="tech"]  { --brand: #E3262E; }
.panel[data-area="theo"]  { --brand: #FF5C00; }
.panel[data-area="edu"]   { --brand: #A73B74; }
.panel[data-area="found"] { --brand: #006D77; }
.panel[data-area="min"]   { --brand: #1E3A5F; }

/* Iglesia Local dark-mode lift. The primary navy #1E3A5F is too dark
   to read on warm-black (contrast ~1.8); we lift it to a sapphire that
   keeps the same hue (~213°) so the brand still reads as navy, just
   brighter. Note: this is a parlox.cc render variant only — the
   church's actual brand color stays unchanged in their own assets. */
:root[data-theme="dark"] .panel[data-area="min"] {
  --brand: #4670A5;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] .panel[data-area="min"] {
    --brand: #4670A5;
  }
}

/* ---------- Globals ---------- */
body {
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: 1.55;
  background: var(--bg);
  color: var(--fg);
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  position: relative;
  overflow-x: hidden;
}

/* Paper grain — fixed, mix-blended over the whole page so it doesn't
   shift on scroll. SVG fractalNoise inlined as data URI to avoid an
   extra request. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: var(--grain-opacity);
  mix-blend-mode: var(--grain-blend);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.92' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0.7 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 6px;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: var(--space-4);
  background: var(--bg-elev);
  color: var(--fg);
  padding: var(--space-2) var(--space-4);
  border-radius: 6px;
  z-index: 1000;
  transition: top var(--dur) var(--ease);
}
.skip-link:focus {
  top: var(--space-2);
}

/* ---------- Topbar ---------- */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 0 var(--space-5);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
}
@media (min-width: 768px) {
  .topbar {
    padding: 0 var(--space-6);
  }
}

.mark {
  display: inline-flex;
  align-items: baseline;
  gap: 0.4em;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: var(--fs-md);
  font-variation-settings: "opsz" 14;
  letter-spacing: -0.015em;
}
.mark-at {
  font-style: italic;
  color: var(--focus);
  font-weight: 600;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  padding: 0 var(--space-4);
  border-radius: 999px;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: var(--fs-sm);
  transition: background var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.btn:hover {
  background: var(--bg-elev-2);
}
.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--fg);
  color: var(--bg);
  gap: 0.5rem;
}
.btn-primary:hover {
  background: var(--fg);
  filter: brightness(1.12);
}
.wa-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.btn-icon {
  width: 44px;
  padding: 0;
}
.btn-icon .icon {
  width: 20px;
  height: 20px;
}

.icon-sun,
.icon-moon,
.icon-auto {
  display: none;
}
:root[data-theme="auto"] .icon-auto {
  display: block;
}
:root[data-theme="light"] .icon-moon {
  display: block;
}
:root[data-theme="dark"] .icon-sun {
  display: block;
}

.btn-lang {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--fs-xs);
  letter-spacing: 0.08em;
  min-width: 44px;
  padding: 0 var(--space-3);
}

/* ---------- Page layout ---------- */
.page {
  flex: 1 0 auto;
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: var(--space-6) var(--space-5) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  min-height: 0;
  position: relative;
  z-index: 2;
}
@media (min-width: 768px) {
  .page {
    padding: var(--space-8) var(--space-6) var(--space-6);
    gap: var(--space-8);
  }
}

/* ---------- Hero ---------- */
.hero {
  display: grid;
  gap: var(--space-3);
  animation: rise 700ms var(--ease) both;
}
.hero-name {
  font-family: var(--font-display);
  font-weight: 500;
  font-variation-settings: "opsz" 144, "SOFT" 30;
  font-size: var(--fs-xl);
  line-height: 1.04;
  letter-spacing: -0.025em;
  color: var(--fg);
  /* Stay on a single line when the viewport gives us room; the clamp
     on font-size already shrinks gracefully at narrow widths, so we
     let it wrap there naturally. */
  text-wrap: balance;
}
.hero-tagline {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-variation-settings: "opsz" 36;
  font-size: var(--fs-md);
  color: var(--fg-muted);
  line-height: 1.4;
  max-width: 38ch;
}
.hero-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  font-size: var(--fs-xs);
  color: var(--fg-muted);
  margin-top: var(--space-2);
}
.hero-handle {
  font-family: var(--font-body);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.hero-handle .at {
  font-family: var(--font-display);
  font-style: italic;
  color: var(--focus);
}
.hero-sep {
  color: var(--fg-soft);
}
.hero-email {
  color: var(--fg-muted);
  transition: color var(--dur-fast) var(--ease);
}
.hero-email:hover,
.hero-email:focus-visible {
  color: var(--fg);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ---------- Directory ---------- */
.directory {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
}

/* ====================================================
   MOBILE — Wallet / business-card stack (default)
   ====================================================
   Each card is absolutely positioned and full-width.
   Default position for card[i]: translateY(i * tabH).
   Only the top --tab-h of each card peeks above the next.
   When card[k] is active:
     cards [0..k-1] keep i * tabH       (their tabs)
     card[k]        keeps k * tabH      (its tab + content fills)
     cards [k+1..n] shift down by --content-h
   --content-h is computed in JS from the container size.
   ==================================================== */
.panels {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: calc(5 * var(--tab-h-mobile) + 280px);
}

.panel {
  position: absolute;
  inset: 0;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-top: 3px solid var(--brand, var(--fg));
  border-radius: 14px 14px 0 0;
  box-shadow: 0 -10px 30px -16px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  transform: translateY(var(--y, 0px));
  transition: transform var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease);
  will-change: transform;
  /* Cards fade in with a subtle stagger on first paint. */
  animation: card-in 520ms var(--ease) both;
}
.panel:nth-child(1) { animation-delay: 80ms; }
.panel:nth-child(2) { animation-delay: 140ms; }
.panel:nth-child(3) { animation-delay: 200ms; }
.panel:nth-child(4) { animation-delay: 260ms; }
.panel:nth-child(5) { animation-delay: 320ms; }

.panel.is-active {
  box-shadow: 0 -16px 40px -16px rgba(0, 0, 0, 0.28);
}

.panel-tab {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: var(--tab-h-mobile);
  padding: 0 var(--space-5);
  text-align: left;
  color: inherit;
}
.panel-tab-left {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
}
.panel-area {
  font-family: var(--font-body);
  font-size: var(--fs-base);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand, var(--fg));
}
.panel-status {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: var(--fs-xs);
  color: var(--brand, var(--fg-muted));
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--brand) 38%, transparent);
  background: color-mix(in srgb, var(--brand) 8%, transparent);
  white-space: nowrap;
}

.panel-content {
  position: absolute;
  top: var(--tab-h-mobile);
  left: 0;
  right: 0;
  bottom: 0;
  padding: var(--space-3) var(--space-5) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity var(--dur) var(--ease),
    transform var(--dur) var(--ease);
}
.panel.is-active .panel-content {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
  transition-delay: 100ms;
}

.panel-kicker {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-variation-settings: "opsz" 24;
  font-size: var(--fs-sm);
  color: var(--brand, var(--fg-muted));
  max-width: 32ch;
}
.panel-brand {
  font-family: var(--font-display);
  font-weight: 600;
  font-variation-settings: "opsz" 96, "SOFT" 50;
  font-size: var(--fs-lg);
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--fg);
}
.panel-slogan {
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  color: var(--fg-muted);
  max-width: 38ch;
  flex: 1;
}
.panel-link {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--brand, var(--fg));
  padding: var(--space-2) 0;
  min-height: 44px;
  position: relative;
}
.panel-link::after {
  content: "";
  position: absolute;
  left: 0;
  right: 100%;
  bottom: 6px;
  height: 1px;
  background: currentColor;
  transition: right var(--dur) var(--ease);
}
.panel-link:hover::after {
  right: 28px;
}
.panel-link .arrow {
  transition: transform var(--dur) var(--ease);
}
.panel-link:hover .arrow {
  transform: translateX(3px);
}

/* ====================================================
   DESKTOP — Horizontal accordion (≥ 768px)
   ====================================================
   - Panels are flex children, not absolute.
   - Default flex-grow: 1 → equal fifths.
   - Hovered/focused panel: flex-grow: 4 → 4/(4+1+1+1+1)=50%.
   - Vertical area name shows when collapsed.
   - On expand: vertical text fades, content fades in
     bottom-aligned with kicker/brand/slogan/link stack.
   ==================================================== */
@media (min-width: 768px) {
  .directory {
    height: 100%;
  }

  .panels {
    flex-direction: row;
    display: flex;
    width: 100%;
    height: 100%;
    min-height: clamp(380px, 58dvh, 640px);
    gap: var(--space-3);
  }

  .panel {
    position: relative;
    inset: auto;
    flex: 1 1 0;
    min-width: 0;
    height: 100%;
    border: 1px solid var(--line);
    border-top: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: none;
    background: var(--bg-elev);
    transform: none;
    transition: flex-grow var(--dur) var(--ease),
      border-color var(--dur) var(--ease),
      box-shadow var(--dur) var(--ease);
  }

  /* Brand color as a 4px bottom band — quiet identification per panel. */
  .panel::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 4px;
    background: var(--brand, transparent);
    transition: height var(--dur) var(--ease);
    border-radius: 0 0 var(--radius) var(--radius);
  }

  .panel-tab {
    position: absolute;
    inset: 0;
    height: 100%;
    flex-direction: column;
    justify-content: space-between;
    align-items: stretch;
    padding: var(--space-5) var(--space-4);
    background: transparent;
  }
  .panel-tab-left {
    flex-direction: column;
    align-items: center;
    gap: var(--space-4);
    flex: 1;
    justify-content: center;
  }
  .panel-area {
    /* Vertical text — reads bottom→top, conventional. */
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    font-size: clamp(1.5rem, 1.1rem + 1.4vw, 2.25rem);
    font-weight: 700;
    letter-spacing: 0.14em;
    text-align: center;
    transition: opacity var(--dur) var(--ease),
      transform var(--dur) var(--ease);
  }
  .panel-status {
    align-self: center;
    margin-top: auto;
  }

  .panel-content {
    position: absolute;
    inset: 0;
    padding: var(--space-6);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: var(--space-3);
    opacity: 0;
    transform: none;
    pointer-events: none;
    transition: opacity var(--dur) var(--ease);
  }
  .panel-slogan {
    flex: none;
    max-width: 30ch;
  }

  /* Expand on hover, keyboard focus, or programmatic activation. */
  .panel:hover,
  .panel:focus-within,
  .panel.is-active {
    flex-grow: 4;
    border-color: var(--line-strong);
    box-shadow: 0 12px 36px -18px
      color-mix(in srgb, var(--brand) 60%, rgba(0, 0, 0, 0.4));
  }
  .panel:hover::after,
  .panel:focus-within::after,
  .panel.is-active::after {
    height: 6px;
  }
  .panel:hover .panel-area,
  .panel:focus-within .panel-area,
  .panel.is-active .panel-area {
    opacity: 0;
    transform: rotate(180deg) translateY(-12px);
  }
  .panel:hover .panel-status,
  .panel:focus-within .panel-status,
  .panel.is-active .panel-status {
    opacity: 0;
    transform: translateY(8px);
  }
  .panel-status {
    transition: opacity var(--dur) var(--ease),
      transform var(--dur) var(--ease);
  }
  .panel:hover .panel-content,
  .panel:focus-within .panel-content,
  .panel.is-active .panel-content {
    opacity: 1;
    pointer-events: auto;
    transition-delay: 140ms;
  }
}

/* ---------- Bottombar ---------- */
.bottombar {
  min-height: var(--bottombar-h);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-xs);
  color: var(--fg-muted);
  border-top: 1px solid var(--line);
  background: var(--bg);
  padding: var(--space-3) var(--space-4);
  text-align: center;
  position: relative;
  z-index: 2;
}
.bottombar-text {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35em 0.6em;
  line-height: 1.5;
}
.bb-segment {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
  white-space: nowrap;
}
.bb-sep {
  color: var(--fg-soft);
}
.bb-link {
  color: var(--fg);
  font-weight: 500;
  text-decoration: none;
  border-bottom: 1px dashed var(--line-strong);
  padding-bottom: 1px;
  transition: color var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease);
}
.bb-link:hover,
.bb-link:focus-visible {
  color: var(--focus);
  border-color: currentColor;
}
.footer-heart {
  width: 0.95em;
  height: 0.95em;
  color: var(--heart);
  flex-shrink: 0;
  transform: translateY(-1px);
}

/* On phone widths the inline footer wraps awkwardly with the middle
   dots stranded at line edges. Stack the segments and hide the
   separators — reads like a colophon. */
@media (max-width: 599.98px) {
  .bottombar {
    min-height: 0;
    padding-top: var(--space-4);
    padding-bottom: var(--space-4);
  }
  .bottombar-text {
    flex-direction: column;
    gap: var(--space-2);
  }
  .bb-sep {
    display: none;
  }
}

/* ---------- Motion ---------- */
@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(calc(var(--y, 0px) + 12px));
  }
  to {
    opacity: 1;
    transform: translateY(var(--y, 0px));
  }
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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