/* ---------- Top bar ---------- */
.topbar { background: var(--bar); color: var(--bar-text); font-size: 13px; }
.topbar .container { display: flex; align-items: center; justify-content: space-between; gap: 16px; height: 38px; }
.topbar__msg { display: flex; align-items: center; gap: 10px; opacity: .92; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; animation: blink 2.4s ease-in-out infinite; }
.topbar__links { display: flex; align-items: center; gap: 4px; }
.topbar__links a, .topbar__links button { padding: 6px 10px; border-radius: 8px; opacity: .85; transition: opacity .15s, background .15s; display: inline-flex; align-items: center; gap: 6px; }
.topbar svg { width: 15px; height: 15px; flex: none; }
.topbar__links a, .topbar__links button { white-space: nowrap; }
.topbar__links a:hover, .topbar__links button:hover { opacity: 1; background: rgba(255, 255, 255, .1); }
@keyframes blink { 50% { opacity: .35; } }

/* ---------- Masthead ---------- */
.masthead { position: sticky; top: 0; z-index: 60; background: color-mix(in srgb, var(--paper) 90%, transparent); backdrop-filter: blur(14px); border-bottom: 2px solid var(--stroke); }
.masthead .container { display: flex; align-items: center; gap: 28px; height: var(--header-h); }

.logo { display: inline-flex; align-items: center; gap: 12px; font-family: var(--font-display); font-size: 27px; font-weight: 700; letter-spacing: -0.04em; color: var(--ink); }
.logo__mark { width: 42px; height: 42px; flex: none; }
.logo b { color: var(--accent-text); font-weight: 700; }

.nav { display: flex; align-items: center; gap: 2px; margin-left: 6px; }
.nav__link { position: relative; padding: 10px 14px; font-family: var(--font-display); font-weight: 600; font-size: 16px; color: var(--ink); border-radius: 12px; display: inline-flex; align-items: center; gap: 6px; transition: background .15s; }
.nav__link:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); }
.nav__link[aria-current="page"]::after { content: ""; position: absolute; left: 14px; right: 14px; bottom: 3px; height: 4px; border-radius: 4px; background: var(--accent); }
.nav__link svg { width: 14px; height: 14px; transition: transform .2s; }
.nav__item { position: relative; }
.nav__item.is-open > .nav__link svg { transform: rotate(180deg); }

.masthead__right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.searchbtn { display: inline-flex; align-items: center; gap: 10px; height: 44px; padding: 0 14px; border: 2px solid var(--stroke); border-radius: 999px; background: var(--card); color: var(--muted); font-size: 15px; min-width: 190px; transition: transform .15s, box-shadow .15s; }
.searchbtn:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--shadow-c); }
.searchbtn svg { width: 18px; height: 18px; color: var(--ink); }
.searchbtn kbd { margin-left: auto; font: 600 12px var(--font-display); padding: 2px 8px; border: 1.5px solid var(--line); border-radius: 6px; color: var(--muted); }
.iconbtn { display: none; width: 44px; height: 44px; align-items: center; justify-content: center; border: 2px solid var(--stroke); border-radius: 14px; background: var(--card); color: var(--ink); }
.iconbtn svg { width: 20px; height: 20px; }

/* Mega menu */
.mega { position: absolute; top: calc(100% + 14px); left: -80px; width: 640px; padding: 16px; display: none; grid-template-columns: repeat(2, 1fr); gap: 12px; background: var(--card); border: 2px solid var(--stroke); border-radius: var(--radius); box-shadow: 7px 7px 0 var(--shadow-c); }
.nav__item.is-open .mega { display: grid; animation: pop .18s ease-out; }
.mega a { display: flex; gap: 12px; padding: 14px; border: 2px solid var(--stroke); border-radius: var(--radius-sm); transition: transform .15s, box-shadow .15s; }
.mega a:hover { transform: translate(-2px, -2px); box-shadow: 4px 4px 0 var(--shadow-c); }
.mega__ico { flex: none; width: 46px; height: 56px; display: grid; place-items: center; border: 2px solid var(--stroke); border-radius: 12px; font: 700 20px var(--font-display); color: #12150f; }
.mega strong { display: block; font: 700 17px var(--font-display); color: var(--ink); }
.mega small { display: block; margin-top: 2px; font-size: 13px; line-height: 1.4; color: var(--body); opacity: .85; }
.mega .count { margin-left: auto; align-self: flex-start; font: 700 12px var(--font-display); padding: 2px 8px; border-radius: 999px; background: var(--ink); color: var(--paper); }
@keyframes pop { from { opacity: 0; transform: translateY(-6px); } }

/* Mobile menu */
.drawer { position: fixed; inset: 0; z-index: 90; display: none; background: var(--paper); overflow-y: auto; padding: 18px 24px 40px; }
.drawer.is-open { display: block; animation: pop .2s ease-out; }
.drawer__top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.drawer a.drawer__link { display: block; padding: 14px 0; font: 700 28px var(--font-display); color: var(--ink); border-bottom: 2px solid var(--line); letter-spacing: -0.03em; }
.drawer h4 { margin: 26px 0 10px; font: 600 13px var(--font-display); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.drawer__topics { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Search overlay ---------- */
.overlay { position: fixed; inset: 0; z-index: 120; display: none; align-items: flex-start; justify-content: center; padding: 12vh 16px 16px; background: rgba(12, 10, 8, .55); backdrop-filter: blur(3px); }
.overlay.is-open { display: flex; }
.search { width: 100%; max-width: 640px; background: var(--card); border: 2px solid var(--stroke); border-radius: var(--radius); box-shadow: 8px 8px 0 var(--shadow-c); overflow: hidden; animation: pop .18s ease-out; }
.search__field { display: flex; align-items: center; gap: 12px; padding: 0 18px; border-bottom: 2px solid var(--stroke); }
.search__field svg { width: 22px; height: 22px; color: var(--ink); flex: none; }
.search__field input { flex: 1; height: 62px; border: 0; outline: 0; background: transparent; font: 600 19px var(--font-display); color: var(--ink); }
.search__close { flex: none; display: inline-flex; border-radius: 8px; }
.search__field kbd { font: 600 12px var(--font-display); padding: 3px 8px; border: 1.5px solid var(--line); border-radius: 6px; color: var(--muted); }
.search__list { max-height: 50vh; overflow-y: auto; padding: 8px 8px 0; }
.search__list:empty { display: none; }
.search__foot { padding: 0 8px 8px; }
.search__item { cursor: pointer; }
.search__empty { padding: 28px 12px; text-align: center; color: var(--muted); font-size: 15px; }
.search__item { display: flex; flex-direction: column; gap: 2px; width: 100%; padding: 12px 14px; border-radius: 12px; text-align: left; }
.search__item.is-active { background: color-mix(in srgb, var(--accent) 22%, transparent); box-shadow: inset 4px 0 0 var(--accent); }
.search__item:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.search__item strong { font: 700 16px var(--font-display); color: var(--ink); }
.search__item span { font-size: 13px; color: var(--muted); }
.search__all { display: block; width: 100%; padding: 12px 14px; text-align: left; font: 600 14px var(--font-display); color: var(--accent-text); border-radius: 12px; }
.search__all:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); }

/* ---------- Footer ---------- */
.footer { margin-top: 110px; background: var(--paper-2); border-top: 2px solid var(--stroke); }
.cta { position: relative; margin-top: -70px; padding: 44px; display: grid; grid-template-columns: 1.1fr 1fr; gap: 36px; align-items: center; background: var(--accent); color: var(--on-accent); border: 2px solid var(--stroke); border-radius: 28px; box-shadow: 8px 8px 0 var(--shadow-c); overflow: hidden; }
.cta h2 { color: var(--on-accent); font-size: clamp(28px, 3.6vw, 44px); }
.cta p { margin-top: 12px; font-size: 17px; color: var(--on-accent); opacity: .85; max-width: 46ch; }
.cta .blob { position: absolute; right: -60px; top: -60px; width: 220px; height: 220px; border-radius: 50%; background: var(--sun); opacity: .5; pointer-events: none; }
.sub { position: relative; display: flex; flex-direction: column; gap: 10px; }
.sub__row { display: flex; gap: 10px; }
.sub input { flex: 1; min-width: 0; height: 54px; padding: 0 18px; border: 2px solid var(--stroke); border-radius: 16px; background: #fffdf8; color: #12150f; font-size: 16px; }
.sub input::placeholder { color: #7b8072; }
.sub button { height: 54px; padding: 0 24px; border: 2px solid var(--stroke); border-radius: 16px; background: #12150f; color: #fffdf8; font: 700 16px var(--font-display); transition: transform .15s, box-shadow .15s; }
.sub button:hover { transform: translate(-2px, -2px); box-shadow: 4px 4px 0 rgba(18, 21, 15, .35); }
.sub__msg { min-height: 22px; font-size: 14px; font-weight: 600; color: var(--on-accent); }
.sub__msg.is-error { color: #7a1710; }
.sub__msg a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.sub input[aria-invalid="true"] { border-color: #7a1710; box-shadow: inset 0 0 0 1px #7a1710; }
.sub button:disabled { opacity: .7; cursor: progress; }
.rail__sub .sub__msg, .cta .sub__msg { color: #12150f; }

.footer__grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 40px; padding: 64px 0 40px; }
.footer__brand p { margin-top: 16px; max-width: 34ch; font-size: 15px; color: var(--body); }
.footer h4 { margin-bottom: 14px; font: 600 13px var(--font-display); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.footer li + li { margin-top: 8px; }
.footer li a { font-size: 15px; color: var(--ink); background: linear-gradient(var(--accent), var(--accent)) 0 100% / 0 3px no-repeat; transition: background-size .2s; }
.footer li a:hover { background-size: 100% 3px; }
.footer__legal { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; padding: 22px 0 34px; border-top: 2px solid var(--line); font-size: 13.5px; color: var(--muted); }
.footer__legal p { max-width: 70ch; }

/* ---------- Reading progress ---------- */
.progress { position: fixed; left: 0; top: 0; z-index: 150; height: 5px; width: 100%; background: var(--accent); border-bottom: 2px solid var(--stroke); transform: scaleX(0); transform-origin: 0 50%; transition: transform .08s linear; pointer-events: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .nav, .searchbtn, .masthead__right .btn--accent { display: none; }
  .iconbtn { display: inline-flex; }
  .masthead .container { gap: 12px; }
  .cta { grid-template-columns: 1fr; padding: 30px; }
  .footer__grid { grid-template-columns: 1fr 1fr; gap: 28px; }
}
@media (max-width: 560px) {
  .topbar__msg { display: none; }
  .topbar .container { justify-content: flex-end; }
  .sub__row { flex-direction: column; }
  .sub input { flex: none; }
  .cta .blob { display: none; }
  .footer__grid { grid-template-columns: 1fr; }
}
.rail__sub .sub__row { flex-direction: column; }
.rail__sub .sub input { flex: none; height: 48px; }
.rail__sub .sub button { height: 46px; }
