/* Page structure of mockup A «Folha de Programa»: side rail, main column,
 * section rhythm, inner-page head, RG band, footer. Values from the mockup;
 * inner-page head, breadcrumbs and footer columns are new, in its language. */

/* ── rail (≥1024: fixed column; <1024: sheet) ─────────────────────────── */
.topbar { display: none; }
.rail {
  position: fixed; inset: 0 auto 0 0; width: var(--rail); z-index: var(--z-rail);
  background: var(--color-surface); border-right: 1px solid var(--color-border);
  display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain;
}
.brand { display: flex; gap: 12px; align-items: center; text-decoration: none; padding: 28px 24px 22px; border-bottom: 1px solid var(--color-border); color: var(--color-text); }
.brand .oct { --s: 46px; font-size: 11px; letter-spacing: .02em; }
.brand__txt { display: flex; flex-direction: column; line-height: 1; }
.brand__l1 { font-weight: 700; font-size: 17px; letter-spacing: .06em; }
.brand__l2 { font-family: var(--font-mono); font-size: 12px; letter-spacing: .28em; margin-top: 6px; color: var(--color-brand); font-weight: 600; }
.brand:hover .brand__l1 { color: var(--color-brand); }

.nav { padding: 0 12px 16px; flex: 1; }
.nav__group { padding-top: 14px; }
.nav__label {
  display: flex; justify-content: space-between; margin: 0 0 4px; padding: 0 12px 6px;
  font-family: var(--font-mono); font-size: var(--fs-mono-xs); letter-spacing: .14em; text-transform: uppercase;
  color: var(--color-muted); border-bottom: 1px solid var(--color-border);
}
.nav ul { margin: 0; padding: 0; }
.nav a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 32px; padding: 4px 12px; text-decoration: none; font-size: 15px; color: var(--color-text);
  border-left: 2px solid transparent;
  transition: background-color var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast);
}
.nav a:hover { background: var(--color-bg); color: var(--color-brand); }
.nav a[aria-current="page"] { border-left-color: var(--color-brand); font-weight: 600; color: var(--color-brand); background: var(--color-brand-tint); }
.nav a[aria-current="page"]::after { content: ""; width: 6px; height: 6px; background: var(--color-accent); clip-path: var(--oct); }
.nav .ext { font-family: var(--font-mono); font-size: 11px; color: var(--color-muted); font-weight: 400; }

.rail__rg { margin: 0 12px 16px; border: 1px solid var(--color-text); padding: 14px 14px 12px; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; align-items: center; }
.rail__rg .oct { --s: 44px; font-size: 15px; background: var(--color-text); grid-row: span 2; }
.rail__rg strong { font-size: 14px; line-height: 1.25; }
.rail__rg a { font-size: 14px; font-weight: 600; color: var(--color-brand); text-underline-offset: 3px; display: inline-flex; min-height: 24px; align-items: center; }
.rail__rg a:hover { color: var(--color-brand-deep); }
.rail__close { display: none; }
.scrim { display: none; }

/* ── main column ──────────────────────────────────────────────────────── */
main, .rg, .foot { margin-left: var(--rail); min-width: 0; }
.wrap { max-width: var(--container); padding: 0 var(--container-pad); margin: 0 auto 0 0; }

.secnum { display: inline-flex; align-items: center; gap: 10px; font-family: var(--font-mono); font-size: 13px; letter-spacing: .12em; color: var(--color-muted); text-transform: uppercase; }
.secnum b { font-weight: 600; color: var(--color-text); font-size: 13px; border: 1px solid var(--color-text); padding: 2px 6px; letter-spacing: .04em; }
.secnum::after { content: ""; width: 28px; height: 2px; background: var(--color-accent); }
.kick { font-family: var(--font-mono); font-size: var(--fs-mono-xs); letter-spacing: .14em; text-transform: uppercase; color: var(--color-muted); margin: 0; }

.hero__meta { display: flex; flex-wrap: wrap; gap: 6px 22px; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--color-text); padding-bottom: 12px; }
.hero__meta .mono { font-size: 13px; color: var(--color-muted); letter-spacing: .04em; }

/* sections */
.sec { padding: var(--space-9) 0 0; }
.sec--tight { padding-top: var(--space-8); }
.sec__head { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 24px 56px; align-items: end; margin-bottom: 32px; }
.sec__head h2 { font-size: var(--fs-h2); letter-spacing: var(--ls-display); line-height: var(--lh-tight); margin: 14px 0 0; font-weight: 600; }
.sec__head h2 span { display: block; color: var(--color-muted); font-weight: 500; }
.sec__aside { font-size: 15px; color: var(--color-muted); }
.sec__aside p { margin: 0 0 12px; }

/* inner page head (added, in the hero's language) */
.phero { padding: 56px 0 0; }
.crumbs ol { display: flex; flex-wrap: wrap; gap: 4px 0; margin: 0 0 18px; padding: 0; font-family: var(--font-mono); font-size: 12px; letter-spacing: .06em; color: var(--color-muted); }
.crumbs li { display: inline-flex; align-items: center; }
.crumbs li + li::before { content: "/"; margin: 0 10px; color: var(--color-border); }
.crumbs a { color: var(--color-muted); text-underline-offset: 3px; position: relative; }
.crumbs a:hover { color: var(--color-brand); }
.crumbs a::after { content: ""; position: absolute; inset: 50% 0 auto 0; translate: 0 -50%; height: 100%; min-height: 24px; }
.crumbs [aria-current] { color: var(--color-text); }
.phero__grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 420px); gap: 24px 48px; align-items: end; margin-top: 34px; }
.phero__h1 { font-size: var(--fs-page-h1); line-height: .94; letter-spacing: -.05em; font-weight: 600; margin: 0; }
.phero__h1 span { display: block; color: var(--color-muted); font-weight: 500; }
.phero__lead { margin: 0 0 12px; color: var(--color-muted); font-size: var(--fs-lead); }
.phero__lead strong { color: var(--color-text); font-weight: 600; }
.phero + .sec { padding-top: var(--space-7); }

/* prose (legal, guide, history) */
.prose { max-width: 70ch; font-size: 17px; line-height: 1.65; }
.prose h2 { font-size: var(--fs-h3); letter-spacing: -.03em; line-height: 1.15; font-weight: 600; margin: 2.2em 0 .6em; }
.prose h3 { font-size: 19px; font-weight: 600; margin: 1.6em 0 .4em; }
.prose p, .prose ul, .prose ol { margin: 0 0 1em; }
.prose ul { list-style: none; padding: 0; }
.prose ul li { position: relative; padding-left: 22px; margin-bottom: .4em; }
.prose ul li::before { content: ""; position: absolute; left: 2px; top: .62em; width: 8px; height: 8px; background: var(--color-brand); clip-path: var(--oct); }
.prose ol { padding-left: 1.4em; }
.prose a { color: var(--color-brand); text-underline-offset: 3px; }
.prose strong { font-weight: 600; }

/* ── RG band ──────────────────────────────────────────────────────────── */
.rg { margin-top: var(--space-9); background: var(--color-brand); color: var(--color-on-brand); }
.rg__in { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 24px 36px; align-items: center; padding-top: 40px; padding-bottom: 40px; }
.rg .oct { --s: 96px; font-size: 28px; }
.rg p { margin: 0; }
.rg__t { font-size: clamp(1.3rem, 1rem + 1vw, 1.75rem); font-weight: 600; letter-spacing: -.03em; line-height: 1.15; }
.rg__s { margin-top: 8px !important; color: var(--color-on-brand-muted); max-width: 62ch; }
.rg .btn { border-color: #fff; color: #fff; background: transparent; }
.rg .btn:hover { background: #fff; color: var(--color-brand); }

/* ── footer ───────────────────────────────────────────────────────────── */
.foot { padding-top: 40px; padding-bottom: 40px; font-size: 14px; color: var(--color-muted); }
.foot__top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px 24px; padding-bottom: 20px; border-bottom: 1px solid var(--color-text); }
.brand--foot { padding: 0; border: 0; }
.brand--foot .oct { --s: 40px; font-size: 10px; }
.foot__tag { font-size: 12px; letter-spacing: .06em; margin: 0; }
.foot__cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px 40px; padding: 24px 0; border-bottom: 1px solid var(--color-border); }
.foot__h { font-family: var(--font-mono); font-size: 11px; font-weight: 500; letter-spacing: .14em; text-transform: uppercase; color: var(--color-muted); margin: 0 0 10px; }
.foot__col ul { margin: 0; padding: 0; display: grid; gap: 2px; }
.foot__col a { display: inline-flex; min-height: 28px; align-items: center; color: var(--color-text); text-decoration: none; font-size: 15px; transition: color var(--dur-fast); }
.foot__col a:hover { color: var(--color-brand); text-decoration: underline; text-underline-offset: 3px; }
.foot__data { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px 40px; padding: 24px 0; }
.foot__data p { margin: 0 0 4px; }
.foot__data b { color: var(--color-text); font-weight: 600; }
.foot__data a { color: var(--color-text); text-underline-offset: 3px; overflow-wrap: anywhere; }
.foot__data a:hover { color: var(--color-brand); }
.foot__legal { display: flex; flex-wrap: wrap; gap: 6px 18px; justify-content: space-between; padding-top: 12px; border-top: 1px solid var(--color-border); font-family: var(--font-mono); font-size: 12px; }

/* ── back to top ──────────────────────────────────────────────────────── */
.to-top {
  position: fixed; right: 20px; bottom: 20px; z-index: var(--z-topbar);
  width: 48px; height: 48px; display: grid; place-items: center; border: 0;
  background: var(--color-text); color: #fff; clip-path: var(--oct);
  transition: background-color var(--dur-fast), transform var(--dur-fast);
}
.to-top:hover { background: var(--color-brand); transform: translateY(-2px); }
.to-top .ico { width: 20px; height: 20px; }

/* ── responsive ───────────────────────────────────────────────────────── */
@media (max-width: 1279px) {
  :root { --container-pad: 40px; }
}
/* rail present but narrow window: the page head stacks (H1 over lead) before words collide */
@media (max-width: 1180px) {
  .phero__grid { grid-template-columns: 1fr; }
}
@media (max-width: 1023px) {
  main, .rg, .foot { margin-left: 0; }
  /* the header wrapper is as tall as the topbar, so it is the header that sticks */
  .site-header { position: sticky; top: 0; z-index: var(--z-topbar); }
  .topbar {
    display: flex;
    justify-content: space-between; align-items: center; gap: 12px;
    background: var(--color-surface); border-bottom: 1px solid var(--color-border); padding: 8px 16px;
  }
  .topbar .brand { padding: 0; border: 0; }
  .topbar .brand .oct { --s: 38px; font-size: 9.5px; }
  .topbar .brand__l1 { font-size: 15px; }
  .topbar .brand__l2 { font-size: 11px; margin-top: 4px; }
  .menu-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border: 1px solid var(--color-text); background: var(--color-surface); font-weight: 600; transition: background-color var(--dur-fast), color var(--dur-fast); }
  .menu-btn:hover { background: var(--color-text); color: #fff; }
  .rail {
    width: min(100%, 420px); border-right: 1px solid var(--color-text); z-index: var(--z-rail-open);
    transform: translateX(-100%); visibility: hidden;
    transition: transform var(--dur-slow) var(--ease), visibility 0s linear var(--dur-slow);
  }
  .rail.is-open { transform: none; visibility: visible; transition: transform var(--dur-slow) var(--ease); }
  .rail__close { display: inline-flex; position: absolute; top: 22px; right: 16px; align-items: center; justify-content: center; width: 44px; height: 44px; border: 1px solid var(--color-text); background: var(--color-surface); }
  .rail__close:hover { background: var(--color-text); color: #fff; }
  .rail .brand { padding-right: 72px; }
  .nav a { min-height: 44px; font-size: 16px; }
  .scrim { display: block; position: fixed; inset: 0; background: var(--color-scrim); z-index: var(--z-scrim); opacity: 0; visibility: hidden; transition: opacity var(--dur-slow); }
  .scrim.is-on { opacity: 1; visibility: visible; }
  .phero { padding-top: 32px; }
}
@media (max-width: 899px) {
  .sec__head, .phero__grid { grid-template-columns: 1fr; }
  .foot__cols { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1279px) { .foot__data { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 759px) {
  :root { --container-pad: 16px; }
  .hero__meta { flex-direction: column; align-items: flex-start; }
  .sec { padding-top: 80px; }
  .phero__grid { margin-top: 24px; }
  .rg__in { grid-template-columns: auto 1fr; padding-top: 32px; padding-bottom: 32px; }
  .rg .oct { --s: 64px; font-size: 19px; }
  .rg .btn { grid-column: 1 / -1; }
  .foot__cols, .foot__data { grid-template-columns: 1fr; }
  .to-top { right: 12px; bottom: 12px; }
}
@media (max-width: 389px) {
  .topbar .brand__l2 { letter-spacing: .18em; }
}

/* Phones: the trail stays on one line, so the swap from the fallback face to Geist Mono
   cannot re-wrap it and push the page head down (CLS). The current page repeats the H1:
   on phones it is kept for screen readers only; the crumb before it may shorten. */
@media (max-width: 759px) {
  .crumbs ol { flex-wrap: nowrap; white-space: nowrap; overflow: hidden; }
  .crumbs li { flex: none; }
  .crumbs li:nth-last-child(2) { flex: 0 1 auto; min-width: 0; }
  .crumbs li:nth-last-child(2) > a, .crumbs li:nth-last-child(2) > span { display: block; overflow: hidden; text-overflow: ellipsis; line-height: 24px; }
  .crumbs li:last-child:not(:first-child),
  .crumbs li:last-child:not(:first-child) > span { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
}

