/* ==========================================================================
   F-014 — Ecosystem shared styles: responsive guards, cards, lightbox,
   accordions, breadcrumbs, accessibility. Loaded by DEB + MS layouts.
   Main + PAT sites inherit guards via their own layouts where included.
   ========================================================================== */

/* ── Overflow guard (320px: absolutely no horizontal scroll) ── */
html, body { overflow-x: clip; max-width: 100%; }
body { -webkit-text-size-adjust: 100%; }
img, video, audio, iframe, table { max-width: 100%; }
img, video { height: auto; }
iframe { border: 0; }

/* ── Ultra-wide control (2560/3840): cap content, centre it ── */
@media (min-width: 1920px) {
    .container { max-width: 1440px; }
    .eco-wide { max-width: 1600px; margin-inline: auto; }
}
@media (min-width: 2560px) {
    body { font-size: 17px; }
    .container { max-width: 1560px; }
}
@media (min-width: 3840px) {
    .container { max-width: 1600px; }
}

/* ── Fluid typography (no clipping/overlap at any width) ── */
.eco-h1, h1.eco-title { font-size: clamp(1.75rem, 1.2rem + 2.5vw, 3rem); line-height: 1.15; overflow-wrap: break-word; }
.eco-h2, h2.eco-title { font-size: clamp(1.375rem, 1.05rem + 1.6vw, 2.25rem); line-height: 1.2; overflow-wrap: break-word; }
.eco-lead { font-size: clamp(1rem, 0.95rem + 0.4vw, 1.125rem); line-height: 1.7; }
.eco-wrap { overflow-wrap: break-word; word-break: break-word; hyphens: auto; }

/* ── Breadcrumb (shared) ── */
.eco-breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; font-size: 0.8125rem; margin-bottom: 1.25rem; list-style: none; padding: 0; }
.eco-breadcrumb a { text-decoration: none; opacity: 0.85; }
.eco-breadcrumb a:hover { opacity: 1; text-decoration: underline; }
.eco-breadcrumb [aria-current="page"] { font-weight: 600; }
.eco-breadcrumb .eco-sep { opacity: 0.4; }

/* ── Detail layout (content + sidebar) ── */
.eco-detail-layout { display: grid; grid-template-columns: 1fr; gap: 2rem; }
@media (min-width: 1024px) { .eco-detail-layout { grid-template-columns: minmax(0, 1fr) 320px; gap: 2.5rem; } }
.eco-detail-main { min-width: 0; }
.eco-sidebar { min-width: 0; }
.eco-sidebar-card { border: 1px solid rgba(0,0,0,0.1); border-radius: 0.75rem; padding: 1.25rem; margin-bottom: 1.25rem; background: #fff; }
.eco-sidebar-card h3 { font-size: 0.95rem; margin-bottom: 0.75rem; }
.eco-sidebar-card ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.4rem; }
.eco-sidebar-card a { font-size: 0.875rem; text-decoration: none; }
.eco-sidebar-card a:hover { text-decoration: underline; }

/* ── Responsive card grids: 3/4 cols desktop, 2 tablet, 1 mobile ── */
.eco-grid { display: grid; grid-template-columns: 1fr; gap: 1.25rem; }
@media (min-width: 576px) { .eco-grid.eco-grid-2, .eco-grid.eco-grid-3, .eco-grid.eco-grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) {
    .eco-grid.eco-grid-3 { grid-template-columns: repeat(3, 1fr); }
    .eco-grid.eco-grid-4 { grid-template-columns: repeat(4, 1fr); }
}
.eco-card { border: 1px solid rgba(0,0,0,0.1); border-radius: 0.75rem; overflow: hidden; background: #fff; display: flex; flex-direction: column; min-width: 0; transition: transform 0.25s ease, box-shadow 0.25s ease; }
.eco-card:hover { transform: translateY(-3px); box-shadow: 0 14px 28px rgba(0,0,0,0.1); }
.eco-card-body { padding: 1.25rem; display: flex; flex-direction: column; gap: 0.5rem; flex: 1; }
.eco-card-title { font-size: 1.05rem; line-height: 1.4; margin: 0; overflow-wrap: break-word; }
.eco-card-title a { text-decoration: none; color: inherit; }
.eco-card-title a:hover { text-decoration: underline; }
.eco-card-meta { font-size: 0.78rem; opacity: 0.75; display: flex; flex-wrap: wrap; gap: 0.5rem 0.9rem; }
.eco-card-text { font-size: 0.9rem; line-height: 1.65; opacity: 0.85; }
.eco-card-link { font-size: 0.875rem; font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; gap: 0.4rem; margin-top: auto; padding-top: 0.5rem; min-height: 44px; }
.eco-card-link:hover { text-decoration: underline; }

/* ── Media: aspect ratio, lightbox ── */
.eco-media { position: relative; overflow: hidden; background: rgba(0,0,0,0.06); aspect-ratio: 16 / 9; display: flex; align-items: center; justify-content: center; }
.eco-media--square { aspect-ratio: 1 / 1; }
.eco-media i { font-size: 2rem; opacity: 0.5; }
.eco-media img { width: 100%; height: 100%; object-fit: cover; }
.eco-video-wrap { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: 0.75rem; overflow: hidden; }
.eco-video-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; }
.eco-audio { display: flex; align-items: center; gap: 1rem; border: 1px solid rgba(0,0,0,0.12); border-radius: 0.75rem; padding: 1rem 1.25rem; background: #fff; }
.eco-audio audio { width: 100%; }
.eco-lightbox { position: fixed; inset: 0; z-index: 2000; background: rgba(0,0,0,0.9); display: none; align-items: center; justify-content: center; padding: 1rem; }
.eco-lightbox.is-open { display: flex; }
.eco-lightbox figure { margin: 0; max-width: min(90vw, 1100px); }
.eco-lightbox img { max-width: 100%; max-height: 78vh; border-radius: 0.5rem; }
.eco-lightbox figcaption { color: #fff; text-align: center; padding-top: 0.75rem; font-size: 0.9rem; }
.eco-lightbox-close { position: absolute; top: 1rem; right: 1rem; width: 44px; height: 44px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.4); background: transparent; color: #fff; font-size: 1.1rem; cursor: pointer; }
.eco-gallery-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
@media (min-width: 768px) { .eco-gallery-grid { grid-template-columns: repeat(3, 1fr); gap: 1rem; } }
@media (min-width: 1024px) { .eco-gallery-grid { grid-template-columns: repeat(4, 1fr); } }
.eco-gallery-item { margin: 0; border-radius: 0.5rem; overflow: hidden; }
.eco-gallery-item button { display: block; width: 100%; border: 0; padding: 0; background: rgba(0,0,0,0.06); aspect-ratio: 1/1; cursor: pointer; min-height: 44px; }
.eco-gallery-item figcaption { font-size: 0.75rem; padding: 0.4rem 0.1rem 0; opacity: 0.75; }

/* ── Accessible accordion ── */
.eco-accordion { border: 1px solid rgba(0,0,0,0.12); border-radius: 0.75rem; overflow: hidden; margin-bottom: 0.75rem; background: #fff; }
.eco-accordion-btn { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem 1.25rem; background: none; border: 0; cursor: pointer; font-size: 0.95rem; font-weight: 600; text-align: left; min-height: 48px; }
.eco-accordion-btn i { transition: transform 0.25s ease; flex-shrink: 0; }
.eco-accordion.is-open .eco-accordion-btn i { transform: rotate(180deg); }
.eco-accordion-panel { max-height: 0; overflow: hidden; transition: max-height 0.3s ease; }
.eco-accordion-panel-inner { padding: 0 1.25rem 1.25rem; font-size: 0.92rem; line-height: 1.7; }

/* ── Prev/next + share + tags ── */
.eco-prevnext { display: grid; grid-template-columns: 1fr; gap: 1rem; margin-top: 2.5rem; }
@media (min-width: 640px) { .eco-prevnext { grid-template-columns: 1fr 1fr; } }
.eco-prevnext a { border: 1px solid rgba(0,0,0,0.12); border-radius: 0.75rem; padding: 1rem 1.25rem; text-decoration: none; display: block; min-height: 44px; }
.eco-prevnext a:hover { border-color: currentColor; }
.eco-prevnext .eco-pn-label { display: block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.1em; opacity: 0.65; margin-bottom: 0.25rem; }
.eco-tags { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.eco-tag { display: inline-flex; align-items: center; min-height: 32px; padding: 0.2rem 0.7rem; border-radius: 999px; border: 1px solid rgba(0,0,0,0.15); font-size: 0.75rem; text-decoration: none; }
.eco-share { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.eco-share a { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 50%; border: 1px solid rgba(0,0,0,0.15); text-decoration: none; }

/* ── CTA band ── */
.eco-cta { text-align: center; padding: 3.5rem 1rem; border-radius: 1rem; margin: 3rem 0 0; }
.eco-cta h2 { margin-bottom: 0.75rem; }
.eco-cta p { margin-bottom: 1.5rem; opacity: 0.85; }
.eco-cta-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; justify-content: center; }

/* ── Accessibility: focus, skip link, touch targets ── */
:focus-visible { outline: 3px solid #2563eb; outline-offset: 2px; border-radius: 2px; }
.skip-link { position: absolute; left: -9999px; top: 0; background: #000; color: #fff; padding: 0.75rem 1.25rem; z-index: 3000; border-radius: 0 0 0.5rem 0; }
.skip-link:focus { left: 0; }
.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; }
@media (max-width: 480px) {
    .btn, .eco-card-link, .eco-accordion-btn { min-height: 44px; }
    .eco-prevnext a { padding: 1rem; }
}

/* ── 404 state ── */
.eco-empty { text-align: center; padding: 4rem 1rem; }
.eco-empty h1 { margin-bottom: 0.75rem; }
.eco-empty p { opacity: 0.8; margin-bottom: 1.5rem; }
