/* ==========================================================================
   Dr. T. R. Paarivendhar — Global foundation
   Tokens, base elements, typography and layout primitives
   ========================================================================== */

:root {
  --midnight: #16263d;
  --midnight-deep: #0e1929;
  --slate: #40566e;
  --terracotta: #b97863;
  --terracotta-ink: #98563f;
  --terracotta-light: #e0ab97;
  --sage: #d5ded3;
  --sage-deep: #bccab8;
  --ivory: #f5f1e8;
  --ivory-deep: #ebe4d4;
  --graphite: #252b32;
  --muted: #56606b;
  --white: #ffffff;
  --rule: rgba(22, 38, 61, 0.16);
  --rule-strong: rgba(22, 38, 61, 0.34);
  --rule-light: rgba(245, 241, 232, 0.18);

  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "Instrument Sans", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --max: 1320px;
  --gutter: clamp(1.25rem, 4vw, 3.5rem);
  --section: clamp(4rem, 9vw, 8rem);
  --header-h: 5.25rem;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

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

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

/* Protected pages stay hidden until the access check in js/guard.js passes */
html.is-guarded:not(.is-authorised) body {
  visibility: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--ivory);
  color: var(--graphite);
  font-family: var(--sans);
  font-size: clamp(1rem, 0.96rem + 0.2vw, 1.0625rem);
  line-height: 1.72;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  animation: page-in 0.6s var(--ease) both;
}

@keyframes page-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

img {
  height: auto;
}

a {
  color: var(--midnight);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.22em;
  transition: color 0.25s var(--ease), text-decoration-color 0.25s var(--ease);
}

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

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

:focus-visible {
  outline: 2px solid var(--terracotta-ink);
  outline-offset: 3px;
  border-radius: 1px;
}

::selection {
  background: var(--sage);
  color: var(--midnight);
}

/* ---------- Typography ---------- */

h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  color: var(--midnight);
  line-height: 1.12;
  letter-spacing: -0.012em;
  text-wrap: balance;
}

h1 {
  font-size: clamp(2.4rem, 1.6rem + 3.4vw, 4.5rem);
  letter-spacing: -0.02em;
}

h2 {
  font-size: clamp(1.9rem, 1.4rem + 1.9vw, 3rem);
}

h3 {
  font-size: clamp(1.35rem, 1.2rem + 0.6vw, 1.7rem);
  line-height: 1.22;
}

h4 {
  font-size: 1.2rem;
  line-height: 1.3;
}

p {
  margin: 0 0 1.15em;
}

p:last-child {
  margin-bottom: 0;
}

strong {
  font-weight: 600;
  color: var(--midnight);
}

em {
  font-style: italic;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 1.25rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--terracotta-ink);
}

.eyebrow::before {
  content: "";
  width: 2rem;
  height: 1px;
  background: currentColor;
}

.lede {
  font-family: var(--serif);
  font-size: clamp(1.2rem, 1.05rem + 0.6vw, 1.5rem);
  line-height: 1.55;
  color: var(--slate);
  max-width: 44ch;
}

.mono {
  font-family: var(--mono);
  letter-spacing: 0.02em;
}

.prose {
  max-width: 68ch;
}

.prose p + h3,
.prose ul + h3 {
  margin-top: 2.25rem;
}

.prose h3 {
  margin-bottom: 0.9rem;
}

.prose ul {
  margin: 0 0 1.25em;
  padding-left: 1.2rem;
}

.prose li {
  margin-bottom: 0.45rem;
}

.prose li::marker {
  color: var(--terracotta);
}

.dropcap::first-letter {
  float: left;
  margin: 0.1em 0.12em 0 0;
  font-family: var(--serif);
  font-size: 4.1em;
  line-height: 0.8;
  color: var(--terracotta-ink);
}

.sup-ref {
  font-family: var(--mono);
  font-size: 0.7em;
  vertical-align: super;
  line-height: 0;
  margin-left: 0.1em;
}

.sup-ref a {
  text-decoration: none;
  color: var(--terracotta-ink);
}

/* ---------- Layout primitives ---------- */

.wrap {
  width: 100%;
  max-width: var(--max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

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

.section--tight {
  padding-block: clamp(3rem, 6vw, 5rem);
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -4rem;
  z-index: 200;
  padding: 0.75rem 1.1rem;
  background: var(--midnight);
  color: var(--ivory);
  font-weight: 600;
  text-decoration: none;
  transition: top 0.2s var(--ease);
}

.skip-link:focus {
  top: 1rem;
  color: var(--ivory);
}

/* ---------- Motion ---------- */

.js [data-reveal] {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.9s var(--ease), transform 0.9s var(--ease);
}

.js [data-reveal].is-visible {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  .js [data-reveal] {
    opacity: 1;
    transform: none;
  }
}
