/* ============================================================
   Nanmayil — Base Layer
   ------------------------------------------------------------
   Reset + typography defaults + global element styles +
   accessibility utilities. Reads exclusively from tokens.css.
   ============================================================ */

/* ---------- Modern reset ----------------------------------- */

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

* {
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    scroll-behavior: smooth;
    scroll-padding-top: 88px;   /* clears sticky header when anchoring */
}

body {
    min-height: 100vh;
    width: 100%;
    overflow-x: hidden;
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: var(--color-ink);
    background-color: var(--color-canvas);
    font-feature-settings: "kern", "liga", "calt";
    display: flex;
    flex-direction: column;
}

/* Images, media — responsive by default, no CLS */
img,
picture,
video,
canvas,
svg {
    display: block;
    max-width: 100%;
    height: auto;
}

/* Honour intrinsic dimensions when set */
img[width][height] {
    height: auto;
}

/* Form controls inherit typography */
input,
button,
textarea,
select {
    font: inherit;
    color: inherit;
}

button {
    background: none;
    border: 0;
    cursor: pointer;
}

button:disabled,
[aria-disabled="true"] {
    cursor: not-allowed;
}

/* Remove list markers on nav-style lists (opt-in via class) */
.list-reset,
ul.list-reset,
ol.list-reset {
    list-style: none;
}

/* Lists retain markers by default but sit inside their container */
ul,
ol {
    padding-left: 1.25rem;
}

/* Tables — base */
table {
    border-collapse: collapse;
    width: 100%;
}

/* Text-rendering for headings */
h1, h2, h3, h4, h5, h6 {
    overflow-wrap: break-word;
    text-wrap: balance;
}

/* Paragraph wrap for readability */
p {
    text-wrap: pretty;
}

/* Hidden attribute respected */
[hidden] {
    display: none !important;
}

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

h1, .h1,
h2, .h2,
h3, .h3,
h4, .h4 {
    font-family: var(--font-display);
    font-weight: var(--weight-semibold);
    color: var(--color-ink);
    letter-spacing: var(--tracking-snug);
    line-height: var(--leading-tight);
}

h1, .h1 {
    font-size: clamp(var(--text-4xl), 4.5vw + 1rem, var(--text-6xl));
    line-height: var(--leading-tight);
    letter-spacing: var(--tracking-tight);
}

h2, .h2 {
    font-size: clamp(var(--text-3xl), 2.8vw + 1rem, var(--text-5xl));
    line-height: var(--leading-tight);
}

h3, .h3 {
    font-size: clamp(var(--text-2xl), 1.6vw + 1rem, var(--text-3xl));
    line-height: var(--leading-snug);
}

h4, .h4 {
    font-size: var(--text-xl);
    line-height: var(--leading-snug);
}

h5, .h5 {
    font-family: var(--font-body);
    font-weight: var(--weight-semibold);
    font-size: var(--text-lg);
    line-height: var(--leading-snug);
    letter-spacing: var(--tracking-normal);
}

h6, .h6 {
    font-family: var(--font-body);
    font-weight: var(--weight-semibold);
    font-size: var(--text-base);
    line-height: var(--leading-ui);
    letter-spacing: var(--tracking-wide);
    text-transform: uppercase;
}

p {
    font-size: var(--text-base);
    line-height: var(--leading-relaxed);
    color: var(--color-ink-soft);
}

.lead {
    font-size: var(--text-lg);
    line-height: var(--leading-relaxed);
    color: var(--color-ink-soft);
}

.muted {
    color: var(--color-ink-mute);
}

.eyebrow {
    font-family: var(--font-body);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    letter-spacing: var(--tracking-widest);
    text-transform: uppercase;
    color: var(--color-accent-deep);
}

.display {
    font-family: var(--font-display);
    font-weight: var(--weight-regular);
    font-style: italic;
    letter-spacing: var(--tracking-tight);
}

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

strong, b {
    font-weight: var(--weight-semibold);
}

em {
    font-style: italic;
}

/* Links — editorial underline with brand color */
a {
    color: var(--color-brand);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
    text-decoration-color: color-mix(in srgb, var(--color-brand) 35%, transparent);
    transition: color var(--duration-fast) var(--ease-out),
                text-decoration-color var(--duration-fast) var(--ease-out);
}

a:hover {
    color: var(--color-brand-strong);
    text-decoration-color: currentColor;
}

a.no-underline,
.no-underline a {
    text-decoration: none;
}

/* Horizontal rule — gold hairline */
hr {
    border: 0;
    height: 1px;
    background: linear-gradient(90deg,
        transparent 0%,
        var(--color-border-strong) 20%,
        var(--color-border-strong) 80%,
        transparent 100%);
    margin: var(--space-8) 0;
}

.hr-gold {
    background: linear-gradient(90deg,
        transparent 0%,
        var(--color-accent) 50%,
        transparent 100%);
    height: 1px;
}

/* Blockquote — editorial pull-quote */
blockquote {
    font-family: var(--font-display);
    font-style: italic;
    font-size: var(--text-xl);
    line-height: var(--leading-snug);
    color: var(--color-ink);
    padding-left: var(--space-5);
    border-left: 2px solid var(--color-accent);
    margin: var(--space-6) 0;
}

/* Code */
code, kbd, samp, pre {
    font-family: var(--font-mono);
    font-size: 0.925em;
}

code {
    background: var(--color-canvas-alt);
    padding: 0.15em 0.4em;
    border-radius: var(--radius-xs);
}

/* Selection */
::selection {
    background: var(--color-brand-tint);
    color: var(--color-ink);
}

/* ---------- Focus management ------------------------------- */

/* Hide default outline only for mouse users; keep for keyboard */
:focus {
    outline: none;
}

:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
    border-radius: var(--radius-xs);
}

/* Elements that manage their own focus ring (buttons, inputs) */
.focus-ring:focus-visible {
    outline: none;
    box-shadow: var(--shadow-focus);
}

/* ---------- Layout utilities ------------------------------- */

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

.container-lg { max-width: var(--container-lg); }
.container-md { max-width: var(--container-md); }
.container-sm { max-width: var(--container-sm); }
.container-xs { max-width: var(--container-xs); }

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

.stack-sm  { --stack-space: var(--space-2); }
.stack-md  { --stack-space: var(--space-4); }
.stack-lg  { --stack-space: var(--space-6); }
.stack-xl  { --stack-space: var(--space-8); }

.row-flex {
    display: flex;
    gap: var(--space-4);
}

.row-flex.wrap { flex-wrap: wrap; }
.row-flex.center { align-items: center; }
.row-flex.between { justify-content: space-between; }

.grid {
    display: grid;
    gap: var(--space-4);
}

/* Section rhythm */
.section {
    padding-block: clamp(var(--space-12), 8vw, var(--space-24));
}

.section-tight {
    padding-block: clamp(var(--space-8), 5vw, var(--space-16));
}

.section-canvas     { background: var(--color-canvas); }
.section-canvas-alt { background: var(--color-canvas-alt); }
.section-surface    { background: var(--color-surface); }
.section-brand      { background: var(--color-brand); color: var(--color-ink-inverse); }
.section-brand h1, .section-brand h2, .section-brand h3 { color: var(--color-ink-inverse); }

/* ---------- Accessibility utilities ------------------------ */

/* Skip-to-content — appears on focus */
.skip-link {
    position: absolute;
    top: -999px;
    left: var(--space-4);
    z-index: var(--z-toast);
    padding: var(--space-3) var(--space-5);
    background: var(--color-brand);
    color: var(--color-ink-inverse);
    border-radius: var(--radius-md);
    font-weight: var(--weight-semibold);
    text-decoration: none;
    box-shadow: var(--shadow-lg);
}

.skip-link:focus {
    top: var(--space-4);
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* Screen-reader-only content */
.sr-only,
.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;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Hide from AT but keep visible (rare; use thoughtfully) */
[aria-hidden="true"] {
    /* no forced display:none — caller controls presentation */
}

/* ---------- Reveal-on-scroll (progressive enhancement) ----- */
/* Pair with /scripts/reveal.js. Elements marked [data-reveal]
   start hidden + translated; reveal.js adds data-reveal-state="in"
   when they enter the viewport.
   Respects prefers-reduced-motion. */
[data-reveal] {
    opacity: 0;
    transform: translateY(14px);
    transition:
        opacity var(--duration-slow) var(--ease-editorial),
        transform var(--duration-slow) var(--ease-editorial);
    will-change: opacity, transform;
}
[data-reveal][data-reveal-state="in"] {
    opacity: 1;
    transform: translateY(0);
}
[data-reveal="fade"] { transform: none; }
[data-reveal="rise"] { transform: translateY(20px); }
[data-reveal="left"] { transform: translateX(-20px); }
[data-reveal="right"] { transform: translateX(20px); }
[data-reveal="scale"] { transform: scale(0.96); }
[data-reveal="fade"][data-reveal-state="in"],
[data-reveal="rise"][data-reveal-state="in"],
[data-reveal="left"][data-reveal-state="in"],
[data-reveal="right"][data-reveal-state="in"],
[data-reveal="scale"][data-reveal-state="in"] {
    transform: none;
}
/* If JS never ran, never leave content hidden. */
html.no-js [data-reveal],
html:not(.js) [data-reveal] {
    opacity: 1 !important;
    transform: none !important;
}

@media (prefers-reduced-motion: reduce) {
    [data-reveal],
    [data-reveal][data-reveal-state="in"] {
        opacity: 1 !important;
        transform: none !important;
        transition: none !important;
    }
}

/* ---------- Print ------------------------------------------ */

@media print {
    body {
        background: #fff;
        color: #000;
    }
    a {
        color: #000;
        text-decoration: underline;
    }
    .no-print {
        display: none !important;
    }
}
