/* ══════════════════════════════════════════════════════════════════════
   CONTRA LA RESISTENCIA — page stylesheet
   Companion to index.html / app.js.
════════════════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ══════════════════════════════════════════════════════════════════════
   SHARED BRAND TOKENS — verbatim from the design system
════════════════════════════════════════════════════════════════════ */
:root {
  --brand-accent:      #7f77dd;
  --brand-accent-dim:  #534ab7;
  --brand-danger:      #e24b4a;
  --brand-danger-dim:  #c43a39;
  --brand-success:     #1d9e75;

  --hdr-bg:       #0e0f11;
  --hdr-surface:  #16181c;
  --hdr-col:      #1d1f25;
  --hdr-hover:    #24272f;
  --hdr-border:   rgba(255,255,255,0.07);
  --hdr-border2:  rgba(255,255,255,0.14);
  --hdr-text:     #e8e6f0;
  --hdr-muted:    #9896a8;
  --hdr-dim:      #5c5a6b;
  --hdr-accent:   var(--brand-accent);
  --hdr-accent-s: rgba(127,119,221,0.15);
  --hdr-danger:   var(--brand-danger);
  --hdr-height:   56px;

  --dot: rgba(255,255,255,0.045); /* faint drafting-grid texture */
}
html[data-app-theme="light"] {
  --brand-accent:      #6c64cc;
  --brand-accent-dim:  #4e47a0;
  --brand-danger:      #d93535;
  --brand-danger-dim:  #b82f2f;
  --brand-success:     #1a8c68;

  --hdr-bg:       #f4f3f8;
  --hdr-surface:  #ffffff;
  --hdr-col:      #f9f8fc;
  --hdr-hover:    #f0eef8;
  --hdr-border:   rgba(0,0,0,0.08);
  --hdr-border2:  rgba(0,0,0,0.15);
  --hdr-text:     #1a1828;
  --hdr-muted:    #5a5870;
  --hdr-dim:      #9896a8;
  --hdr-accent:   var(--brand-accent);
  --hdr-accent-s: rgba(108,100,204,0.12);
  --hdr-danger:   var(--brand-danger);

  --dot: rgba(20,16,60,0.07);
}

/* ══════════════════════════════════════════════════════════════════════
   PAGE BASE
════════════════════════════════════════════════════════════════════ */
html { scroll-behavior: smooth; }
body {
  min-height: 100vh;
  display: flex; flex-direction: column;
  background: var(--hdr-bg);
  background-image: radial-gradient(var(--dot) 1px, transparent 1.4px);
  background-size: 26px 26px;
  color: var(--hdr-muted);
  font-family: 'Inter', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
::selection { background: var(--brand-accent); color: #fff; }
:focus-visible { outline: 2px solid var(--brand-accent); outline-offset: 2px; border-radius: 4px; }

/* ══════════════════════════════════════════════════════════════════════
   TOP BAR — back · brand · language · theme
════════════════════════════════════════════════════════════════════ */
.app-topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--hdr-height);
  background: rgba(22,24,28,0.82);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--hdr-border);
  display: flex; align-items: center; gap: 10px;
  padding: 0 16px; flex-shrink: 0;
  font-family: 'Inter', system-ui, sans-serif;
}
html[data-app-theme="light"] .app-topbar { background: rgba(255,255,255,0.82); }

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mark {
  width: 22px; height: 22px; border-radius: 7px;
  background: var(--brand-accent); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.mark svg { width: 15px; height: 15px; stroke: #fff; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.brand-name {
  font-size: 13px; font-weight: 600; color: var(--hdr-text); letter-spacing: 0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.app-header-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* ── Switcher + dropdown (verbatim behaviour from the system) ── */
.app-switcher { position: relative; }
.app-switcher-btn {
  display: flex; align-items: center; gap: 7px;
  height: 32px; padding: 0 10px 0 8px;
  border-radius: 10px;
  background: var(--hdr-col); border: 0.5px solid var(--hdr-border);
  cursor: pointer; color: var(--hdr-text); font-size: 13px; font-weight: 500;
  font-family: 'Inter', system-ui, sans-serif;
  transition: background .12s, border-color .12s;
}
.app-switcher-btn:hover { background: var(--hdr-hover); border-color: var(--hdr-border2); }
.app-switcher-btn .btn-icon { width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.app-switcher-btn .btn-icon svg { color: var(--hdr-dim); }
.app-switcher-btn span { font-size: 13px; font-weight: 500; }
.app-switcher-btn .app-chevron { font-size: 14px; color: var(--hdr-dim); margin-left: 2px; display: flex; transition: transform .18s; }
.app-switcher-btn.open .app-chevron { transform: rotate(180deg); }

.app-switcher-dd {
  display: none; position: absolute; top: calc(100% + 6px);
  left: auto; right: 0;
  min-width: 210px; background: var(--hdr-surface);
  border: 0.5px solid var(--hdr-border2); border-radius: 14px;
  padding: 6px; z-index: 200; box-shadow: 0 8px 32px rgba(0,0,0,.4);
}
.app-switcher-dd.open { display: block; animation: appDdIn .14s ease; }
@keyframes appDdIn { from{opacity:0;transform:translateY(-4px)} to{opacity:1;transform:translateY(0)} }
.app-dd-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 10px; cursor: pointer;
  font-size: 13px; color: var(--hdr-muted); transition: background .1s, color .1s;
}
.app-dd-item:hover { background: var(--hdr-hover); color: var(--hdr-text); }
.app-dd-item.active { background: var(--hdr-accent-s); color: var(--hdr-accent); }
.app-dd-icon { width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; color: var(--hdr-dim); }
.app-dd-item.active .app-dd-icon { color: var(--hdr-accent); }
.app-dd-text { flex: 1; }
.app-dd-title { font-weight: 500; font-size: 13px; }
.app-dd-badge { font-size: 10px; padding: 1px 6px; border-radius: 20px; background: var(--hdr-col); color: var(--hdr-dim); font-weight: 500; flex-shrink: 0; }
.app-dd-item.active .app-dd-badge { background: var(--hdr-accent-s); color: var(--hdr-accent); }

/* ── Ghost toolbar buttons (back + theme toggle) ── */
.app-hbtn {
  display: flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: 8px;
  font-size: 12.5px; font-weight: 500; cursor: pointer;
  border: 1px solid var(--hdr-border2); background: var(--hdr-col); color: var(--hdr-muted);
  font-family: 'Inter', system-ui, sans-serif; transition: background .12s, color .12s;
}
.app-hbtn:hover { background: var(--hdr-hover); color: var(--hdr-text); }
.app-hbtn.icon-only { width: 32px; padding: 0; justify-content: center; flex-shrink: 0; }

/* ══════════════════════════════════════════════════════════════════════
   CONTENT — one editorial column
════════════════════════════════════════════════════════════════════ */
#content {
  flex: 1;
  width: min(720px, 100%);
  margin: 0 auto;
  padding: clamp(64px, 10vh, 108px) 28px 0;
  transition: opacity .2s ease, transform .2s ease;
}
#content.swapping { opacity: 0; transform: translateY(8px); }

.headline {
  margin: 0 0 40px;
  font-family: 'Fraunces', serif;
  font-optical-sizing: auto;
  font-size: clamp(2.5rem, 6.3vw, 4.3rem);
  font-weight: 520;
  line-height: 1.07;
  letter-spacing: -0.018em;
  color: var(--hdr-text);
  max-width: 17ch;
}
.hl {
  font-style: italic;
  color: var(--brand-accent);
  position: relative;
  display: inline-block;
  padding: 0 .05em .2em;
  margin: 0 -.05em -.2em;
}
/* ── Squiggle reveal — clip-path sweep, NOT dash math ────────────────
     The stroke is never manipulated: the always-fully-painted SVG is
     unveiled left→right by a clip-path inset animation whose FINAL
     STATE IS UNCLIPPED. When it ends, the line is simply a normal,
     complete stroke — it cannot end partially drawn. */
.squiggle {
  position: absolute; left: .05em; bottom: .04em;
  width: calc(100% - .1em); height: .13em;
  overflow: visible;
  clip-path: inset(-40% 102% -40% 0);
  animation: unveil .7s cubic-bezier(.55,.1,.3,1) forwards;
}
@keyframes unveil {
  from { clip-path: inset(-40% 102% -40% 0); }
  to   { clip-path: inset(-40% -10% -40% -10%); }
}
.squiggle path {
  fill: none; stroke: var(--brand-accent);
  stroke-width: 3; stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

/* Masked word-rise for the headline */
.w-mask { display: inline-block; overflow: hidden; vertical-align: bottom; padding-bottom: .22em; margin-bottom: -.22em; }
.js .w-inner { display: inline-block; transform: translateY(115%); animation: rise .75s cubic-bezier(.19,.8,.22,1) forwards; }
@keyframes rise { to { transform: translateY(0); } }

/* Staged entrance for everything below the fold-line */
.js .reveal { opacity: 0; animation: fadeUp .7s cubic-bezier(.2,.7,.25,1) forwards; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.r-cta-top { animation-delay: .48s; }
.r-lede    { animation-delay: .60s; }
.r-b1      { animation-delay: .72s; }
.r-b2      { animation-delay: .84s; }
.r-b3      { animation-delay: .96s; }
.r-meta    { animation-delay: 1.08s; }
.r-cta     { animation-delay: 1.20s; }

.lede {
  font-size: 18.5px; line-height: 1.7;
  color: var(--hdr-text); opacity: .94;
  max-width: 56ch;
}
.block {
  display: grid; grid-template-columns: 52px 1fr;
  gap: 4px 18px; align-items: start;
  padding: 22px 0;
  border-top: 1px solid var(--hdr-border);
}
.idx {
  display: flex; align-items: center; gap: 8px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .12em;
  color: var(--brand-accent); padding-top: 5px;
}
.dash { display: block; width: 14px; height: 1px; background: var(--brand-accent); opacity: .55; transition: width .25s ease, opacity .25s ease; }
.block:hover .dash { width: 26px; opacity: 1; }
.b-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 15.5px; font-weight: 600;
  color: var(--hdr-text); margin-bottom: 8px;
}
.b-ico { display: flex; color: var(--brand-accent); flex-shrink: 0; }
.block p { font-size: 15px; line-height: 1.8; }

/* Subtitle line — centered */
.meta {
  margin-top: 4px; padding-top: 20px;
  border-top: 1px solid var(--hdr-border);
  font-size: 11.5px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--hdr-dim);
  text-align: center;
}

/* ══════════════════════════════════════════════════════════════════════
   CTA — one link, two identical buttons: top (under the title) + bottom,
   both centered.
════════════════════════════════════════════════════════════════════ */
.cta-row {
  display: flex; justify-content: center;
  margin-top: 44px;
}
.cta-row.top { margin: 0 0 40px; }
.cta {
  display: inline-flex; align-items: center; gap: 10px;
  height: 50px; padding: 0 26px; border-radius: 10px;
  background: var(--brand-accent); color: #fff; text-decoration: none;
  font-size: 14px; font-weight: 600; letter-spacing: .01em;
  transition: background .15s ease, transform .15s ease;
}
.cta svg { transition: transform .18s ease; }
.cta:hover { background: var(--brand-accent-dim); transform: translateY(-1px); }
.cta:hover svg { transform: translateX(3px); }
.cta:active { transform: translateY(0); }

/* ══════════════════════════════════════════════════════════════════════
   FOOTER — resistor pinned left, copyright dead-center
════════════════════════════════════════════════════════════════════ */
.footer {
  width: min(720px, 100%);
  margin: 88px auto 0;
  padding: 20px 28px 44px;
  border-top: 1px solid var(--hdr-border);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  font-size: 12.5px; color: var(--hdr-dim);
}
.res { grid-column: 1; justify-self: start; flex-shrink: 0; opacity: .85; }
.footer-copy { grid-column: 2; justify-self: center; }

@media (max-width: 520px) {
  .block { grid-template-columns: 40px 1fr; }
  .lede { font-size: 17px; }
  .brand-name { max-width: 40vw; }
}

/* Respect users who prefer stillness. Note: .squiggle MUST get
   clip-path: none here — the global animation kill would otherwise
   freeze it at its hidden "from" clip and hide the line forever. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .js .reveal { opacity: 1; }
  .js .w-inner { transform: none; }
  .squiggle { clip-path: none !important; }
}