/* Mayfair Scholars – base: reset, typography, layout, utilities, prose, focus, motion. */

/* ── Reset ─────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: calc(var(--header-h) + 1rem);
}

body,
h1, h2, h3, h4, h5, h6,
p, figure, blockquote, dl, dd, ul, ol {
  margin: 0;
}

ul,
ol {
  padding: 0;
}

/* Plain lists in content keep their bullets; lists styled in templates are untouched.
   :where() keeps this at zero specificity so any component rule wins. */
:where(ul:not([class]):not([style]), ol:not([class]):not([style])) {
  padding-left: 1.25rem;
}

body {
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  color: var(--color-text-main);
  background-color: var(--color-bg-white);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

img,
svg,
video {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
}

svg {
  flex-shrink: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

table {
  border-collapse: collapse;
}

/* ── Typography ────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 600;
  line-height: var(--leading-tight);
  color: var(--color-primary);
  margin-bottom: var(--space-4);
  font-variant-numeric: lining-nums;
  text-wrap: balance;
}

h1 { font-size: var(--text-5xl); letter-spacing: -0.01em; }
h2 { font-size: var(--text-3xl); letter-spacing: -0.005em; }
h3 { font-size: var(--text-2xl); }
h4 { font-size: var(--text-xl); }
h5, h6 { font-size: var(--text-lg); }

p {
  margin-bottom: var(--space-4);
}

strong,
b {
  font-weight: 600;
}

small {
  font-size: var(--text-sm);
}

hr {
  border: 0;
  border-top: 1px solid var(--color-border);
  margin: var(--space-6) 0;
}

/* Links: underlined in running text; UI links (buttons, cards, nav) opt out in components.css. */
a {
  color: var(--color-link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  transition: color var(--transition-fast), text-decoration-color var(--transition-fast);
}

a:hover {
  color: var(--color-link-hover);
}

/* ── Focus ─────────────────────────────────────────────────────── */
:focus-visible {
  outline: 3px solid var(--color-focus);
  outline-offset: 2px;
}

.section-bg-navy :focus-visible,
.page-hero--navy :focus-visible,
.trust-bar :focus-visible,
.footer :focus-visible,
.topbar :focus-visible,
.on-dark :focus-visible {
  outline-color: var(--color-focus-on-dark);
}

main[tabindex="-1"]:focus {
  outline: none;
}

/* ── Accessibility helpers ─────────────────────────────────────── */
.screen-reader-text,
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  z-index: var(--z-skip);
  padding: var(--space-3) var(--space-5);
  background: var(--color-primary);
  color: var(--color-text-light);
  font-weight: 600;
  text-decoration: none;
  border-radius: var(--radius-sm);
  transform: translateY(-200%);
}

/* The navy pill is the indicator (16.96:1 on the white header); the gold ring sits inside it
   (6.9:1 on navy) so it never lands on the white header (2.46:1). */
.skip-link:focus,
.skip-link:focus-visible {
  transform: none;
  color: var(--color-text-light);
  outline: 3px solid var(--color-focus-on-dark);
  outline-offset: -6px;
}

/* ── Layout ────────────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.container--narrow {
  max-width: calc(var(--measure) + 2 * var(--gutter));
}

.section {
  padding-block: var(--section-pad);
}

.section--tight {
  padding-block: calc(var(--section-pad) * 0.6);
}

.section-bg-ivory {
  background-color: var(--color-bg-ivory);
}

.section-bg-navy {
  background-color: var(--color-primary);
  color: var(--color-text-light);
}

.section-bg-navy h1,
.section-bg-navy h2,
.section-bg-navy h3,
.section-bg-navy h4 {
  color: var(--color-text-light);
}

.section-bg-navy a:not(.btn) {
  color: var(--color-text-light);
}

.section-bg-navy a:not(.btn):hover {
  color: var(--color-accent);
}

.grid-2,
.grid-3,
.grid-4 {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-6);
}

@media (min-width: 768px) {
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.stack > * + * {
  margin-top: var(--space-4);
}

/* ── Utilities ─────────────────────────────────────────────────── */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-muted { color: var(--color-text-muted); }
.text-subtle { color: var(--color-text-subtle); }
.mb-0 { margin-bottom: 0; }
.mb-xs { margin-bottom: var(--space-2); }
.mb-sm { margin-bottom: var(--space-4); }
.mb-md { margin-bottom: var(--space-6); }
.mb-lg { margin-bottom: var(--space-8); }
.mt-sm { margin-top: var(--space-4); }
.mt-md { margin-top: var(--space-6); }
.mt-lg { margin-top: var(--space-8); }
.mx-auto { margin-inline: auto; }

@media (max-width: 767px) {
  .mobile-gap-md { gap: var(--space-6) !important; }
}

/* ── Prose (long-form content: pages, posts, guides, legal) ────── */
.prose,
.post-content {
  max-width: var(--measure);
  font-size: var(--text-md);
  line-height: 1.75;
  color: var(--color-text-main);
}

.prose > * + *,
.post-content > * + * {
  margin-top: var(--space-5);
}

.prose p,
.post-content p {
  margin-bottom: 0;
}

.prose h2,
.post-content h2 {
  font-size: var(--text-3xl);
  margin-top: var(--space-7);
  margin-bottom: 0;
}

.prose h3,
.post-content h3 {
  font-size: var(--text-2xl);
  margin-top: var(--space-6);
  margin-bottom: 0;
}

.prose h4,
.post-content h4 {
  margin-top: var(--space-5);
  margin-bottom: 0;
}

.prose > :first-child,
.post-content > :first-child {
  margin-top: 0;
}

.prose ul,
.prose ol,
.post-content ul,
.post-content ol {
  padding-left: 1.5rem;
}

.prose ul,
.post-content ul {
  list-style: disc;
}

.prose ol,
.post-content ol {
  list-style: decimal;
}

.prose li + li,
.post-content li + li {
  margin-top: var(--space-2);
}

.prose li::marker,
.post-content li::marker {
  color: var(--color-accent-dark);
}

.prose blockquote,
.post-content blockquote {
  border-left: 3px solid var(--color-accent);
  padding: var(--space-4) var(--space-5);
  background-color: var(--color-bg-ivory);
  font-style: italic;
  color: var(--color-text-muted);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.prose blockquote p,
.post-content blockquote p {
  margin: 0;
}

.prose img,
.post-content img {
  border-radius: var(--radius-sm);
}

.prose figure figcaption,
.post-content figure figcaption {
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-subtle);
}

.prose table,
.post-content table {
  width: 100%;
  font-size: var(--text-base);
}

.prose th,
.prose td,
.post-content th,
.post-content td {
  text-align: left;
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  vertical-align: top;
}

.prose th,
.post-content th {
  background: var(--color-bg-ivory);
  font-weight: 600;
}

/* ── Motion ────────────────────────────────────────────────────── */
/* Scroll reveal is progressive enhancement: content is visible unless main.js has run
   (html.reveal-ready) AND the visitor has not asked for reduced motion.
   Only the reveal animates: the transition lives on .is-visible, so hiding a below-the-fold
   section is instant and nothing ever visibly fades OUT after load. Sections main.js reveals
   for an in-page jump (#anchor) get .is-instant and appear without a fade. */
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }

  html.reveal-ready .animate-on-scroll:not(.is-visible) {
    opacity: 0;
    transform: translateY(24px);
  }

  html.reveal-ready .animate-on-scroll.is-visible {
    transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
  }

  html.reveal-ready .animate-on-scroll.is-visible.is-instant {
    transition: none;
  }

  /* Cross-document page fade (replaces Swup; unsupported browsers just navigate normally). */
  @view-transition {
    navigation: auto;
  }

  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: 0.25s;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

@media print {
  .animate-on-scroll {
    opacity: 1 !important;
    transform: none !important;
  }
}
