/* C'era una favola — notte stellata */

@font-face {
    font-family: "Fraunces";
    src: url("../fonts/fraunces-latin-wght-normal.woff2") format("woff2");
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Literata";
    src: url("../fonts/literata-latin-wght-normal.woff2") format("woff2");
    font-weight: 200 900;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Literata";
    src: url("../fonts/literata-latin-wght-italic.woff2") format("woff2");
    font-weight: 200 900;
    font-style: italic;
    font-display: swap;
}

:root {
    --night-900: #070a22;
    --night-800: #0b1033;
    --night-700: #141a4a;
    --night-600: #1f2766;
    --ink: #f1f2ff;
    --ink-soft: #bcc1ea;
    --moon: #ffeab0;
    --gold: #ffd166;
    --lilac: #b9a7ff;
    --rose: #ff9fb8;
    --surface: rgba(255, 255, 255, 0.06);
    --surface-strong: rgba(255, 255, 255, 0.1);
    --line: rgba(255, 255, 255, 0.14);
    --radius: 20px;
    --font-display: "Fraunces", Georgia, serif;
    --font-body: "Literata", Georgia, "Times New Roman", serif;
    --story-size: 1.25rem;
    color-scheme: dark;
}

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

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

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: linear-gradient(180deg, var(--night-900) 0%, var(--night-800) 35%, var(--night-700) 100%) fixed;
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 1.0625rem;
    line-height: 1.6;
}

main {
    flex: 1;
}

/* Cielo stellato: più strati con passo diverso, così la ripetizione non si nota */
.sky {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background-image:
        radial-gradient(1.6px 1.6px at 23px 41px, #fff 50%, transparent 52%),
        radial-gradient(1.2px 1.2px at 147px 96px, #fff 50%, transparent 52%),
        radial-gradient(1px 1px at 88px 171px, var(--moon) 50%, transparent 52%),
        radial-gradient(1.4px 1.4px at 211px 29px, #dcd6ff 50%, transparent 52%),
        radial-gradient(1px 1px at 301px 233px, #fff 50%, transparent 52%),
        radial-gradient(2px 2px at 59px 307px, var(--moon) 50%, transparent 52%);
    background-size: 233px 233px, 311px 311px, 197px 197px, 389px 389px, 457px 457px, 523px 523px;
    opacity: 0.55;
    animation: twinkle 7s ease-in-out infinite alternate;
}

@keyframes twinkle {
    from { opacity: 0.35; }
    to { opacity: 0.65; }
}

a {
    color: var(--moon);
    text-underline-offset: 0.18em;
}
a:hover {
    color: #fff;
}

:focus-visible {
    outline: 3px solid var(--gold);
    outline-offset: 3px;
    border-radius: 6px;
}

h1, h2, h3 {
    font-family: var(--font-display);
    font-weight: 600;
    line-height: 1.15;
    margin: 0 0 0.5em;
    text-wrap: balance;
}

p {
    margin: 0 0 1em;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

[hidden] {
    display: none !important;
}

.wrap {
    width: min(100% - 2rem, 1120px);
    margin-inline: auto;
}
.wrap--narrow {
    width: min(100% - 2rem, 720px);
}

.section {
    padding-block: 2rem;
}
.section__title {
    font-size: clamp(1.5rem, 1.2rem + 1.4vw, 2rem);
    margin-bottom: 1rem;
}
.section__more {
    margin-top: 2rem;
    text-align: center;
}
.page-title {
    font-size: clamp(1.9rem, 1.4rem + 2.4vw, 2.8rem);
}
.lead {
    color: var(--ink-soft);
    max-width: 60ch;
}
.empty {
    padding: 2rem 1.25rem;
    text-align: center;
    color: var(--ink-soft);
    background: var(--surface);
    border: 1px dashed var(--line);
    border-radius: var(--radius);
}

.skip {
    position: absolute;
    left: 1rem;
    top: -4rem;
    z-index: 10;
    padding: 0.6rem 1rem;
    background: var(--gold);
    color: var(--night-900);
    border-radius: 10px;
}
.skip:focus {
    top: 1rem;
    color: var(--night-900);
}

/* Intestazione */
.site-header {
    border-bottom: 1px solid var(--line);
    background: rgba(7, 10, 34, 0.6);
    backdrop-filter: blur(8px);
}
.site-header__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1.5rem;
    padding-block: 0.85rem;
}
.logo {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 650;
    color: var(--ink);
    text-decoration: none;
}
.logo__moon {
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    box-shadow: inset -0.42rem -0.12rem 0 0 var(--moon);
    transform: rotate(-20deg);
}
.nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
}
.nav a,
.linklike {
    display: inline-block;
    padding: 0.45rem 0.8rem;
    border-radius: 999px;
    color: var(--ink);
    text-decoration: none;
    font: inherit;
}
.nav a:hover,
.linklike:hover {
    background: var(--surface-strong);
}
.nav a[aria-current="page"] {
    background: var(--surface-strong);
    color: var(--moon);
}
.nav__count {
    display: inline-block;
    min-width: 1.4em;
    padding: 0 0.35em;
    border-radius: 999px;
    background: var(--rose);
    color: var(--night-900);
    font-size: 0.8em;
    font-weight: 700;
    line-height: 1.4;
    text-align: center;
}
.linklike {
    background: none;
    border: 0;
    cursor: pointer;
}

/* Bottoni */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.9rem;
    padding: 0.6rem 1.3rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.15s, transform 0.15s;
}
.btn:hover {
    background: var(--surface-strong);
    color: #fff;
    transform: translateY(-1px);
}
.btn--primary {
    border-color: transparent;
    background: var(--gold);
    color: var(--night-900);
}
.btn--primary:hover {
    background: var(--moon);
    color: var(--night-900);
}
.btn--danger {
    border-color: var(--rose);
    color: var(--rose);
}

/* Hero */
.hero {
    padding-block: clamp(2.5rem, 7vw, 5.5rem);
}
.hero__inner {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 2rem;
}
.hero h1 {
    font-size: clamp(2.6rem, 1.6rem + 5.5vw, 5rem);
    font-weight: 500;
    font-style: italic;
    color: var(--moon);
    margin-bottom: 0.3em;
}
.hero__lead {
    max-width: 34ch;
    font-size: clamp(1.15rem, 1rem + 0.7vw, 1.45rem);
    color: var(--ink-soft);
}
.hero__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin: 1.75rem 0 0;
}
.hero__moon {
    width: clamp(7rem, 22vw, 15rem);
    aspect-ratio: 1;
    border-radius: 50%;
    background:
        radial-gradient(circle at 32% 30%, rgba(0, 0, 0, 0.07) 0 9%, transparent 10%),
        radial-gradient(circle at 64% 58%, rgba(0, 0, 0, 0.06) 0 13%, transparent 14%),
        radial-gradient(circle at 38% 72%, rgba(0, 0, 0, 0.05) 0 6%, transparent 7%),
        radial-gradient(circle at 35% 30%, #fff8dc, var(--moon) 60%, #f3d68a);
    box-shadow: 0 0 60px 12px rgba(255, 234, 176, 0.28), 0 0 160px 50px rgba(255, 234, 176, 0.12);
    animation: float 9s ease-in-out infinite alternate;
}

@keyframes float {
    from { transform: translateY(-6px); }
    to { transform: translateY(6px); }
}

/* Copertine: se non c'è un'illustrazione, un simbolo su un cielo colorato */
.cover {
    position: relative;
    display: grid;
    place-items: center;
    aspect-ratio: 3 / 2;
    overflow: hidden;
    border-radius: calc(var(--radius) - 6px);
    background: linear-gradient(160deg, #2a2f8f, #5b3fa8);
}
.cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.cover__symbol {
    font-size: clamp(3rem, 9vw, 4.5rem);
    line-height: 1;
    filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.35));
}
.cover--large .cover__symbol {
    font-size: clamp(4.5rem, 16vw, 7.5rem);
}
.cover::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image:
        radial-gradient(1.5px 1.5px at 18% 22%, #fff 50%, transparent 52%),
        radial-gradient(1px 1px at 72% 16%, #fff 50%, transparent 52%),
        radial-gradient(1.5px 1.5px at 86% 64%, #fff 50%, transparent 52%),
        radial-gradient(1px 1px at 30% 78%, #fff 50%, transparent 52%),
        radial-gradient(1px 1px at 55% 40%, #fff 50%, transparent 52%);
    opacity: 0.7;
}
.cover:has(img)::after {
    display: none;
}
.cover--0 { background: linear-gradient(160deg, #23308f, #5a3fa8); }
.cover--1 { background: linear-gradient(160deg, #0f4c75, #2d7f9d); }
.cover--2 { background: linear-gradient(160deg, #5a2a7a, #b0487f); }
.cover--3 { background: linear-gradient(160deg, #1d5a4c, #3f8f6b); }
.cover--4 { background: linear-gradient(160deg, #7a3b1f, #c17a3a); }
.cover--5 { background: linear-gradient(160deg, #2b2a6b, #3f6fb5); }

/* Card */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
    gap: 1.25rem;
}
.card {
    position: relative;
    display: flex;
    flex-direction: column;
    padding: 0.75rem 0.75rem 1rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    transition: transform 0.2s, background-color 0.2s, border-color 0.2s;
}
.card:hover {
    transform: translateY(-3px);
    background: var(--surface-strong);
    border-color: rgba(255, 234, 176, 0.4);
}
.card__link {
    color: var(--ink);
    text-decoration: none;
}
/* Tutta la card è cliccabile, ma il cuore resta sopra */
.card__link::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: var(--radius);
}
.card__title {
    margin: 0.9rem 0.35rem 0.35rem;
    font-size: 1.3rem;
}
.card__excerpt {
    margin: 0 0.35rem 0.9rem;
    color: var(--ink-soft);
    font-size: 0.98rem;
}
.card .meta {
    margin: auto 0.35rem 0;
}

.meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin: 0;
    padding: 0;
    list-style: none;
    font-size: 0.85rem;
}
.meta li {
    padding: 0.15rem 0.65rem;
    border-radius: 999px;
    background: rgba(185, 167, 255, 0.16);
    color: #ddd5ff;
}
.meta a {
    color: inherit;
}

.fav {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 1;
    width: 2.75rem;
    height: 2.75rem;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 50%;
    background: rgba(7, 10, 34, 0.6);
    color: #fff;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    transition: transform 0.15s, background-color 0.15s, color 0.15s;
}
.fav:hover {
    transform: scale(1.1);
}
.fav[aria-pressed="true"] {
    background: #fff;
    color: #e63e6d;
}

/* La favola di stasera */
.tonight {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
    gap: 1.5rem;
    align-items: center;
    padding: 1rem;
    background: linear-gradient(135deg, rgba(255, 234, 176, 0.12), var(--surface));
    border: 1px solid rgba(255, 234, 176, 0.35);
    border-radius: calc(var(--radius) + 4px);
    color: var(--ink);
    text-decoration: none;
    transition: transform 0.2s;
}
.tonight:hover {
    transform: translateY(-3px);
    color: var(--ink);
}
.tonight h3 {
    font-size: clamp(1.5rem, 1.2rem + 1.6vw, 2.2rem);
    color: var(--moon);
}
.tonight p {
    color: var(--ink-soft);
}

/* Scelta rapida */
.pick {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
    gap: 1.5rem;
    padding: 1.5rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
.pick__label {
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-soft);
    margin-bottom: 0.75rem;
}
.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}
.chip {
    display: inline-block;
    padding: 0.5rem 1rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    color: var(--ink);
    text-decoration: none;
}
.chip:hover {
    border-color: var(--moon);
    color: var(--moon);
}

/* Filtri e campi */
.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 0.75rem;
    padding: 1rem;
    margin-bottom: 1rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
.field {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 9.5rem;
}
.field--grow {
    flex: 1 1 14rem;
}
.field > span,
.field > label > span {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ink-soft);
}
input[type="text"],
input[type="search"],
input[type="password"],
input[type="file"],
select,
textarea {
    width: 100%;
    min-height: 2.9rem;
    padding: 0.55rem 0.85rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(7, 10, 34, 0.6);
    color: var(--ink);
    font: inherit;
}
input::placeholder {
    color: #8f95c4;
}
.results {
    color: var(--ink-soft);
    margin-bottom: 1.25rem;
}
.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
    color: var(--ink-soft);
}

/* Pagina della favola */
.story {
    padding-block: 1.5rem 1rem;
}
.story__header h1 {
    margin-top: 1.5rem;
    font-size: clamp(2.1rem, 1.5rem + 3.2vw, 3.4rem);
    color: var(--moon);
}
.story__tools {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1.25rem;
}
.tool {
    min-width: 2.9rem;
    min-height: 2.9rem;
    padding: 0.4rem 0.9rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
.tool:hover {
    background: var(--surface-strong);
}
.tool:disabled {
    opacity: 0.4;
    cursor: default;
}
.tool--fav[aria-pressed="true"] {
    border-color: var(--rose);
    color: var(--rose);
}
.story__body {
    margin-top: 2rem;
    font-size: var(--story-size);
    line-height: 1.8;
    hyphens: auto;
}
.story__body p {
    margin-bottom: 1.2em;
}
.story__body > p:first-child::first-letter {
    float: left;
    margin: 0.08em 0.12em 0 0;
    font-family: var(--font-display);
    font-size: 3.6em;
    font-weight: 600;
    line-height: 0.85;
    color: var(--gold);
}
.story[data-size="0"] { --story-size: 1.1rem; }
.story[data-size="2"] { --story-size: 1.45rem; }
.story[data-size="3"] { --story-size: 1.7rem; }

.moral {
    margin-top: 2.5rem;
    padding: 1.25rem 1.5rem;
    border-left: 4px solid var(--gold);
    border-radius: 0 var(--radius) var(--radius) 0;
    background: rgba(255, 209, 102, 0.1);
}
.moral h2 {
    font-size: 1.1rem;
    color: var(--gold);
    margin-bottom: 0.35rem;
}
.moral p {
    margin: 0;
    font-style: italic;
    font-size: 1.15rem;
}
.story__end {
    margin: 2.5rem 0 0;
    text-align: center;
    color: var(--moon);
    letter-spacing: 0.6em;
}
.preview-bar {
    margin: 0;
    padding: 0.6rem 1rem;
    background: var(--gold);
    color: var(--night-900);
    text-align: center;
    font-weight: 600;
}
.preview-bar a {
    color: inherit;
}

/* Pagine di testo */
.prose h2 {
    margin-top: 2rem;
    font-size: 1.4rem;
    color: var(--moon);
}
.prose p {
    max-width: 65ch;
}

/* Piè di pagina */
.site-footer {
    margin-top: 3rem;
    padding-block: 2rem;
    border-top: 1px solid var(--line);
    text-align: center;
    color: var(--ink-soft);
}
.site-footer__sign {
    font-family: var(--font-display);
    font-style: italic;
    font-size: 1.4rem;
    color: var(--moon);
}
.site-footer__links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem 1.5rem;
    margin: 0 0 1rem;
    padding: 0;
    list-style: none;
}
.site-footer__note {
    margin: 0;
    font-size: 0.9rem;
}

@media (max-width: 640px) {
    .hero__inner {
        grid-template-columns: 1fr;
    }
    .hero__moon {
        order: -1;
    }
    .tonight {
        grid-template-columns: 1fr;
    }
    .filters .btn {
        width: 100%;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
    html {
        scroll-behavior: auto;
    }
}

@media print {
    .sky, .site-header, .site-footer, .story__tools, .breadcrumb, .section, .fav, .preview-bar {
        display: none !important;
    }
    body {
        background: #fff;
        color: #000;
    }
    .story__header h1, .moral h2 {
        color: #000;
    }
}

/* Percorso di navigazione */
.breadcrumb ol {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.5rem;
    margin: 0 0 1.25rem;
    padding: 0;
    list-style: none;
    font-size: 0.9rem;
    color: var(--ink-soft);
}
.breadcrumb li + li::before {
    content: "›";
    margin-right: 0.5rem;
    opacity: 0.6;
}
.breadcrumb a {
    color: var(--ink-soft);
    text-decoration: none;
}
.breadcrumb a:hover {
    color: var(--moon);
}

/* Elenco delle categorie */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
    gap: 1.25rem;
    margin: 1.5rem 0 0;
    padding: 0;
    list-style: none;
}
.category-card {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    height: 100%;
    padding: 1.5rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: var(--ink);
    text-decoration: none;
    transition: transform 0.2s, background-color 0.2s, border-color 0.2s;
}
.category-card:hover {
    transform: translateY(-3px);
    background: var(--surface-strong);
    border-color: rgba(255, 234, 176, 0.4);
    color: var(--ink);
}
.category-card__symbol {
    font-size: 2.5rem;
    line-height: 1.1;
}
.category-card__name {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--moon);
}
.category-card__count {
    font-size: 0.85rem;
    color: #ddd5ff;
}
.category-card__text {
    margin-top: 0.4rem;
    color: var(--ink-soft);
    font-size: 0.98rem;
}
