/* =====================================================================
   Prima Repubblica — Landing Page
   Aesthetic: stark editorial monochrome. Edizione Sera (off-white on near-black)
   and Edizione Mattina (ink on newsprint). Bodoni Moda masthead + EB Garamond, film-grain.
   "Contro il logorio della politica moderna."
   ===================================================================== */

/* Edition tokens — Sera (default): warm off-white on near-black.
   Mattina: newsprint ground, ink type. Toggle via [data-edition]. */
:root,
html[data-edition="sera"] {
    --bg:        #0b0a08;
    --ink:       #f3eee3;
    --ink-soft:  #d0c8b8;
    --muted:     #8c8577;
    --accent:    #ffffff;

    --tri-green: #1f7a4d;
    --tri-white: #f3eee3;
    --tri-red:   #b23b2f;
    --tri-white-edge: transparent;

    --hair:         rgba(243, 238, 227, 0.15);
    --hair-strong:  rgba(243, 238, 227, 0.42);
    --hover-wash:   rgba(243, 238, 227, 0.05);
    --focus-ring:   rgba(243, 238, 227, 0.4);

    --grain-opacity: 0.06;
    --grain-blend:   screen;
    --crown: radial-gradient(90% 55% at 50% -8%, rgba(255, 255, 255, 0.055), transparent 68%);

    --seal-filter: none;
    --theme-color: #0b0a08;

    --font-display: 'Bodoni Moda', 'Didot', 'Bodoni MT', 'Times New Roman', serif;
    --font-serif:   'EB Garamond', Georgia, 'Times New Roman', serif;
}

/* Edizione Mattina — black ink on warm newsprint */
html[data-edition="mattina"] {
    --bg:        #f0ebe0;
    --ink:       #0b0a08;
    --ink-soft:  #2c2820;
    --muted:     #6e675a;
    --accent:    #000000;

    --tri-green: #1f7a4d;
    --tri-white: #faf7f0;
    --tri-red:   #b23b2f;
    --tri-white-edge: rgba(11, 10, 8, 0.18);

    --hair:         rgba(11, 10, 8, 0.12);
    --hair-strong:  rgba(11, 10, 8, 0.32);
    --hover-wash:   rgba(11, 10, 8, 0.04);
    --focus-ring:   rgba(11, 10, 8, 0.28);

    --grain-opacity: 0.045;
    --grain-blend:   multiply;
    --crown: radial-gradient(90% 55% at 50% -8%, rgba(255, 248, 230, 0.65), transparent 68%);

    /* Seal art is light ink for Sera; invert to a dark stamp on paper */
    --seal-filter: invert(1);

    --theme-color: #f0ebe0;
}

/* ------------------------------------------------------------------ Reset */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    min-height: 100dvh;
    background-color: var(--bg);
    color: var(--ink);
    font-family: var(--font-serif);
    font-size: 18px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    transition: background-color 0.45s ease, color 0.35s ease;
}

::selection {
    background: var(--ink);
    color: var(--bg);
}

/* Accessibility helper — visible to screen readers only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Film grain + a soft crown of light for depth (self-contained overlays) */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    opacity: var(--grain-opacity);
    mix-blend-mode: var(--grain-blend);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    transition: opacity 0.45s ease;
}

body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background: var(--crown);
    transition: opacity 0.45s ease;
}

/* ------------------------------------------------------------------ Skip link */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 10;
}

.skip-link:focus {
    left: 1rem;
    top: 1rem;
    background: var(--ink);
    color: var(--bg);
    padding: 0.6rem 1rem;
    font-family: var(--font-serif);
    letter-spacing: 0.05em;
    border-radius: 2px;
}

/* ------------------------------------------------------------------ Page shell */
.page {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 37rem;
    min-height: 100dvh;
    margin-inline: auto;
    padding: clamp(3.25rem, 11vh, 6.5rem) clamp(1.5rem, 6vw, 2.75rem) clamp(2rem, 5vh, 3rem);
    display: flex;
    flex-direction: column;
    container-type: inline-size;
    container-name: page;
}

/* ------------------------------------------------------------------ Masthead */
.masthead {
    text-align: center;
}

.wordmark {
    font-family: var(--font-display);
    /* Didone masthead — heavier weight + lower opsz so hairlines (A/V/M) stay visible on screen */
    font-weight: 700;
    font-optical-sizing: auto;
    /* Smaller optical size = sturdier thins (opsz 96 was dissolving diagonals on mobile) */
    font-variation-settings: "opsz" 14;
    /* Single-line brand lockup: scale to column, never wrap */
    font-size: clamp(1.25rem, 8.6cqi, 2.85rem);
    line-height: 0.98;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    white-space: nowrap;
    color: var(--ink);
    /* Tiny stroke reinforces hairlines without looking outlined */
    -webkit-text-stroke: 0.35px currentColor;
    paint-order: stroke fill;
}

/* Fallback when container query units are unavailable */
@supports not (font-size: 1cqi) {
    .wordmark {
        font-size: clamp(1.1rem, 5.2vw + 0.25rem, 2.5rem);
    }
}

.payoff {
    margin-top: 1.15rem;
    font-family: var(--font-display);
    font-weight: 400;
    font-optical-sizing: auto;
    font-size: clamp(0.62rem, 2.0vw, 0.78rem);
    letter-spacing: 0.28em;
    text-transform: uppercase;
    color: var(--ink-soft);
    padding-left: 0.28em; /* offset trailing letter-spacing */
}

.masthead-rule {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    margin-top: 1.7rem;
    padding: 0.55rem 0;
    border-top: 1px solid var(--hair-strong);
    border-bottom: 1px solid var(--hair-strong);
    font-family: var(--font-serif);
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 0.68rem;
    color: var(--muted);
}

.rule-date {
    color: var(--ink-soft);
    white-space: nowrap;
}

.tagline {
    max-width: 30rem;
    margin: 1.65rem auto 0;
    font-style: italic;
    font-size: clamp(1.05rem, 3.3vw, 1.28rem);
    line-height: 1.5;
    color: var(--ink-soft);
    text-wrap: balance;
}

.tricolore {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: clamp(1.9rem, 5vw, 2.4rem);
}

.tricolore span {
    width: 22px;
    height: 3px;
    border-radius: 1px;
}

.tri-green { background: var(--tri-green); }
.tri-white {
    background: var(--tri-white);
    box-shadow: inset 0 0 0 1px var(--tri-white-edge);
}
.tri-red   { background: var(--tri-red); }


/* ------------------------------------------------------------------ Edition toggle (Mattina / Sera)
   Tiny corner meta-label — newspaper masthead style, never competes with the wordmark. */
.edition-toggle {
    position: absolute;
    top: 0.85rem;
    right: clamp(0.65rem, 3vw, 1.1rem);
    z-index: 2;
    margin: 0;
    padding: 0.35rem 0.2rem;
    font-family: var(--font-serif);
    font-size: 0.58rem;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    line-height: 1;
    color: var(--muted);
    background: transparent;
    border: none;
    border-bottom: 1px solid transparent;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    opacity: 0.55;
    transition:
        color 0.25s ease,
        opacity 0.25s ease,
        border-color 0.25s ease;
}

.edition-toggle:hover,
.edition-toggle:focus-visible {
    color: var(--ink-soft);
    opacity: 0.95;
    border-bottom-color: var(--hair-strong);
    outline: none;
}

.edition-toggle:focus-visible {
    box-shadow: 0 0 0 2px var(--focus-ring);
    border-radius: 1px;
}

.edition-name {
    color: inherit;
}

/* Soften colour transitions for ink-bound elements */
.wordmark,
.payoff,
.masthead-rule,
.tagline,
.link,
.link-title,
.link-kicker,
.link-sub,
.link-arrow,
.colophon,
.contact-kicker,
.contact-btn,
.contact-email,
.credit a {
    transition:
        color 0.35s ease,
        background-color 0.35s ease,
        border-color 0.35s ease,
        box-shadow 0.25s ease,
        transform 0.25s ease,
        opacity 0.3s ease;
}

/* ------------------------------------------------------------------ Links */
.links {
    margin-top: clamp(2.5rem, 7vw, 3.5rem);
    border-top: 1px solid var(--hair);
}

.link {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
    padding: 1.5rem clamp(0.5rem, 2.5vw, 1rem);
    border-bottom: 1px solid var(--hair);
    text-decoration: none;
    color: var(--ink);
    transition: background-color 0.25s ease, box-shadow 0.25s ease;
}

.link:hover,
.link:focus-visible {
    background-color: var(--hover-wash);
    box-shadow: inset 3px 0 0 var(--accent);
    outline: none;
}

.link:focus-visible {
    box-shadow: inset 3px 0 0 var(--accent), inset 0 0 0 2px var(--focus-ring);
}

.link-text {
    display: flex;
    flex-direction: column;
    gap: 0.32rem;
    min-width: 0;
}

.link-kicker {
    font-family: var(--font-serif);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    font-size: 0.68rem;
    color: var(--muted);
}

.link-title {
    font-family: var(--font-serif);
    font-weight: 500;
    font-size: clamp(1.4rem, 5.5vw, 1.72rem);
    line-height: 1.15;
    letter-spacing: 0.005em;
    color: var(--ink);
    transition: color 0.2s ease;
}

.link:hover .link-title,
.link:focus-visible .link-title {
    color: var(--accent);
}

.link-sub {
    font-family: var(--font-serif);
    font-size: 0.94rem;
    line-height: 1.35;
    color: var(--muted);
}

.link-arrow {
    flex: none;
    font-family: var(--font-serif);
    font-size: 1.5rem;
    color: var(--muted);
    transition: transform 0.25s ease, color 0.2s ease;
}

.link:hover .link-arrow,
.link:focus-visible .link-arrow {
    transform: translateX(6px);
    color: var(--accent);
}

/* ------------------------------------------------------------------ Colophon + official seal */
.colophon {
    margin-top: auto;
    padding-top: clamp(2.75rem, 8vw, 4.25rem);
    text-align: center;
    font-family: var(--font-serif);
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    line-height: 1.85;
    color: var(--muted);
}

/* The emblem, stamped like an official ink seal at the foot of the bulletin. */
.seal {
    display: block;
    width: clamp(88px, 23vw, 120px);
    height: auto;
    margin: 0 auto clamp(1.9rem, 5.5vw, 2.6rem);
    opacity: 0.92;
    transform: rotate(-4deg);
    filter: var(--seal-filter);
    transition:
        transform 0.55s cubic-bezier(0.2, 0.7, 0.2, 1),
        opacity 0.3s ease,
        filter 0.45s ease;
}

/* Get in touch — Segreteria di Redazione */
.contact {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin: 0 auto clamp(2.25rem, 6vw, 3rem);
}

.contact-kicker {
    font-family: var(--font-serif);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    font-size: 0.68rem;
    color: var(--muted);
}

.contact-btn {
    font-family: var(--font-display);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.13em;
    font-size: 0.78rem;
    color: var(--ink);
    background: transparent;
    text-decoration: none;
    padding: 0.8rem 1.9rem;
    border: 1px solid var(--hair-strong);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    white-space: nowrap;
    transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

.contact-btn:hover,
.contact-btn:focus-visible,
.contact-btn.is-copied {
    background: var(--ink);
    color: var(--bg);
    border-color: var(--ink);
    outline: none;
}

.contact-email {
    font-family: var(--font-serif);
    font-size: 0.85rem;
    letter-spacing: 0.02em;
    color: var(--muted);
    text-decoration: none;
    transition: color 0.2s ease;
}

.contact-email:hover,
.contact-email:focus-visible {
    color: var(--ink);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.colophon:hover .seal,
.seal:hover {
    transform: rotate(0deg);
    opacity: 1;
}

.colophon strong {
    color: var(--ink-soft);
    font-weight: 600;
}

/* Discreet maker's credit — muted at rest, a whisper of ApexForge green on hover */
.credit {
    margin-top: 1.5rem;
    font-size: 0.66rem;
    letter-spacing: 0.06em;
    opacity: 0.7;
}

.credit a {
    color: var(--muted);
    text-decoration: none;
    transition: color 0.2s ease;
}

.credit a:hover,
.credit a:focus-visible {
    color: var(--ink-soft);
    outline: none;
}

.credit a:hover .credit-name,
.credit a:focus-visible .credit-name {
    color: #00ffa3;
}

/* ------------------------------------------------------------------ Responsive */
@media (max-width: 480px) {
    .masthead-rule {
        gap: 0;
        justify-content: center;
    }
    .rule-side {
        display: none; /* keep only the dateline on small screens */
    }
    .link {
        padding-inline: 0.25rem;
        gap: 1rem;
    }
    .link-arrow {
        font-size: 1.3rem;
    }
    .contact-btn {
        padding: 0.75rem 1.4rem;
        font-size: 0.72rem;
        letter-spacing: 0.1em;
    }
}

/* ------------------------------------------------------------------ Motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition: none !important;
        animation: none !important;
    }
}

/* ------------------------------------------------------------------ Coming Soon (temporary Bottega page) */
.page--coming-soon {
    justify-content: flex-start;
}

.coming-soon {
    margin-top: clamp(2.5rem, 8vw, 4rem);
    padding: clamp(2rem, 6vw, 3rem) clamp(0.5rem, 2.5vw, 1rem);
    border-top: 1px solid var(--hair-strong);
    border-bottom: 1px solid var(--hair-strong);
    text-align: center;
}

.coming-soon-kicker {
    font-family: var(--font-serif);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.22em;
    font-size: 0.68rem;
    color: var(--muted);
}

.coming-soon-title {
    margin-top: 1rem;
    font-family: var(--font-display);
    font-weight: 700;
    font-optical-sizing: auto;
    font-variation-settings: "opsz" 24;
    font-size: clamp(2.4rem, 11vw, 3.6rem);
    line-height: 1.05;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink);
    -webkit-text-stroke: 0.35px currentColor;
    paint-order: stroke fill;
}

.coming-soon-lead {
    max-width: 26rem;
    margin: 1.5rem auto 0;
    font-style: italic;
    font-size: clamp(1.1rem, 3.5vw, 1.3rem);
    line-height: 1.5;
    color: var(--ink-soft);
    text-wrap: balance;
}

.coming-soon-note {
    margin-top: 0.85rem;
    font-family: var(--font-serif);
    font-size: 0.95rem;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.coming-soon-back {
    display: inline-block;
    margin-top: clamp(2rem, 5vw, 2.75rem);
    text-decoration: none;
}

.coming-soon-title,
.coming-soon-kicker,
.coming-soon-lead,
.coming-soon-note {
    transition: color 0.35s ease;
}
