/* ==========================================================================
   GUIDE PAGES — CSS
   Depends on main.css (site variables) and adds guide-specific variables.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;600;700&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;1,9..40,300&display=swap');

/* ------------------------------------------------------------------
   Guide-specific CSS variables (supplement site vars from main.css)
   ------------------------------------------------------------------ */
:root {
    --guide-accent:       #3a6b35;
    --guide-accent-soft:  #e8f0e7;
    --guide-accent-hover: #2e5629;
    --guide-warn:         #c97d2e;
    --guide-warn-soft:    #fdf3e3;
    --guide-danger:       #b03a2e;
    --guide-danger-soft:  #fdecea;
    --guide-surface:      #ffffff;
    --guide-tag-bg:       #f0ece6;
    --guide-radius-sm:    6px;
    --guide-radius-md:    12px;
    --guide-radius-lg:    20px;
    --guide-max-content:  760px;
    --guide-max-wide:     1100px;
    --guide-font-display: 'Playfair Display', Georgia, serif;
    --guide-font-body:    'DM Sans', system-ui, sans-serif;
}

body.dark {
    --guide-accent:       #5a9b54;
    --guide-accent-soft:  #1a2e18;
    --guide-accent-hover: #6db866;
    --guide-warn-soft:    #2d2010;
    --guide-danger-soft:  #2d1a1a;
    --guide-surface:      var(--bg-secondary);
    --guide-tag-bg:       #1c2128;
}

/* ------------------------------------------------------------------
   GUIDE PAGE WRAPPER — reset main padding, full-width sections
   ------------------------------------------------------------------ */
.guide-page {
    font-family: var(--guide-font-body);
    font-size: 17px;
    line-height: 1.75;
    /* Negative margin to undo site <main> padding */
    margin: -2rem -1.25rem;
    /* Stacking context below sticky nav (z-index: 1000) */
    position: relative;
    z-index: 0;
}

/* ------------------------------------------------------------------
   BREADCRUMB
   ------------------------------------------------------------------ */
.guide-breadcrumb {
    max-width: var(--guide-max-wide);
    margin: 0 auto;
    padding: 20px 24px 0;
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.guide-breadcrumb a {
    color: var(--text-secondary);
    text-decoration: none;
}

.guide-breadcrumb a:hover {
    color: var(--guide-accent);
    text-decoration: none;
}

.guide-breadcrumb span { opacity: .5; }

/* ------------------------------------------------------------------
   HERO
   ------------------------------------------------------------------ */
.guide-hero {
    max-width: var(--guide-max-wide);
    margin: 0 auto;
    padding: 40px 24px 32px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 32px;
    align-items: end;
    /* Collapse on scroll — height+padding animated via JS inline styles */
    overflow: hidden;
    transition: max-height 0.38s cubic-bezier(0.4, 0, 0.2, 1),
                padding-top 0.38s cubic-bezier(0.4, 0, 0.2, 1),
                padding-bottom 0.38s cubic-bezier(0.4, 0, 0.2, 1);
}

.guide-hero__tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--guide-accent-soft);
    color: var(--guide-accent);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: .06em;
    text-transform: uppercase;
    padding: 5px 12px;
    border-radius: 99px;
    margin-bottom: 16px;
}

.guide-hero__title {
    font-family: var(--guide-font-display);
    font-size: clamp(1.8rem, 4vw, 3rem);
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-primary);
    max-width: 600px;
}

.guide-hero__lead {
    margin-top: 14px;
    font-size: 18px;
    font-weight: 300;
    color: var(--text-secondary);
    max-width: 560px;
}

.guide-hero__meta {
    display: flex;
    gap: 24px;
    margin-top: 20px;
    font-size: 13px;
    color: var(--text-secondary);
    flex-wrap: wrap;
}

/* TOC sidebar (desktop only) */
.guide-hero__aside {
    background: var(--guide-surface);
    border: 1px solid var(--border);
    border-radius: var(--guide-radius-lg);
    padding: 20px 22px;
    min-width: 200px;
    font-size: 13px;
    box-shadow: var(--shadow-sm);
}

.guide-hero__aside strong {
    display: block;
    font-size: 11px;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.toc-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.toc-list a {
    color: var(--text-primary);
    text-decoration: none;
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-size: 13px;
    transition: color .15s;
}

.toc-list a:hover {
    color: var(--guide-accent);
    text-decoration: none;
}

.toc-num {
    font-size: 11px;
    color: var(--guide-accent);
    font-weight: 600;
    min-width: 14px;
}

/* ------------------------------------------------------------------
   CONTENT WRAPPER
   ------------------------------------------------------------------ */
.guide-content {
    max-width: var(--guide-max-content);
    margin: 0 auto;
    padding: 0 24px 80px;
}

.guide-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 40px 0;
}

/* ------------------------------------------------------------------
   STEP SECTIONS
   ------------------------------------------------------------------ */
.guide-section {
    margin-bottom: 48px;
    scroll-margin-top: 110px;
}

.guide-section-header {
    display: flex;
    align-items: flex-start;
    gap: 18px;
    margin-bottom: 20px;
}

.guide-back-top {
    margin-left: auto;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--guide-accent-soft);
    color: var(--guide-accent);
    font-size: 14px;
    text-decoration: none;
    opacity: 0.55;
    transition: opacity 0.18s, background 0.18s;
    line-height: 1;
}

.guide-back-top:hover {
    opacity: 1;
    background: var(--guide-accent);
    color: #fff;
}

.guide-section-number {
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--guide-accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--guide-font-display);
    font-size: 18px;
    font-weight: 700;
    margin-top: 2px;
}

.guide-section-title {
    font-family: var(--guide-font-display);
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1.25;
    color: var(--text-primary);
}

.guide-section p {
    margin-bottom: 14px;
    color: var(--text-primary);
}

/* ------------------------------------------------------------------
   CHECKLIST
   ------------------------------------------------------------------ */
.guide-checklist {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 18px 0;
}

.guide-checklist li {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    background: var(--guide-surface);
    border: 1px solid var(--border);
    border-radius: var(--guide-radius-md);
    padding: 14px 18px;
}

.guide-checklist__icon {
    font-size: 20px;
    flex-shrink: 0;
    margin-top: 1px;
}

.guide-checklist__body > strong {
    display: block;
    margin-bottom: 3px;
    font-weight: 500;
    color: var(--text-primary);
}

.guide-checklist__body p {
    margin: 0;
    font-size: 15px;
    color: var(--text-secondary);
}

/* ------------------------------------------------------------------
   SIGNAL CARDS (ok / warn / danger)
   ------------------------------------------------------------------ */
.signal-cards {
    display: grid;
    gap: 12px;
    margin: 20px 0;
}

.signal-card {
    border-radius: var(--guide-radius-md);
    padding: 16px 20px;
    display: flex;
    gap: 14px;
    align-items: flex-start;
    border-left: 4px solid transparent;
}

.signal-card--ok {
    background: var(--guide-accent-soft);
    border-left-color: var(--guide-accent);
}

.signal-card--warn {
    background: var(--guide-warn-soft);
    border-left-color: var(--guide-warn);
}

.signal-card--danger {
    background: var(--guide-danger-soft);
    border-left-color: var(--guide-danger);
}

.signal-card__emoji {
    font-size: 22px;
    flex-shrink: 0;
    margin-top: 2px;
}

.signal-card__content strong {
    display: block;
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.signal-card__content p {
    margin: 0;
    font-size: 15px;
    color: var(--text-secondary);
}

/* ------------------------------------------------------------------
   RATING BLOCKS (semaforo verde / giallo / rosso)
   ------------------------------------------------------------------ */
.rating-grid {
    display: grid;
    gap: 12px;
    margin: 20px 0;
}

.rating-block {
    border-radius: var(--guide-radius-md);
    overflow: hidden;
    border: 1px solid var(--border);
    display: grid;
    grid-template-columns: 56px 1fr;
}

.rating-block__dot {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.rating-block--green .rating-block__dot { background: #d4edda; }
.rating-block--yellow .rating-block__dot { background: #fff3cd; }
.rating-block--red    .rating-block__dot { background: #f8d7da; }

.rating-block__body {
    padding: 14px 18px;
    background: var(--guide-surface);
}

.rating-block__body strong {
    display: block;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.rating-block__body ul {
    margin: 0;
    padding-left: 18px;
    font-size: 14px;
    color: var(--text-secondary);
}

/* ------------------------------------------------------------------
   NUMBERED STEP LIST
   ------------------------------------------------------------------ */
.guide-step-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 18px;
    margin: 20px 0;
}

.guide-step-list li {
    display: grid;
    grid-template-columns: 36px 1fr;
    gap: 16px;
    align-items: flex-start;
}

.guide-step-num {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--guide-accent);
    color: var(--guide-accent);
    font-weight: 700;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.guide-step-body strong {
    display: block;
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.guide-step-body p {
    margin: 0;
    font-size: 15px;
    color: var(--text-secondary);
}

/* ------------------------------------------------------------------
   SUMMARY TABLE
   ------------------------------------------------------------------ */
.guide-table-wrap {
    overflow-x: auto;
    margin: 20px 0;
    border-radius: var(--guide-radius-md);
    border: 1px solid var(--border);
}

.guide-table-wrap table {
    width: 100%;
    border-collapse: collapse;
    font-size: 15px;
    background: var(--guide-surface);
}

.guide-table-wrap thead th {
    text-align: left;
    padding: 12px 18px;
    font-size: 12px;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--text-secondary);
    background: var(--guide-tag-bg);
    font-weight: 500;
    border-bottom: 1px solid var(--border);
}

.guide-table-wrap tbody td {
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
    color: var(--text-primary);
}

.guide-table-wrap tbody tr:last-child td { border-bottom: none; }
.guide-table-wrap tbody tr:hover td { background: var(--bg-primary); }

/* ------------------------------------------------------------------
   INSIGHT / BLOCKQUOTE
   ------------------------------------------------------------------ */
.guide-insight {
    border-left: 3px solid var(--guide-accent);
    padding: 14px 20px;
    background: var(--guide-accent-soft);
    border-radius: 0 var(--guide-radius-sm) var(--guide-radius-sm) 0;
    margin: 20px 0;
    font-style: italic;
    color: var(--text-secondary);
    font-size: 15px;
}

/* ------------------------------------------------------------------
   CTA BANNER
   ------------------------------------------------------------------ */
.guide-cta {
    background: var(--guide-accent);
    color: #fff;
    border-radius: var(--guide-radius-lg);
    padding: 40px;
    margin-top: 48px;
    text-align: center;
}

.guide-cta h2 {
    font-family: var(--guide-font-display);
    font-size: 1.6rem;
    font-weight: 700;
    margin-bottom: 12px;
}

.guide-cta p {
    font-size: 16px;
    opacity: .88;
    margin-bottom: 24px;
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
}

.guide-btn {
    display: inline-block;
    padding: 13px 30px;
    border-radius: 99px;
    font-weight: 500;
    font-size: 15px;
    text-decoration: none;
    transition: transform .15s, opacity .15s;
    background: #fff;
    color: var(--guide-accent);
}

.guide-btn:hover {
    transform: translateY(-2px);
    opacity: .9;
    text-decoration: none;
    color: var(--guide-accent);
}

/* ------------------------------------------------------------------
   RELATED GUIDES
   ------------------------------------------------------------------ */
.guide-related {
    margin-top: 48px;
    padding-top: 32px;
    border-top: 1px solid var(--border);
}

.guide-related h3 {
    font-family: var(--guide-font-display);
    font-size: 1.2rem;
    margin-bottom: 18px;
    color: var(--text-primary);
}

.guide-related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

.guide-related-card {
    background: var(--guide-surface);
    border: 1px solid var(--border);
    border-radius: var(--guide-radius-md);
    padding: 18px 20px;
    text-decoration: none;
    color: var(--text-primary);
    transition: border-color .15s, transform .15s;
    display: block;
}

.guide-related-card:hover {
    border-color: var(--guide-accent);
    transform: translateY(-2px);
    text-decoration: none;
    color: var(--text-primary);
}

.guide-related-card__tag {
    font-size: 11px;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--guide-accent);
    font-weight: 500;
    margin-bottom: 6px;
}

.guide-related-card__title {
    font-size: 15px;
    font-weight: 500;
    line-height: 1.3;
}

/* ------------------------------------------------------------------
   GUIDES INDEX PAGE
   ------------------------------------------------------------------ */
.guides-index {
    max-width: var(--guide-max-wide);
    margin: 0 auto;
    padding: 40px 24px 80px;
}

.guides-index__header {
    margin-bottom: 48px;
    overflow: hidden;
    transition: max-height 0.38s cubic-bezier(0.4, 0, 0.2, 1),
                margin-bottom 0.38s cubic-bezier(0.4, 0, 0.2, 1);
}

.guides-index__tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--guide-accent-soft);
    color: var(--guide-accent);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: .06em;
    text-transform: uppercase;
    padding: 5px 12px;
    border-radius: 99px;
    margin-bottom: 16px;
}

.guides-index__title {
    font-family: var(--guide-font-display);
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    font-weight: 700;
    line-height: 1.2;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.guides-index__lead {
    font-size: 18px;
    font-weight: 300;
    color: var(--text-secondary);
    max-width: 560px;
}

.guides-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.guide-card {
    background: var(--guide-surface);
    border: 1px solid var(--border);
    border-radius: var(--guide-radius-lg);
    padding: 24px 26px;
    text-decoration: none;
    color: var(--text-primary);
    transition: border-color .2s, transform .2s, box-shadow .2s;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: var(--shadow-sm);
}

.guide-card:hover {
    border-color: var(--guide-accent);
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,.1);
    text-decoration: none;
    color: var(--text-primary);
}

.guide-card__icon {
    font-size: 32px;
    line-height: 1;
}

.guide-card__category {
    font-size: 11px;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--guide-accent);
    font-weight: 600;
}

.guide-card__title {
    font-family: var(--guide-font-display);
    font-size: 1.15rem;
    font-weight: 600;
    line-height: 1.3;
}

.guide-card__desc {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    flex: 1;
}

.guide-card__meta {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    gap: 16px;
    margin-top: 4px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

/* ------------------------------------------------------------------
   RESPONSIVE
   ------------------------------------------------------------------ */
@media (max-width: 700px) {
    .guide-page {
        margin: -2rem -1.25rem;
    }

    .guide-hero {
        grid-template-columns: 1fr;
        padding-top: 24px;
    }

    .guide-hero__aside {
        display: none;
    }

    .guide-cta {
        padding: 28px 20px;
    }

    .guide-content {
        padding: 0 16px 60px;
    }

    .guide-breadcrumb {
        padding: 16px 16px 0;
    }

    .guides-index {
        padding: 24px 16px 60px;
    }

    .guides-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .guide-hero {
        padding: 20px 16px 24px;
    }

    .guide-hero__title {
        font-size: 1.65rem;
    }

    .guide-section-title {
        font-size: 1.25rem;
    }
}
