/*
 * Design tokens — the single source for every colour, type step and gap.
 * This file IS the source of truth (the design handoff these values came
 * from was retired 2026-09-17). Why the colours are what they are — the
 * contrast ratios that forbid lightening --accent or --meta — is in
 * docs/design-principles.md §2; change a value only with that in mind.
 *
 * Nothing in this file selects an element other than :root, html and body.
 * Component styling belongs in base.css (site chrome) or the per-app
 * stylesheets — keeping the token layer selector-free means a value can be
 * changed here without wondering what else it affects.
 */

:root {
    /* Colour: the client's corporate identity, the palette of the old
     * jinepsgazetesi.com (anthracite, white, blue), measured on the live site
     * 2026-11-01 and adopted by the owner the same day (decisions log). All
     * combinations in use meet WCAG AA. --brand is the old site's own blue,
     * #4db2ec: 2.4:1 on white, so it never carries text on a light ground;
     * ink text on it is 6.5:1. --accent is the same hue darkened for link
     * and button text: 5.2:1 on --paper, 4.8:1 on --tint — do not lighten
     * it. --accent-on-dark is the old site's active-menu blue, 10.2:1 on ink. */
    --ink: #212529;
    --body: #343a40;
    --meta: #5c636a;
    --muted: #8c939a;
    --rule: #dee2e6;
    --paper: #ffffff;
    --tint: #f7f7f7;
    --mat: #eef0f2;
    --brand: #4db2ec;
    --accent: #1a73a8;
    --accent-on-dark: #a2d9ff;

    /* Success/error — owner ruling 2026-09-17: standardize on red/green
     * everywhere (site messages, form errors, auth screens all used to
     * disagree — see docs/decisions-log.md) rather than reusing --accent for
     * errors. Warm, muted hues to match the rest of the palette rather than
     * a stock Material red/green; both clear 6.4:1 on --paper and --tint. */
    --success: #3a6130;
    --error: #9c3225;

    /* On ink grounds: text is --paper, secondary the same colour dimmed.
     * Expressed as ready-made rgba values rather than opacity so a parent's
     * opacity never compounds onto a child's. */
    --on-ink: #ffffff;
    --on-ink-secondary: rgba(255, 255, 255, 0.85);
    --on-ink-tertiary: rgba(255, 255, 255, 0.6);
    --on-ink-breadcrumb: rgba(255, 255, 255, 0.72);
    --rule-on-ink: rgba(255, 255, 255, 0.2);
    --rule-on-ink-strong: rgba(255, 255, 255, 0.45);

    /* Type. Two families only. PT Serif is the one family covering Turkish
     * and all four Cyrillic locales, which is why it carries the body text
     * and not just the headlines. */
    --font-serif: "PT Serif", Georgia, "Times New Roman", serif;
    --font-sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;

    /* Body copy is 17.5px on mobile and 17px from 900px up — larger on the
     * phone, not smaller: shorter measure, closer viewing. The step is
     * overridden in the 900px media query at the foot of this file. */
    --text-body: 17.5px;
    --leading-body: 1.68;

    /* Headline steps, largest first. Tracking tightens as size grows. */
    --text-display: 42px;
    --text-h1: 34px;
    --text-h2: 27px;
    --text-h3: 21px;
    --text-lead: 19px;

    /* UI steps. Nothing below 11px on desktop. */
    --text-ui: 12.5px;
    --text-meta: 11.5px;
    --text-kicker: 11px;
    --text-kicker-small: 10.5px;

    --leading-tight: 1.06;
    --leading-headline: 1.14;
    --leading-h3: 1.38;
    --tracking-display: -0.022em;
    --tracking-headline: -0.02em;
    --tracking-h3: -0.012em;
    --tracking-kicker: 0.14em;
    --tracking-wordmark: 0.06em;

    /* Line language. 2.5px is the strongest signal in the system — section
     * rules, the header underline, pull quotes. Use it sparingly. */
    --rule-strong: 2.5px;
    --rule-medium: 1.5px;
    --rule-hairline: 1px;

    /* Square corners everywhere. The only exceptions are avatars (50%), the
     * review-bell count badge (9px), and the newsletter-preferences toggle
     * switch (account.css, a pill track + circular thumb — owner ruling
     * 2026-09-17: keep it, a toggle drawn with square corners loses the
     * "flip switch" affordance), all set locally where they occur. This is
     * deliberate — it reads as newsprint. Do not round cards. */
    --radius: 0;

    /* The only two shadows in the system. Scanned front pages and magazine
     * covers get --shadow-paper so they read as physical paper; open search
     * dropdowns get --shadow-dropdown. Nothing else casts a shadow. */
    --shadow-paper: drop-shadow(0 1px 6px rgba(20, 18, 15, 0.28));
    --shadow-dropdown: 0 4px 14px rgba(20, 18, 15, 0.1);

    /* Spacing. Gaps come from this scale; use flex/grid `gap`, never margin
     * chains. --gutter and --card-pad widen at 640px and 900px below. */
    --gutter: 16px;
    --card-pad: 16px;
    --space-1: 7px;
    --space-2: 9px;
    --space-3: 11px;
    --space-4: 14px;
    --space-5: 18px;
    --space-6: 22px;
    --space-7: 26px;
    --space-8: 30px;

    /* Paragraph rhythm inside body prose. Named separately from the gap scale
     * because it is a typographic measure, not a layout gap: blocks take
     * 24-26px against this 16px, and that contrast is what makes an inserted
     * block read as an object rather than as more prose. */
    --paragraph-gap: 16px;

    /* Layout. Most pages stop at 1120px centred; the Turkish homepage alone
     * uses 1280px (owner ruling 2026-09-13, design 4a). Body measure caps at
     * 760px, which is 65-75 characters at the body size. */
    --page-max: 1120px;
    --homepage-max: 1280px;
    --measure: 760px;
    --rail-width: 260px;
    /* Design 4a/4b: the homepage rail is 340px once the full 1120px layout
     * applies (>1100); the article body measure is 660px, narrower than the
     * 760px block measure because 4b sets the body at 19px. */
    --rail-width-wide: 340px;
    --measure-article: 660px;

    /* Two design literals with no other home: the dashed rule that frames
     * an ad slot, and the start of the wash behind a members-only feed row. */
    --rule-dashed: #c4cad0;
    --gated-wash: #eef7fd;

    /* Touch targets never below 44px. Inputs are 50px on mobile and no input
     * font may drop below 16px or iOS auto-zooms the page on focus. */
    --target-min: 44px;
    --input-height: 50px;
    --input-font-min: 16px;
}

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

html {
    /* The design's sizes are all px and the token steps above are px, so
     * nothing here scales with the root size — but a reader who has set a
     * larger default font still gets it honoured through the browser's own
     * page zoom, which px does not defeat. */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: var(--font-serif);
    font-size: var(--text-body);
    line-height: var(--leading-body);
    color: var(--body);
    background: var(--paper);
}

/*
 * Focus is specification, not decoration (README §"Focus, keyboard and
 * motion"). Always `outline`, never `box-shadow` — shadows vanish in
 * Windows high-contrast mode, leaving keyboard users with no position on
 * screen. Never `outline: none`, and never plain `:focus`, which would put
 * a ring on every mouse click too.
 */
:focus-visible {
    outline: var(--rule-strong) solid var(--accent);
    outline-offset: 2px;
}

/* On ink grounds --accent is unreadable; --accent-on-dark is the ring there.
 * Any component that paints an ink ground carries .on-ink so this applies
 * without each one restating the rule. */
.on-ink :focus-visible,
.on-ink:focus-visible {
    outline-color: var(--accent-on-dark);
    outline-offset: 3px;
}

/*
 * The first tab stop on every page is the skip link, visually hidden until
 * focused. Not `display: none` — that would remove it from the tab order,
 * which is the one thing it exists for.
 */
.skip-link {
    position: absolute;
    left: var(--gutter);
    top: 0;
    z-index: 100;
    transform: translateY(-110%);
    padding: 11px 18px;
    background: var(--paper);
    border: var(--rule-strong) solid var(--ink);
    color: var(--ink);
    font: 600 var(--text-ui) / 1 var(--font-sans);
    text-decoration: none;
}

.skip-link:focus {
    transform: translateY(0);
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* Form controls do not inherit the page font on their own. */
input,
select,
textarea,
button {
    font-family: inherit;
}

/*
 * No input font below 16px — iOS auto-zooms the page otherwise. Site-wide
 * rather than per-form: one form that forgets it costs a zoom on every focus.
 *
 * Scoped to the controls that actually take typed text. Buttons are excluded
 * deliberately: iOS zooms on *focus of a text field*, not on a button, and
 * the design puts buttons at 12-12.5px, so a blanket floor here would
 * silently inflate every button in the system.
 */
input:not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="checkbox"]):not([type="radio"]),
select,
textarea {
    font-size: max(var(--input-font-min), 1em);
}

/* Headlines always wrap prettily and never below the tightest leading. */
h1,
h2,
h3,
h4 {
    font-family: var(--font-serif);
    font-weight: 700;
    color: var(--ink);
    text-wrap: pretty;
}

img {
    max-width: 100%;
}

/*
 * prefers-reduced-motion: transitions become instant and the mobile lead
 * carousel stops auto-advancing (the carousel half is enforced in JS, which
 * CSS cannot reach).
 */
@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;
    }
}

/*
 * The four breakpoint thresholds (README §"Mobile is the primary surface").
 * Written as min-width because the base rules above are the mobile layout —
 * the desktop comps are the wide end of one layout, not the canonical design.
 */

/* 640-900: single column still, wider gutter, lists become 2-up grids. */
@media (min-width: 640px) {
    :root {
        --gutter: 24px;
        --card-pad: 20px;
    }
}

/* 900-1100: the rail returns, gutter reaches its full width, and body type
 * steps *down* to 17px — the measure is longer here than on a phone. */
@media (min-width: 900px) {
    :root {
        --gutter: var(--space-8);
        --card-pad: var(--space-7);
        --text-body: 17px;
        --input-height: var(--target-min);
    }
}
