/* ==========================================================================
   Planificando RD — Educación Municipal
   Sidebar: Expressive Design System (vibrant, bold, IBM Plex Mono)
   Cards:   Bento Design System (modular, clean, warm, Inter)
   ========================================================================== */

/* ── 0. Font loaded via functions.php <link> — no @import ── */

/* ── 1. Variables ── */
:root {
    --pl-bg: #00329C;

    --pl-text: #F1F5F9;
    --pl-text-secondary: #CBD5E1;
    --pl-text-muted: #94A3B8;

    --pl-accent: #D4AF37;
    --pl-accent-soft: rgba(212, 175, 55, 0.12);

    --pl-border: rgba(255, 255, 255, 0.1);

    --pl-shadow-lg: 0 8px 30px rgba(0, 20, 80, 0.5), 0 4px 6px rgba(0, 0, 0, 0.25);

    /* ── Card tokens — Pure white on royal blue, real gold #D4AF37 ── */
    --card-surface: #FFFFFF;
    --card-text: #0F172A;
    --card-text-secondary: #334155;
    --card-text-muted: #475569;
    --card-metric: #00329C;
    --card-gold: #D4AF37;
    --card-gold-light: #F5E6A3;
    --card-border: rgba(0, 50, 156, 0.15);
    --card-border-hover: rgba(212, 175, 55, 0.4);
    --card-shadow: 0 4px 20px rgba(0, 20, 80, 0.15), 0 1px 4px rgba(0, 0, 0, 0.08);
    --card-shadow-hover: 0 24px 50px rgba(0, 20, 80, 0.25), 0 0 0 1px rgba(212, 175, 55, 0.25);

    /* ── Expressive tokens ── */
    --expr-primary: #D4AF37;
    --expr-surface: rgba(0, 25, 85, 0.92);
}

/* ── 2. Page body ── */
body:has(.planificando) {
    background-color: var(--pl-bg);
    background-image:
        radial-gradient(ellipse at 15% 30%, rgba(212, 175, 55, 0.07), transparent 50%),
        radial-gradient(ellipse at 85% 20%, rgba(0, 20, 80, 0.4), transparent 55%),
        radial-gradient(ellipse at 50% 85%, rgba(212, 175, 55, 0.04), transparent 40%);
}

/* ── 3. Scrollbar ── */
body:has(.planificando) ::-webkit-scrollbar { width: 6px; height: 6px; }
body:has(.planificando) ::-webkit-scrollbar-track { background: transparent; }
body:has(.planificando) ::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, 0.2); border-radius: 3px; }
body:has(.planificando) ::-webkit-scrollbar-thumb:hover { background: rgba(148, 163, 184, 0.35); }

/* ── 4. Grid ── */
.planificando {
    display: grid;
    grid-template-columns: 180px 1fr;
    grid-template-rows: auto 1fr auto;
    grid-template-areas:
        "header  header"
        "sidebar game"
        "cards   cards";
    gap: 20px;
    padding: calc(var(--fedomu-header-h, 60px) + 10px) max(24px, 4vw) 32px;
    max-width: 1600px;
    margin: 0 auto;
}

/* ── 5. Header ── */
.planificando__header {
    grid-area: header;
    padding: 0 4px;
}

.planificando__title {
    font-family: 'Merriweather', Georgia, serif;
    font-size: 2.2rem;
    font-weight: 900;
    color: var(--pl-text);
    margin: 0;
    line-height: 1.1;
}

.planificando__title-accent {
    color: var(--pl-accent);
    /* no glow — clean type */
}

.planificando__subtitle {
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 400;
    color: var(--pl-text-secondary);
    margin: 8px 0 0;
    letter-spacing: 0.3px;
}

/* ==========================================================================
   SIDEBAR — Expressive Design System
   Bold, vibrant, personality-driven. IBM Plex Mono. Dynamic hover states.
   ========================================================================== */

.planificando__sidebar {
    grid-area: sidebar;
    padding: 4px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
    overflow: hidden;
}

.planificando__sidebar-heading {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 3px;
    color: var(--expr-primary);
    font-weight: 700;
    margin: 0 0 2px 4px;
}

.planificando__nav-item {
    aspect-ratio: 1;
    padding: 14px;
    border-radius: 14px;
    background: var(--expr-surface);
    background-image: linear-gradient(
        160deg,
        color-mix(in srgb, var(--item-accent, var(--expr-primary)) 14%, transparent),
        transparent 70%
    );
    border: 2px solid color-mix(in srgb, var(--item-accent, var(--expr-primary)) 20%, transparent);
    border-bottom: 4px solid var(--item-accent, var(--expr-primary));
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    gap: 8px;
    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        transform 0.2s ease,
        box-shadow 0.2s ease;
    cursor: pointer;
}

.planificando__nav-item:last-child {
    aspect-ratio: auto;
    flex: 1;
    min-height: 0;
}

.planificando__nav-item:hover {
    background-color: rgba(0, 30, 110, 0.98);
    border-color: color-mix(in srgb, var(--item-accent, var(--expr-primary)) 45%, transparent);
    border-bottom-color: var(--item-accent, var(--expr-primary));
    transform: translateY(-4px) scale(1.02);
    box-shadow:
        0 8px 30px rgba(0, 0, 0, 0.45),
        0 0 25px color-mix(in srgb, var(--item-accent, var(--expr-primary)) 18%, transparent);
}

.planificando__nav-item strong {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--pl-text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}

.planificando__nav-item strong iconify-icon {
    color: var(--item-accent, var(--expr-primary));
    flex-shrink: 0;
    font-size: 22px;
    background: color-mix(in srgb, var(--item-accent, var(--expr-primary)) 12%, transparent);
    border-radius: 50%;
    padding: 8px;
    transition: background 0.2s ease;
}

.planificando__nav-item:hover strong iconify-icon {
    background: color-mix(in srgb, var(--item-accent, var(--expr-primary)) 22%, transparent);
}

.planificando__nav-item span {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.75rem;
    color: var(--pl-text-muted);
    line-height: 1.5;
    display: block;
    max-width: 95%;
}

/* ==========================================================================
   GAME AREA — Unchanged
   ========================================================================== */

.planificando__game {
    grid-area: game;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.planificando__game-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 4px;
}

.planificando__game-title {
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--pl-text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.planificando__game-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #34D399;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(52, 211, 153, 0.5);
    animation: planificando-pulse 2.5s ease-in-out infinite;
}

@keyframes planificando-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

.planificando__fullscreen-btn {
    border: 1px solid var(--pl-accent);
    background: var(--pl-accent-soft);
    color: var(--pl-accent);
    padding: 10px 20px;
    min-height: 44px;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.82rem;
    cursor: pointer;
    transition: background 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
}

.planificando__fullscreen-btn:hover {
    background: var(--pl-accent);
    color: var(--pl-bg);
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.3);
}

.planificando__game-stage {
    width: 100%;
    border-radius: 16px;
    position: relative;
    border: 1px solid var(--pl-border);
    box-shadow: var(--pl-shadow-lg), inset 0 0 30px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    background: var(--pl-bg);
}

.planificando__iframe {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    min-height: 400px;
    border: 0;
}

/* ── Fullscreen ── */
.planificando__game.is-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: #000;
    gap: 0;
}

.planificando__game.is-fullscreen .planificando__game-toolbar { display: none; }
.planificando__game.is-fullscreen .planificando__game-stage { border-radius: 0; border: 0; box-shadow: none; }
.planificando__game.is-fullscreen .planificando__iframe { aspect-ratio: auto; min-height: 100vh; height: 100vh; }

/* ==========================================================================
   CARDS — SaaS Dashboard Widgets on Royal Blue
   Pure white cards, #D4AF37 gold accents, data-first hierarchy.
   Dashboard data + Bento warmth + gold accents.
   ========================================================================== */

.planificando__cards {
    grid-area: cards;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 18px;
    width: 100%;
}

/* ── Card surface ── */
.planificando__card {
    aspect-ratio: 16 / 9;
    padding: 20px 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    position: relative;
    overflow: hidden;
    background: var(--card-surface);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    box-shadow: var(--card-shadow);
    transition:
        border-color 0.25s ease,
        box-shadow 0.25s ease,
        transform 0.25s ease;
}

/* Gold accent bar — static, clean */
.planificando__card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--card-gold);
    border-radius: 16px 16px 0 0;
}

/* Hover: gentle lift + gold border */
.planificando__card:hover {
    border-color: var(--card-border-hover);
    box-shadow: var(--card-shadow-hover);
    transform: translateY(-4px);
}

/* Release aspect-ratio when expanded */
.planificando__card.is-open {
    aspect-ratio: auto;
}

/* ── Category label — IBM Plex Mono ── */
.planificando__card-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--card-text-muted);
    margin-bottom: 2px;
}

.planificando__card-label iconify-icon {
    color: var(--card-gold);
}

/* ── Hero metric — brand blue, big, bold ── */
.planificando__card-metric {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.planificando__card-number {
    font-family: 'Inter', sans-serif;
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--card-metric);
    line-height: 1;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
}

.planificando__card-unit {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--card-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ── Hook — provocative, conversational ── */
.planificando__card-hook {
    font-family: 'Inter', sans-serif;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--card-text-secondary);
    line-height: 1.4;
    margin: 2px 0 0;
}

/* ── Data bar — visual storytelling ── */
.planificando__card-bar {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.planificando__card-bar-track {
    width: 100%;
    height: 6px;
    background: rgba(0, 50, 156, 0.12);
    border-radius: 3px;
    overflow: hidden;
}

.planificando__card-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--card-gold), var(--card-gold-light));
    border-radius: 3px;
    transform-origin: left;
    animation: bar-enter 1.2s cubic-bezier(0.25, 1, 0.5, 1) 0.4s both;
}

@keyframes bar-enter {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
}

.planificando__card-bar-text {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.6rem;
    font-weight: 500;
    color: var(--card-text-muted);
    letter-spacing: 0.5px;
}

/* ── Expandable detail ── */
.planificando__card-details {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s cubic-bezier(0.2, 0, 0, 1), opacity 0.25s ease;
    opacity: 0;
}

.planificando__card.is-open .planificando__card-details {
    max-height: 300px;
    opacity: 1;
    margin-top: 8px;
}

.planificando__card-details p {
    color: var(--card-text-muted);
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    line-height: 1.6;
    margin: 0;
    padding-top: 8px;
    border-top: 1px solid rgba(0, 50, 156, 0.1);
}

/* ── Toggle — brand blue link ── */
.planificando__card-toggle {
    margin-top: auto;
    align-self: flex-start;
    background: transparent;
    border: none;
    color: var(--card-metric);
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    min-height: 44px;
    padding: 10px 0;
    border-radius: 4px;
    transition: color 0.2s ease;
}

.planificando__card-toggle:hover {
    color: #8B6914;
}

.planificando__card-toggle::after {
    content: "\2193";
    transition: transform 0.25s ease;
    font-size: 0.9em;
}

.planificando__card.is-open .planificando__card-toggle::after {
    transform: rotate(180deg);
}

/* ── Card highlight (sidebar → card navigation) ── */
.planificando__card.is-highlighted {
    border-color: var(--card-gold);
    box-shadow: var(--card-shadow-hover), 0 0 0 2px var(--card-gold);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

/* ── Game loading overlay ── */
.planificando__game-loading {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background: var(--pl-bg);
    color: var(--pl-text-secondary);
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    border-radius: 16px;
}

.planificando__game-loading iconify-icon {
    animation: planificando-spin 1.5s linear infinite;
}

@keyframes planificando-spin {
    to { transform: rotate(360deg); }
}

.planificando__game-loading.is-error {
    color: var(--pl-text);
}

.planificando__game-loading.is-hidden {
    display: none;
}

.planificando__game-loading button {
    margin-top: 4px;
    padding: 8px 16px;
    border: 1px solid var(--pl-accent);
    background: var(--pl-accent-soft);
    color: var(--pl-accent);
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
}

.planificando__game-loading button:hover {
    background: var(--pl-accent);
    color: var(--pl-bg);
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 850px) {
    .planificando {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto auto;
        grid-template-areas:
            "header"
            "game"
            "sidebar"
            "cards";
    }

    .planificando__sidebar {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        overflow: visible;
    }

    .planificando__sidebar-heading {
        grid-column: 1 / -1;
    }

    .planificando__nav-item {
        aspect-ratio: 1;
    }

    .planificando__nav-item:last-child {
        aspect-ratio: 1;
        flex: 0;
    }

    .planificando__cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .planificando {
        padding-left: 16px;
        padding-right: 16px;
        gap: 16px;
    }

    .planificando__sidebar {
        grid-template-columns: repeat(2, 1fr);
    }

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

    .planificando__title {
        font-size: 1.75rem;
    }

    .planificando__subtitle {
        font-size: 0.9rem;
    }
}

/* ── Focus ── */
.planificando__fullscreen-btn:focus-visible,
.planificando__card-toggle:focus-visible,
.planificando__nav-item:focus-visible {
    outline: 2px solid var(--card-gold);
    outline-offset: 2px;
}

/* ── Visually hidden ── */
.planificando .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;
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
    .planificando__card,
    .planificando__nav-item,
    .planificando__fullscreen-btn,
    .planificando__card-toggle::after,
    .planificando__card-details {
        transition: none;
    }

    .planificando__game-dot,
    .planificando__card-bar-fill,
    .planificando__game-loading iconify-icon {
        animation: none;
    }

    .planificando__card-bar-fill {
        transform: none;
    }

    .planificando__card:hover,
    .planificando__nav-item:hover {
        transform: none;
    }
}
