/* Diari Segreti - stile base.
   Tema chiaro di default, tema scuro automatico con prefers-color-scheme. */

@font-face {
    font-family: 'Cormorant Garamond';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url(../fonts/cormorant-garamond-600.woff2) format('woff2');
}
@font-face {
    font-family: 'Cormorant Garamond';
    font-style: italic;
    font-weight: 500;
    font-display: swap;
    src: url(../fonts/cormorant-garamond-italic-500.woff2) format('woff2');
}
@font-face {
    font-family: 'Nunito Sans';
    font-style: normal;
    font-weight: 400 700;
    font-display: swap;
    src: url(../fonts/nunito-sans-latin.woff2) format('woff2');
}

:root {
    color-scheme: light dark;

    --bg: #f7f1f5;
    --surface: #ffffff;
    --surface-2: #f3e8ef;
    --border: #e6d5df;
    --divider: #dcc6d3;
    --text-strong: #2b1a26;
    --text: #4f3f4b;
    --muted: #7a6675;
    --accent: #a22a68;
    --btn: #832454;
    --btn-hover: #661b40;
    --btn-text: #ffffff;
    --ghost-border: #c9a6b9;
    --ghost-text: #832454;
    --input-bg: #ffffff;
    --input-border: #c9a6b9;
    --danger: #c0392b;
    --focus: #832454;

    --header-bg: #832454;
    --header-border: #661b40;
    --header-link: #f6dbe8;
    --header-active: #ffffff;
    --header-underline: #ffffff;
    --header-ghost-border: #e6aac6;
    --header-cta-bg: #ffffff;
    --header-cta-text: #832454;
    --footer-bg: #661b40;
    --footer-border: #380d22;
    --footer-text: #f6dbe8;
    --dot: #d9c3d0;

    --font-title: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
    --font-body: 'Nunito Sans', 'Trebuchet MS', Arial, sans-serif;
}

/* Tema scuro: automatico (senza scelta dell'utente) o scelto con l'interruttore nel footer.
   Le due liste di variabili devono restare identiche. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --bg: #16101a;
        --surface: #1f1725;
        --surface-2: #281d2f;
        --border: #3a2a43;
        --divider: #3a2a43;
        --text-strong: #f4ecf3;
        --text: #d2c4d0;
        --muted: #ab9aa9;
        --accent: #ff8cc4;
        --btn: #b02a6b;
        --btn-hover: #c2337a;
        --btn-text: #ffffff;
        --ghost-border: #5a4267;
        --ghost-text: #f4ecf3;
        --input-bg: #16101a;
        --input-border: #4a3854;
        --danger: #ff7a7a;
        --focus: #ff8cc4;

        --header-bg: #1c1421;
        --header-border: #35263d;
        --header-link: #d2c4d0;
        --header-active: #ffffff;
        --header-underline: #ff8cc4;
        --header-ghost-border: #5a4267;
        --header-cta-bg: #b02a6b;
        --header-cta-text: #ffffff;
        --footer-bg: #110c15;
        --footer-border: #2a1e31;
        --footer-text: #ab9aa9;
        --dot: #4a3854;
    }
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] {
    color-scheme: dark;

    --bg: #16101a;
    --surface: #1f1725;
    --surface-2: #281d2f;
    --border: #3a2a43;
    --divider: #3a2a43;
    --text-strong: #f4ecf3;
    --text: #d2c4d0;
    --muted: #ab9aa9;
    --accent: #ff8cc4;
    --btn: #b02a6b;
    --btn-hover: #c2337a;
    --btn-text: #ffffff;
    --ghost-border: #5a4267;
    --ghost-text: #f4ecf3;
    --input-bg: #16101a;
    --input-border: #4a3854;
    --danger: #ff7a7a;
    --focus: #ff8cc4;

    --header-bg: #1c1421;
    --header-border: #35263d;
    --header-link: #d2c4d0;
    --header-active: #ffffff;
    --header-underline: #ff8cc4;
    --header-ghost-border: #5a4267;
    --header-cta-bg: #b02a6b;
    --header-cta-text: #ffffff;
    --footer-bg: #110c15;
    --footer-border: #2a1e31;
    --footer-text: #ab9aa9;
    --dot: #4a3854;
}

* { box-sizing: border-box; }
html, body, h1, h2, h3, div, p, form, input, button, ul, li { margin: 0; padding: 0; }
body {
    font-family: var(--font-body);
    font-size: 100%;
    line-height: 1.65;
    color: var(--text);
    background-color: var(--bg);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
img { max-width: 100%; height: auto; }
a { color: var(--accent); }
a:focus-visible, button:focus-visible, input:focus-visible, textarea:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}
input, textarea, select, button { font-family: var(--font-body); }
h1, h2, h3 { color: var(--text-strong); }
.wrap { width: min(1200px, 100% - 32px); margin: 0 auto; }
.hidden { display: none !important; }

/* ---------- Header ---------- */
.site-header {
    background: var(--header-bg);
    border-bottom: 1px solid var(--header-border);
}
.header-inner {
    display: flex;
    align-items: stretch;
    gap: 32px;
    min-height: 72px;
}
.brand { display: flex; align-items: center; line-height: 0; }
.brand img { height: 46px; width: auto; display: block; }
.mainnav {
    display: flex;
    align-items: stretch;
    gap: 32px;
    flex-grow: 1;
}
.navlinks {
    list-style: none;
    display: flex;
    align-items: stretch;
    gap: 4px;
    flex-grow: 1;
}
.navlinks li { display: flex; }
.navlinks a {
    display: flex;
    align-items: center;
    padding: 0 16px;
    border-bottom: 3px solid transparent;
    color: var(--header-link);
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
}
.navlinks a:hover { color: var(--header-active); }
.navlinks a.active {
    color: var(--header-active);
    font-weight: 700;
    border-bottom-color: var(--header-underline);
}
.navlinks li.solo-mobile { display: none; }
.navactions { display: flex; align-items: center; gap: 12px; }
.navactions a {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    padding: 0 24px;
    border: 1px solid var(--header-ghost-border);
    border-radius: 999px;
    color: var(--header-active);
    font-size: 15px;
    font-weight: 700;
    text-decoration: none;
}
.navactions a.active { background: rgba(255, 255, 255, 0.12); }
.navactions a.cta {
    background: var(--header-cta-bg);
    border-color: var(--header-cta-bg);
    color: var(--header-cta-text);
}
.navtoggle {
    display: none;
    width: 48px;
    height: 48px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    background: transparent;
    border: 0;
    cursor: pointer;
    align-self: center;
}
.navtoggle .icon-bar {
    display: block;
    width: 24px;
    height: 2px;
    border-radius: 1px;
    background: var(--header-active);
}

/* ---------- Layout ---------- */
main.wrap {
    padding: 40px 0 64px;
    display: flex;
    flex-direction: column;
    gap: 40px;
    flex-grow: 1;
}
.layout { display: block; }
.layout.has-news {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 32px;
    align-items: start;
}
.layout.has-news .posts { grid-column: span 8; }
.layout.has-news .newsfeed { grid-column: span 4; }
.posts { display: flex; flex-direction: column; gap: 32px; }

/* ---------- Hero / slider ---------- */
.hero {
    display: grid;
    padding: 32px 40px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 24px;
}
.diapositiva {
    grid-area: 1 / 1;
    display: flex;
    align-items: center;
    gap: 40px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.7s ease, visibility 0.7s;
}
.diapositiva.active { opacity: 1; visibility: visible; }
.slide-text { flex-grow: 1; display: flex; flex-direction: column; gap: 12px; }
.hero-title {
    font-family: var(--font-title);
    font-weight: 600;
    font-size: 40px;
    line-height: 1.1;
    color: var(--text-strong);
}
.hero-text { font-size: 16px; line-height: 1.65; max-width: 640px; }
.slide-img {
    width: 260px;
    height: 150px;
    flex-shrink: 0;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border);
}
.slide-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hero-cta { display: flex; gap: 12px; margin-top: 8px; }
.hero-dots { grid-area: 2 / 1; display: flex; gap: 8px; margin-top: 24px; }
.hero-dots .dot {
    width: 10px;
    height: 6px;
    padding: 0;
    border: 0;
    border-radius: 3px;
    background: var(--dot);
    cursor: pointer;
    transition: width 0.3s ease, background-color 0.3s ease;
}
.hero-dots .dot.active { width: 28px; background: var(--accent); }

.page-index .hero { padding: 48px; }
.page-index .diapositiva { gap: 48px; }
.page-index .hero-title { font-size: 68px; line-height: 1; }
.page-index .hero-title em { color: var(--accent); font-weight: 500; }
.page-index .hero-text { font-size: 19px; line-height: 1.6; max-width: 520px; }
.page-index .slide-text { gap: 20px; }
.page-index .slide-img { width: 440px; height: 300px; border-radius: 20px; }
.page-faq .hero-title { font-size: 44px; }

/* ---------- Card / contenuti ---------- */
.card {
    padding: 32px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
}
.post-title {
    font-family: var(--font-title);
    font-weight: 600;
    font-size: 40px;
    line-height: 1.1;
    margin-bottom: 16px;
}
h1.post-title { font-size: 44px; }
.post-body { display: flex; gap: 28px; align-items: flex-start; }
.post-img {
    width: 190px;
    height: 190px;
    flex-shrink: 0;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border);
}
.post-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.post-text {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex-grow: 1;
    min-width: 0;
    font-size: 16px;
    line-height: 1.7;
}
.post-text > p > span:first-child { color: var(--accent); font-weight: 700; font-style: normal; }
.post-text a span { color: inherit; font: inherit; }
.post-text a { font-weight: 700; }
.post-text p.style-paragraf { color: var(--accent); font-style: italic; }
.post-text .list-vitae ul { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.post-text .list-vitae li {
    position: relative;
    padding-left: 32px;
    line-height: 1.5;
}
.post-text .list-vitae li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.2em;
    width: 20px;
    height: 20px;
    background: var(--accent);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / contain no-repeat;
}
.post-text .list-vitae.small, .post-text .list-vitae ul.small { font-size: 14px; }
.post-text .list-vitae ul.small li::before { top: 0.15em; width: 18px; height: 18px; }
.post-text .list-vitae > p { margin-bottom: 10px; }

/* Bottoni */
.btn, .btn-main {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 46px;
    padding: 0 28px;
    border: 1px solid var(--btn);
    border-radius: 999px;
    background: var(--btn);
    color: var(--btn-text);
    font-size: 15px;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}
.btn:hover, .btn-main:hover { background: var(--btn-hover); border-color: var(--btn-hover); }
.post-text .btn-main, .post-text .btn { color: var(--btn-text); }
.btn-ghost, .post-text .btn-ghost {
    background: transparent;
    border-color: var(--ghost-border);
    color: var(--ghost-text);
}
.btn-ghost:hover, .btn-main.btn-ghost:hover { background: var(--surface-2); border-color: var(--ghost-border); }
.page-index .hero-cta .btn { height: 50px; padding: 0 32px; font-size: 16px; }

/* ---------- Pagine specifiche ---------- */
.page-login .posts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
.page-login .posts > .card:nth-child(2) { background: var(--surface-2); }
.page-login .card { padding: 36px; }
.page-login .post-img { float: right; width: 84px; height: 84px; margin: 0 0 12px 16px; }
.page-login .post-body { display: block; }
.page-login .post-body::after { content: ''; display: block; clear: both; }
.page-login .post-text { display: block; }
.page-login .post-text > * + * { margin-top: 16px; }

.page-registrazione .posts, .page-contatti .posts,
.page-ok .posts, .page-logout .posts, .page-privacy .posts {
    width: min(760px, 100%);
    margin: 0 auto;
}
.page-privacy .posts { width: min(900px, 100%); }

/* Link pubblico a una pagina di un diario (pagina_condivisa.html.twig) */
.page-pagina-condivisa .posts { width: min(760px, 100%); margin: 0 auto; }
.pagina-condivisa { display: flex; flex-direction: column; gap: 14px; padding: 40px; }
.pagina-condivisa .post-title { margin: 0; overflow-wrap: anywhere; }
.pagina-condivisa-diario { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.pagina-condivisa-data { font-size: 15px; font-weight: 600; color: var(--accent); }
.pagina-condivisa-foto { margin-top: 6px; border-radius: 16px; overflow: hidden; border: 1px solid var(--border); }
.pagina-condivisa-foto img { display: block; width: 100%; height: auto; }
.pagina-condivisa-testo { font-size: 17px; line-height: 1.75; overflow-wrap: anywhere; }
.pagina-condivisa-testo > * + * { margin-top: 14px; }
.pagina-condivisa-testo ul, .pagina-condivisa-testo ol { padding-left: 24px; }
.pagina-condivisa-testo ul { list-style: disc; }
.pagina-condivisa-testo ol { list-style: decimal; }
.pagina-condivisa-testo blockquote { padding-left: 16px; border-left: 3px solid var(--border); color: var(--muted); }
.pagina-condivisa-testo img { max-width: 100%; height: auto; }
.pagina-condivisa-testo table { max-width: 100%; display: block; overflow-x: auto; }
.pagina-condivisa-testo a { font-weight: 700; }
.pagina-condivisa-nota { margin: 12px 0 0; padding-top: 16px; border-top: 1px solid var(--border); font-size: 14px; color: var(--muted); }
@media (max-width: 575px) {
    .pagina-condivisa { padding: 24px 20px; }
}
.page-registrazione .card, .page-contatti .card { padding: 40px; }

#privacy p { margin-bottom: 14px; font-size: 15px; }
#privacy h3 { color: var(--accent); margin: 8px 0 4px; }
#privacy p:last-child { margin-bottom: 0; }
#privacy ul { margin: 0 0 14px 20px; list-style: disc; font-size: 15px; }
#privacy li { margin-bottom: 6px; }

/* F.A.Q. */
.faq-grid { column-count: 2; column-gap: 32px; }
.faq-item { break-inside: avoid; margin-bottom: 20px; padding: 28px; }
.faq-item.alt { background: var(--surface-2); }
.faq-item h2 {
    font-family: var(--font-body);
    font-size: 18px;
    line-height: 1.35;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 10px;
}
.faq-item p { font-size: 15px; line-height: 1.7; }

/* ---------- News ---------- */
.newsfeed {
    padding: 32px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.newsfeed h2 { font-family: var(--font-title); font-weight: 600; font-size: 34px; }
.newsfeed .news-item { display: flex; flex-direction: column; gap: 6px; padding-bottom: 20px; border-bottom: 1px solid var(--divider); }
.newsfeed .news-item:last-child { padding-bottom: 0; border-bottom: 0; }
.newsfeed h3 { font-size: 17px; font-weight: 700; color: var(--accent); }
.newsfeed .news-date { font-size: 13px; color: var(--muted); }
.newsfeed .news-item p { font-size: 15px; line-height: 1.6; margin-top: 4px; }

/* ---------- Footer ---------- */
.site-footer {
    margin-top: auto;
    background: var(--footer-bg);
    border-top: 1px solid var(--footer-border);
}
.footer-inner { display: flex; align-items: center; gap: 32px; min-height: 112px; }
.footer-inner img { height: 40px; width: auto; display: block; opacity: 0.9; }
.footer-nav { display: flex; gap: 24px; flex-grow: 1; }
.footer-nav a, .footer-note { color: var(--footer-text); font-size: 14px; text-decoration: none; }
.footer-nav a:hover { text-decoration: underline; }
.theme-toggle {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: transparent;
    border: 1px solid var(--footer-text);
    border-radius: 50%;
    color: var(--footer-text);
    cursor: pointer;
    transition: background-color 0.2s ease;
}
.theme-toggle:hover { background: rgba(255, 255, 255, 0.1); }
.theme-toggle svg { width: 20px; height: 20px; display: block; }
/* Mostra l'icona dell'azione: luna nel tema chiaro, sole nel tema scuro */
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) .theme-toggle .icon-sun { display: block; }
    :root:not([data-theme]) .theme-toggle .icon-moon { display: none; }
}

/* ---------- Mobile ---------- */
@media only screen and (max-width: 900px) {
    .header-inner { flex-wrap: wrap; gap: 0; min-height: 64px; justify-content: space-between; }
    .brand img { height: 38px; }
    .navtoggle { display: flex; }
    .mainnav {
        display: none;
        flex-basis: 100%;
        flex-direction: column;
        gap: 0;
        padding-bottom: 16px;
    }
    .site-header.open .mainnav { display: flex; }
    .navlinks { flex-direction: column; gap: 0; }
    .navlinks li.solo-mobile { display: flex; }
    .navlinks a {
        height: 52px;
        padding: 0;
        border-top: 1px solid var(--header-border);
        border-bottom: 0;
        font-size: 17px;
    }
    .navlinks a.active { border-bottom: 0; }
    .navactions { padding-top: 16px; border-top: 1px solid var(--header-border); }
    .navactions a { flex: 1; height: 48px; font-size: 16px; }

    main.wrap { padding: 20px 0 40px; gap: 24px; }
    .layout.has-news { display: block; }
    .layout.has-news .newsfeed { margin-top: 24px; }
    .posts { gap: 24px; }

    .hero, .page-index .hero { padding: 24px; }
    .diapositiva, .page-index .diapositiva { flex-direction: column; align-items: stretch; gap: 16px; }
    .slide-img, .page-index .slide-img { order: 2; width: 100%; height: 200px; }
    .hero-title, .page-faq .hero-title { font-size: 34px; }
    .page-index .hero-title { font-size: 44px; }
    .page-index .hero-text, .hero-text { font-size: 16px; }
    .hero-cta { flex-direction: column; }
    .hero-cta .btn { width: 100%; }
    .hero-dots { margin-top: 16px; }

    .card, .page-registrazione .card, .page-contatti .card, .page-login .card { padding: 24px; }
    .post-title { font-size: 34px; }
    h1.post-title { font-size: 36px; }
    .post-body { flex-direction: column; gap: 16px; }
    .post-img { width: 100%; height: 150px; }
    .post-text { font-size: 15px; }
    .post-text .btn, .post-text .btn-main { align-self: stretch; }
    .page-login .posts { display: flex; }
    .page-login .post-img { float: none; width: 84px; height: 84px; margin: 0 0 12px; }
    .faq-grid { column-count: 1; }
    .newsfeed { padding: 24px; }
    .footer-inner { justify-content: space-between; padding: 20px 0; min-height: 0; }
    .footer-inner img { height: 36px; }
    .footer-nav, .footer-note { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .diapositiva, .hero-dots .dot, .btn, .btn-main { transition: none; }
}
