/*
 * UCF HDL Course — reveal.js Theme
 * University of Central Florida branding
 * Light theme optimized for recorded video lectures
 *
 * Enhancement: Panel utility classes, segment breadcrumb,
 * and live-demo styles consolidated from per-file overrides.
 */

/* ── Design Tokens ── */
:root {
    --ucf-gold: #FFC904;
    --ucf-black: #000000;
    --ucf-dark-gray: #2C2A29;
    --ucf-mid-gray: #5F6062;
    --ucf-light-gray: #E8E8E4;
    --ucf-white: #FFFFFF;
    --ucf-gold-dark: #C9A000;
    --ucf-gold-light: #FFF3B0;

    /* Semantic colors */
    --color-synth: #2E7D32;       /* green — synthesizable */
    --color-sim-only: #E65100;    /* orange — simulation only */
    --color-mistake: #C62828;     /* red — common mistake */
    --color-highlight: #FFC904;

    /* Code */
    --color-code-bg: #1E1E1E;
    --color-code-bg-light: #F5F5F5;
}

/* ── Base Typography ── */
.reveal {
    font-family: 'Inter','Segoe UI','Helvetica Neue',Arial,sans-serif;
    font-size: 32px;
    color: var(--ucf-dark-gray);
}
.reveal .slides { text-align: left; }
.reveal .slides section { padding: 40px 60px; }

.reveal h1,.reveal h2,.reveal h3,.reveal h4 {
    font-family: 'Inter','Segoe UI','Helvetica Neue',Arial,sans-serif;
    font-weight: 700;
    color: var(--ucf-black);
    text-transform: none;
    letter-spacing: -0.02em;
}
.reveal h1 { font-size: 2.2em; border-bottom: 4px solid var(--ucf-gold); padding-bottom: 0.2em; margin-bottom: 0.5em; }
.reveal h2 { font-size: 1.6em; margin-bottom: 0.4em; }
.reveal h3 { font-size: 1.2em; color: var(--ucf-mid-gray); margin-bottom: 0.3em; }
.reveal p  { line-height: 1.5; margin-bottom: 0.6em; }
.reveal strong { color: var(--ucf-black); font-weight: 700; }

.reveal ul,.reveal ol { margin-left: 1em; margin-bottom: 0.5em; }
.reveal li { margin-bottom: 0.4em; line-height: 1.4; }

/* ── Code ── */
.reveal pre {
    width: 100%; margin: 0.5em 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    border-radius: 6px;
    border-left: 4px solid var(--ucf-gold);
    /* Viewport-relative cap so code blocks shrink with the actual window,
       not the 1280×720 logical slide. Horizontal scroll keeps long lines
       intact rather than wrapping them (which mangles indentation). */
    max-height: 65vh;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: auto;
    overflow-y: auto;
}
.reveal pre code {
    font-family: 'JetBrains Mono','Fira Code','Cascadia Code','Consolas',monospace;
    font-size: 0.55em; line-height: 1.5; padding: 1em;
    /* Let parent <pre> own height/scroll; code fills naturally. */
    max-height: none;
    overflow: visible;
    background: var(--color-code-bg); color: #D4D4D4;
    border-radius: 6px;
    display: block;
    box-sizing: border-box;
    white-space: pre;         /* never wrap code lines */
    overflow-wrap: normal;
}
.reveal code {
    font-family: 'JetBrains Mono','Fira Code','Cascadia Code','Consolas',monospace;
    font-size: 0.85em;
    background: var(--color-code-bg-light);
    padding: 0.1em 0.3em; border-radius: 3px;
    color: var(--ucf-dark-gray);
}

/* Code border-color variants */
.reveal pre.synth       { border-left-color: var(--color-synth); }
.reveal pre.sim-only    { border-left-color: var(--color-sim-only); }
.reveal pre.mistake     { border-left-color: var(--color-mistake); }

/* ── Tables ── */
.reveal table { border-collapse: collapse; width: 100%; margin: 0.5em 0; font-size: 0.75em; }
.reveal table th { background: var(--ucf-black); color: var(--ucf-gold); padding: 0.5em 0.8em; text-align: left; font-weight: 700; }
.reveal table td { padding: 0.4em 0.8em; border-bottom: 1px solid var(--ucf-light-gray); }
.reveal table tr:nth-child(even) td { background: #FAFAFA; }

/* ══════════════════════════════════════════════════════════════════════
   RESPONSIVE OVERFLOW + FIT-TO-WINDOW
   Three-part defense for content that outgrows the 1280×720 logical slide:
     1. Section-level vertical scroll (viewport-relative, not pixel)
     2. Per-element caps (code, images, tables, flex columns)
     3. Optional fit-mode that scales the active slide via CSS variable
   ══════════════════════════════════════════════════════════════════════ */

/* ─── 1. Section-level overflow (default mode) ───
   Reveal silently clips overflow via .slides{overflow:hidden}. Give each
   innermost section a viewport-scoped cap + vertical scrollbar so long
   content becomes navigable instead of invisible. */
.reveal .slides section {
    box-sizing: border-box;
    max-height: 95vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding-bottom: 0.5em;   /* keep scrollbar clear of reveal controls */
}
/* Stack parents (outer <section> wrapping nested <section>s) must not
   double-scroll — reveal handles them. */
.reveal .slides section.stack {
    max-height: none;
    overflow: visible;
}

/* Branded scrollbars so the scrollable region is obviously a region. */
.reveal pre::-webkit-scrollbar,
.reveal .slides section::-webkit-scrollbar { width: 8px; height: 8px; }
.reveal pre::-webkit-scrollbar-track,
.reveal .slides section::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.15); border-radius: 4px;
}
.reveal pre::-webkit-scrollbar-thumb,
.reveal .slides section::-webkit-scrollbar-thumb {
    background: var(--ucf-gold); border-radius: 4px; opacity: 0.75;
}
.reveal pre::-webkit-scrollbar-thumb:hover,
.reveal .slides section::-webkit-scrollbar-thumb:hover {
    background: var(--ucf-gold-dark);
}
.reveal pre, .reveal .slides section {
    scrollbar-width: thin;
    scrollbar-color: var(--ucf-gold) rgba(0,0,0,0.15);
}

/* ─── 2. Per-element overflow guards ─── */
.reveal img {
    max-width: 100%;
    max-height: 80vh;
    height: auto;
    object-fit: contain;
}
.reveal svg {
    max-width: 100%;
    max-height: 80vh;
}
.reveal .slides section > table,
.reveal .slides section > .table-wrap {
    display: block;
    overflow-x: auto;
    max-width: 100%;
}
.reveal .columns > .col,
.reveal .two-col > .col {
    min-width: 0;
    min-height: 0;  /* let flex children shrink */
}

/* ─── 3. Fit-mode (toggle via Shift+F or button) ───
   When body has .fit-mode, the ACTIVE slide is scaled by a CSS variable
   (--fit-scale) computed in JS to fit the viewport. Replaces in-slide
   scrolling with a uniformly-shrunk slide — better for projector use. */
body.fit-mode .reveal .slides section.present {
    transform: scale(var(--fit-scale, 1));
    transform-origin: top center;
    /* In fit-mode the scale handles it — don't clip or scroll. */
    max-height: none;
    overflow: visible;
}
body.fit-mode .reveal pre {
    max-height: none;
    overflow: visible;
}

/* ─── 4. Floating UI: discreet fit-mode toggle ───
   A compact pill in the bottom-left corner. Faded by default so it
   never competes with slide content or reveal's own slide-number
   (bottom-right). Inspired by the RTS course's deck-ui pattern. */
.deck-ui-button {
    position: fixed;
    bottom: 0.9em;
    left: 0.9em;
    z-index: 10000;
    background: var(--ucf-black);
    color: var(--ucf-gold);
    border: 1px solid var(--ucf-gold);
    border-radius: 3px;
    padding: 0.35em 0.75em;
    font-family: 'JetBrains Mono','Fira Code','Cascadia Code','Consolas',monospace;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    opacity: 0.35;
    transition: opacity 0.18s ease, background 0.18s ease, color 0.18s ease;
    user-select: none;
    -webkit-user-select: none;
    line-height: 1.2;
}
.deck-ui-button:hover,
.deck-ui-button:focus-visible { opacity: 1; outline: none; }
.deck-ui-button.is-active {
    background: var(--ucf-gold);
    color: var(--ucf-black);
    opacity: 1;
}

/* ─── 5. Help / keybindings toast (one-shot, on first visit) ─── */
.deck-help-toast {
    position: fixed;
    top: 1em;
    right: 1em;
    z-index: 10001;
    background: rgba(0, 0, 0, 0.92);
    color: var(--ucf-white);
    padding: 0.85em 1.1em 0.95em;
    border-radius: 4px;
    border-left: 3px solid var(--ucf-gold);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
    font-family: 'Inter','Segoe UI','Helvetica Neue',Arial,sans-serif;
    font-size: 13px;
    line-height: 1.6;
    max-width: 300px;
    cursor: pointer;
    transition: opacity 0.4s ease;
}
.deck-help-toast strong {
    display: block;
    color: var(--ucf-gold);
    font-family: 'JetBrains Mono','Fira Code','Cascadia Code','Consolas',monospace;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    margin-bottom: 0.5em;
}
.deck-help-toast kbd {
    background: var(--ucf-gold);
    color: var(--ucf-black);
    padding: 0.05em 0.45em;
    border-radius: 2px;
    font-family: 'JetBrains Mono','Fira Code','Cascadia Code','Consolas',monospace;
    font-weight: 700;
    font-size: 0.85em;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
    display: inline-block;
    min-width: 1.2em;
    text-align: center;
}
.deck-help-toast .dismiss-hint {
    margin-top: 0.55em;
    font-size: 0.78em;
    opacity: 0.55;
    font-style: italic;
}
.deck-help-toast.fading { opacity: 0; pointer-events: none; }

/* ─── 6. Print / PDF export ───
   reveal's ?print-pdf mode needs untransformed, unscrolled content.
   Hide the floating UI — it has no place in exported PDFs. */
@media print {
    body.fit-mode .reveal .slides section.present,
    .reveal .slides section { transform: none !important; max-height: none !important; overflow: visible !important; }
    .reveal pre { max-height: none !important; overflow: visible !important; }
    .deck-ui-button, .deck-help-toast { display: none !important; }
}

/* ── Title Slide ── */
.reveal .title-slide { text-align: center; }
.reveal .title-slide h1 { border-bottom: none; font-size: 2.4em; }
.reveal .title-slide .subtitle { font-size: 1.1em; color: var(--ucf-mid-gray); margin-top: 0.3em; }
.reveal .title-slide .course-info { font-size: 0.7em; color: var(--ucf-mid-gray); margin-top: 2em; }

/* ── Section Divider ── */
.reveal .section-divider { text-align: center; background: var(--ucf-black); }
.reveal .section-divider h2 { color: var(--ucf-gold); font-size: 2em; }
.reveal .section-divider p { color: var(--ucf-white); font-size: 0.9em; }

/* ── Live Demo Cue Slide ── */
.reveal .live-demo { text-align: center; background: linear-gradient(135deg, var(--ucf-black) 0%, var(--ucf-dark-gray) 100%); }
.reveal .live-demo h2 { color: var(--ucf-gold); font-size: 1.8em; }
.reveal .live-demo .demo-label {
    display: inline-block;
    background: var(--ucf-gold); color: var(--ucf-black);
    padding: 0.2em 0.8em; border-radius: 4px;
    font-weight: 700; font-size: 0.8em; margin-bottom: 0.5em;
}
.reveal .live-demo p { color: var(--ucf-light-gray); }

/* ── Callout Boxes ── */
.reveal .callout {
    background: var(--ucf-gold-light); border-left: 4px solid var(--ucf-gold);
    padding: 0.8em 1em; border-radius: 0 6px 6px 0; margin: 0.5em 0;
}
.reveal .callout-warning {
    background: #FFF3E0; border-left: 4px solid var(--color-sim-only);
    padding: 0.8em 1em; border-radius: 0 6px 6px 0; margin: 0.5em 0;
}
.reveal .callout-danger {
    background: #FFEBEE; border-left: 4px solid var(--color-mistake);
    padding: 0.8em 1em; border-radius: 0 6px 6px 0; margin: 0.5em 0;
}

/* ── Golden Rule Box ── */
.reveal .golden-rule {
    background: var(--ucf-black); color: var(--ucf-gold);
    padding: 1em 1.5em; border-radius: 8px;
    font-size: 1.1em; font-weight: 700; text-align: center;
    margin: 0.5em 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

/* ── Layout: Columns / Two-Col ── */
.reveal .columns,
.reveal .two-col { display: flex; gap: 2em; }
.reveal .columns .col,
.reveal .two-col .col { flex: 1; }

/* ── Panel Variants (consolidated from per-file styles) ── */
.reveal .panel { padding: 1em; border-radius: 8px; }
.reveal .panel-sw,
.reveal .panel-software { background: #F3E5F5; border: 2px solid #9C27B0; }
.reveal .panel-hw,
.reveal .panel-hardware { background: #E3F2FD; border: 2px solid #1565C0; }
.reveal .panel-good     { background: #E8F5E9; border: 2px solid #2E7D32; }
.reveal .panel-bad      { background: #FFEBEE; border: 2px solid #C62828; }
.reveal .panel-neutral  { background: #FFF8E1; border: 2px solid #F9A825; }
.reveal .panel h3 { margin-top: 0 !important; }

/* Semantic check/cross markers */
.reveal .check { color: #2E7D32; font-weight: 700; }
.reveal .cross { color: #C62828; font-weight: 700; }

/* ── Segment Breadcrumb (Enhancement #3) ── */
.reveal .seg-breadcrumb {
    display: flex; gap: 0.5em;
    justify-content: center;
    margin-top: 1.5em;
}
.reveal .seg-breadcrumb .seg-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--ucf-mid-gray);
    opacity: 0.4;
    transition: all 0.3s ease;
}
.reveal .seg-breadcrumb .seg-dot.active {
    background: var(--ucf-gold);
    opacity: 1;
    width: 28px;
    border-radius: 5px;
}
.reveal .seg-breadcrumb-labels {
    display: flex; gap: 0.8em;
    justify-content: center;
    margin-top: 0.6em;
    font-size: 0.45em;
    color: #888;
}
.reveal .seg-breadcrumb-labels .seg-label.active {
    color: var(--ucf-gold);
    font-weight: 600;
}

/* ── Big Number (for stats/emphasis) ── */
.reveal .big-number {
    font-size: 3em; font-weight: 700;
    color: var(--ucf-gold);
    text-align: center; line-height: 1;
}
.reveal .big-number span {
    display: block; font-size: 0.25em;
    color: var(--ucf-mid-gray);
    font-weight: 400; margin-top: 0.3em;
}

/* ── Progress Bar & Slide Numbers ── */
.reveal .progress { color: var(--ucf-gold); height: 4px; }
.reveal .slide-number { color: var(--ucf-mid-gray); font-size: 14px; right: 20px; bottom: 16px; }

/* ── Fragment Helpers ── */
.reveal .fragment.fade-in-then-semi-out.visible:not(.current-fragment) { opacity: 0.4; }
