/* ==========================================================================
   Shared components
   Masthead, navigation, buttons, figures, source notes, footer
   ========================================================================== */

/* ---------- Masthead (sticky) ---------- */

.masthead {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(245, 241, 232, 0.985);
  border-bottom: 1px solid var(--rule);
  transition: box-shadow 0.3s var(--ease);
}

.masthead.is-condensed {
  box-shadow: 0 10px 30px -22px rgba(14, 25, 41, 0.45);
}

.masthead__rail {
  background: var(--midnight);
  color: var(--sage);
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  max-height: 2.25rem;
  overflow: hidden;
  transition: max-height 0.35s var(--ease);
}

.masthead.is-condensed .masthead__rail {
  max-height: 0;
}

.masthead__rail-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 2.25rem;
}

.masthead__folio {
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.masthead__folio span {
  color: var(--terracotta-light);
  margin-right: 0.65rem;
}

.masthead__rail a {
  color: var(--ivory);
  text-decoration: none;
  white-space: nowrap;
}

.masthead__rail a:hover {
  color: var(--terracotta-light);
}

.masthead__rail a:focus-visible {
  outline-color: var(--sage);
}

.masthead__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  min-height: 4.5rem;
}

/* Brand */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
  text-decoration: none;
  color: var(--midnight);
  flex-shrink: 0;
}

.brand:hover {
  color: var(--midnight);
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  background: var(--midnight);
  color: var(--ivory);
  font-family: var(--serif);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  position: relative;
}

.brand__mark::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: var(--terracotta);
}

.brand__text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand__name {
  font-family: var(--serif);
  font-size: 1.12rem;
  font-weight: 600;
}

.brand__role {
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}

/* Primary navigation — desktop */

.primary-nav__list {
  display: flex;
  align-items: stretch;
  gap: 0.1rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.primary-nav__list a {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 0.55rem 0.62rem 0.6rem;
  font-size: 0.86rem;
  font-weight: 500;
  line-height: 1.15;
  color: var(--graphite);
  text-decoration: none;
  white-space: nowrap;
}

.primary-nav__num {
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.2rem;
}

.primary-nav__list a::after {
  content: "";
  position: absolute;
  left: 0.62rem;
  right: 0.62rem;
  bottom: 0.2rem;
  height: 2px;
  background: var(--terracotta);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.35s var(--ease);
}

.primary-nav__list a:hover {
  color: var(--midnight);
}

.primary-nav__list a:hover::after,
.primary-nav__list a[aria-current="page"]::after {
  transform: scaleX(1);
}

.primary-nav__list a[aria-current="page"] {
  color: var(--midnight);
}

.primary-nav__list a[aria-current="page"] .primary-nav__num {
  color: var(--terracotta-ink);
}

.primary-nav__footer {
  display: none;
}

/* Index toggle (tablet & mobile) */

.index-toggle {
  display: none;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.9rem 0.65rem 1rem;
  background: transparent;
  border: 1px solid var(--rule-strong);
  color: var(--midnight);
  font-family: var(--mono);
  font-size: 0.76rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  min-height: 2.75rem;
  transition: background 0.25s var(--ease), color 0.25s var(--ease);
}

.index-toggle:hover {
  background: var(--midnight);
  color: var(--ivory);
}

.index-toggle__bars {
  position: relative;
  width: 1.1rem;
  height: 0.7rem;
}

.index-toggle__bars::before,
.index-toggle__bars::after {
  content: "";
  position: absolute;
  left: 0;
  width: 100%;
  height: 1.5px;
  background: currentColor;
  transition: transform 0.3s var(--ease), top 0.3s var(--ease);
}

.index-toggle__bars::before {
  top: 0;
}

.index-toggle__bars::after {
  top: calc(100% - 1.5px);
}

.index-toggle[aria-expanded="true"] .index-toggle__bars::before {
  top: calc(50% - 0.75px);
  transform: rotate(45deg);
}

.index-toggle[aria-expanded="true"] .index-toggle__bars::after {
  top: calc(50% - 0.75px);
  transform: rotate(-45deg);
}

/* ---------- Buttons & links ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  min-height: 3.1rem;
  padding: 0.8rem 1.5rem;
  border: 1px solid var(--midnight);
  background: var(--midnight);
  color: var(--ivory);
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.3s var(--ease), color 0.3s var(--ease), border-color 0.3s var(--ease);
}

.btn:hover {
  background: var(--terracotta-ink);
  border-color: var(--terracotta-ink);
  color: var(--white);
}

.btn--ghost {
  background: transparent;
  color: var(--midnight);
}

.btn--ghost:hover {
  background: var(--midnight);
  border-color: var(--midnight);
  color: var(--ivory);
}

.btn--light {
  background: var(--ivory);
  border-color: var(--ivory);
  color: var(--midnight);
}

.btn--light:hover {
  background: var(--terracotta-light);
  border-color: var(--terracotta-light);
  color: var(--midnight-deep);
}

.btn__arrow {
  width: 1.05rem;
  height: 1.05rem;
  transition: transform 0.3s var(--ease);
}

.btn:hover .btn__arrow {
  transform: translateX(4px);
}

.text-link {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 600;
  color: var(--midnight);
  text-decoration: none;
  border-bottom: 1px solid var(--terracotta);
  padding-bottom: 0.15rem;
}

.text-link:hover {
  color: var(--terracotta-ink);
}

/* ---------- Figures (no cropping: images keep their natural ratio) ---------- */

.figure {
  margin: 0;
}

.figure__mat {
  background: var(--sage);
  padding: clamp(0.6rem, 1.4vw, 1rem);
}

.figure__mat--ivory {
  background: var(--ivory-deep);
}

.figure__mat--midnight {
  background: var(--midnight);
}

.figure__mat img {
  width: 100%;
  height: auto;
}

.figure figcaption {
  display: flex;
  gap: 0.75rem;
  margin-top: 0.85rem;
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--muted);
}

.figure figcaption::before {
  content: "";
  flex: 0 0 1.25rem;
  height: 1px;
  margin-top: 0.7rem;
  background: var(--terracotta);
}

.credit {
  display: block;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  margin-top: 0.2rem;
}

/* ---------- Section heading block ---------- */

.section-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  margin-bottom: clamp(2.5rem, 5vw, 4rem);
}

.section-head__index {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--terracotta-ink);
}

.section-head p {
  max-width: 60ch;
  color: var(--slate);
}

/* ---------- Attributed statement ---------- */

.statement {
  margin: 0;
  padding: 0;
}

.statement blockquote {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(1.45rem, 1.15rem + 1.2vw, 2.2rem);
  line-height: 1.35;
  color: var(--midnight);
}

.statement blockquote p::before {
  content: "\201C";
  color: var(--terracotta);
}

.statement blockquote p::after {
  content: "\201D";
  color: var(--terracotta);
}

.statement figcaption {
  margin-top: 1.25rem;
  font-size: 0.88rem;
  color: var(--muted);
}

.statement figcaption strong {
  display: block;
  font-weight: 600;
}

/* ---------- Editorial note ---------- */

.note {
  border-left: 3px solid var(--terracotta);
  background: var(--white);
  padding: 1.25rem 1.5rem;
  font-size: 0.93rem;
  color: var(--slate);
}

.note strong {
  display: block;
  margin-bottom: 0.3rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--terracotta-ink);
}

/* ---------- Source notes ---------- */

.sources {
  border-top: 1px solid var(--rule-strong);
  padding-top: 2.5rem;
}

.sources h2 {
  font-size: 1.5rem;
  margin-bottom: 1.25rem;
}

.sources ol {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: src;
  display: grid;
  gap: 0.75rem 3rem;
}

.sources li {
  counter-increment: src;
  display: grid;
  grid-template-columns: 2.25rem minmax(0, 1fr);
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--muted);
}

.sources li::before {
  content: "[" counter(src) "]";
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--terracotta-ink);
}

.sources a {
  overflow-wrap: anywhere;
}

/* ---------- Page continuation ---------- */

.continue {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  border-top: 1px solid var(--rule-strong);
}

.continue a {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 2rem 0;
  text-decoration: none;
  color: var(--midnight);
}

.continue a + a {
  border-top: 1px solid var(--rule);
}

.continue__label {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.continue__title {
  font-family: var(--serif);
  font-size: clamp(1.5rem, 1.2rem + 1vw, 2.1rem);
  line-height: 1.2;
  transition: color 0.25s var(--ease);
}

.continue a:hover .continue__title {
  color: var(--terracotta-ink);
}

/* ---------- Footer (colophon) ---------- */

.colophon {
  background: var(--midnight-deep);
  color: rgba(245, 241, 232, 0.8);
  font-size: 0.93rem;
}

.colophon a {
  color: var(--ivory);
}

.colophon a:hover {
  color: var(--terracotta-light);
}

.colophon :focus-visible {
  outline-color: var(--sage);
}

.colophon__top {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 3rem;
  padding-block: clamp(3.5rem, 7vw, 6rem) clamp(2.5rem, 5vw, 4rem);
}

.colophon__mark {
  margin: 0 0 1rem;
  font-family: var(--serif);
  font-size: clamp(1.8rem, 1.4rem + 1.5vw, 2.6rem);
  line-height: 1.1;
  color: var(--ivory);
}

.colophon__summary {
  max-width: 38ch;
  color: rgba(245, 241, 232, 0.72);
}

.colophon__heading {
  margin: 0 0 1.1rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--terracotta-light);
}

.colophon__links {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem 1.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.colophon__links a {
  text-decoration: none;
}

.colophon__contact {
  display: grid;
  gap: 0.55rem;
  margin: 0;
}

.colophon__contact dt {
  font-size: 0.78rem;
  color: rgba(245, 241, 232, 0.6);
}

.colophon__contact dd {
  margin: 0 0 0.5rem;
  color: var(--ivory);
  overflow-wrap: anywhere;
}

.social {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.social__link {
  position: relative;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border: 1px solid var(--rule-light);
  color: var(--ivory);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.25s var(--ease), color 0.25s var(--ease), border-color 0.25s var(--ease);
}

.social__link svg {
  width: 1.1rem;
  height: 1.1rem;
}

.social__link:hover {
  background: var(--ivory);
  border-color: var(--ivory);
  color: var(--midnight);
}

.social__link[aria-disabled="true"]::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.5rem);
  transform: translateX(-50%);
  padding: 0.35rem 0.6rem;
  background: var(--ivory);
  color: var(--midnight);
  font-size: 0.72rem;
  white-space: nowrap;
  display: none;
  pointer-events: none;
}

.social li:first-child .social__link::after {
  left: 0;
  transform: none;
}

.social li:nth-child(n+4) .social__link::after {
  left: auto;
  right: 0;
  transform: none;
}

.social__link[aria-disabled="true"]:hover::after,
.social__link[aria-disabled="true"]:focus-visible::after {
  display: block;
}

.social-note {
  margin-top: 0.9rem;
  font-size: 0.78rem;
  color: rgba(245, 241, 232, 0.6);
}

.colophon__base {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 2rem;
  padding-block: 1.5rem;
  border-top: 1px solid var(--rule-light);
  font-size: 0.84rem;
  color: rgba(245, 241, 232, 0.72);
}

.colophon__base p {
  margin: 0;
}

.colophon__lock {
  background: none;
  border: 0;
  padding: 0.3rem 0;
  color: rgba(245, 241, 232, 0.72);
  font-size: 0.84rem;
  text-decoration: underline;
  text-underline-offset: 0.22em;
  cursor: pointer;
}

.colophon__lock:hover {
  color: var(--terracotta-light);
}
