/* Data For Dummies — shared visual system
   Owner: this file. Load it last in <head> on every static page.
   It is additive. Rules use :where() or accessibility-only selectors so they
   do not repaint lesson colors, syntax spans, paywall gates, or auth wiring.

   Do not style: .keyword .string .comment .function .number .type .operator
   Do not set display on: [data-access] .paywall .pro-lock-overlay
     .pro-locked-wrapper .dashboard .auth-gate .auth-page
   Do not rename storage keys or Firebase ids from this stylesheet. */

:root {
    --dfd-font: "Outfit", "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --dfd-mono: "Fira Code", ui-monospace, "SFMono-Regular", Consolas, monospace;
    --dfd-ink: #0f172a;
    --dfd-text: #1e293b;
    --dfd-muted: #475569;
    --dfd-faint: #64748b;
    --dfd-line: #e2e8f0;
    --dfd-surface: #ffffff;
    --dfd-wash: #f8fafc;
    --dfd-accent: #4f46e5;
    --dfd-accent-strong: #4338ca;
    --dfd-accent-soft: #eef2ff;
    --dfd-focus: #4f46e5;
    --dfd-ok: #047857;
    --dfd-warn: #b45309;
    --dfd-danger: #b91c1c;
    --dfd-radius: 16px;
    --dfd-radius-sm: 10px;
    --dfd-shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 12px 32px rgba(15, 23, 42, 0.06);
    --dfd-space: 8px;
    --dfd-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
    --dfd-fast: 160ms;
    color-scheme: light;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* Do not set overflow on html or body. overflow-x: clip forces the other
   axis off visible and breaks position: fixed navs, paywall modals, and menus. */

::selection {
    background: #e0e7ff;
    color: #1e1b4b;
}

/* Keyboard focus. !important so older outline:none rules cannot hide it.
   :focus-visible stays off for mouse clicks. */
:where(a, button, input, select, textarea, summary, [role="button"], [tabindex]):focus-visible {
    outline: 2px solid var(--dfd-focus) !important;
    outline-offset: 3px !important;
}

:where(input, select, textarea):focus-visible {
    outline-offset: 1px !important;
}

/* Shared overflow guards. :where() loses to any lesson rule that sets the same property. */
:where(pre, .code-block, .project-code, .comparison-table, .result-table) {
    max-width: 100%;
}

:where(pre, .code-block) {
    overflow-x: auto;
}

:where(.comparison-table, .result-table) {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

:where(img, video, iframe, canvas) {
    max-width: 100%;
}

:where(.modules-grid, .ux-paths-grid, .ux-projects-grid, .ux-tools-grid, .pricing-grid) {
    min-width: 0;
}

/* Site nav breakpoint. JS uses the same query: matchMedia('(max-width: 768px)').
   Widths 721–768 are mobile. Do not reintroduce a 720px cutoff. */
@media (max-width: 768px) {
    *,
    *::before,
    *::after {
        box-sizing: border-box;
    }

    .page-orb-bg {
        max-width: 100%;
        overflow: hidden;
    }

    #navbar .container,
    .journey-header-row,
    .step {
        flex-wrap: wrap;
        height: auto;
        max-width: 100%;
    }

    .section-subtitle {
        white-space: normal;
    }

    .step-content,
    .section-header {
        min-width: 0;
        max-width: 100%;
    }

    pre,
    .code-block,
    table,
    table.data-table,
    .data-table {
        max-width: 100%;
        min-width: 0 !important;
        overflow-x: auto;
    }

    /* A display:table box grows instead of scrolling, so the table becomes the
       scroll container; rows and cells keep table layout inside it. */
    table {
        display: block;
        -webkit-overflow-scrolling: touch;
    }

    pre,
    .code-block {
        overflow-wrap: anywhere;
    }

    :where(p, li, dd, dt, blockquote, figcaption, .download-box) {
        overflow-wrap: break-word;
    }

    /* Many headings and quiz options are flex rows; only "anywhere" lowers a
       flex item's min-content so one long identifier cannot widen the page. */
    :where(h1, h2, h3, h4, h5, h6, .opt),
    :where(p, li, dd, dt, blockquote, figcaption, .download-box) :where(code, kbd, samp, a) {
        overflow-wrap: anywhere;
    }

    :where(.nav, .lesson-nav, .hero-cta-row, .ux-hero-btns) {
        flex-wrap: wrap;
    }

    :where(.header, .lesson-hero) {
        padding-left: 18px;
        padding-right: 18px;
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Lesson foundation. These classes are opt-in. They do not restyle syntax
   spans (.keyword .string .comment .function .number .type .operator) and
   they do not set display on paywall, auth, or dashboard gates.
   :where() loses to any lesson rule, so family styles keep their colors. */

:where(body.dfd-safe) {
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
    padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
}

:where(.dfd-hit, .dfd-quiz-choice, .dfd-back-top, .dfd-diagram-control, [data-dfd-complete]) {
    min-width: 48px;
    min-height: 48px;
    touch-action: manipulation;
}

:where(.dfd-back-top) {
    position: fixed;
    right: max(16px, env(safe-area-inset-right, 0px));
    bottom: max(16px, env(safe-area-inset-bottom, 0px));
    z-index: 30;
    padding: 0 14px;
    border: 0;
    border-radius: 999px;
    background: var(--dfd-accent);
    color: #fff;
    font: 700 0.95rem/1 var(--dfd-font);
    cursor: pointer;
}

:where(.dfd-quiz) {
    max-width: 100%;
    margin: 24px 0;
    padding: 20px;
    border: 1px solid var(--dfd-line);
    border-radius: var(--dfd-radius);
    background: var(--dfd-surface);
}

:where(.dfd-quiz-choice) {
    display: block;
    width: 100%;
    margin: 8px 0;
    padding: 12px 16px;
    text-align: left;
    font: 600 1rem/1.4 var(--dfd-font);
    color: var(--dfd-text);
    background: var(--dfd-wash);
    border: 2px solid var(--dfd-line);
    border-radius: var(--dfd-radius-sm);
    overflow-wrap: anywhere;
    cursor: pointer;
}

:where(.dfd-quiz-choice.dfd-quiz-correct) {
    border-color: var(--dfd-ok);
    background: #ecfdf5;
}

:where(.dfd-quiz-choice.dfd-quiz-wrong) {
    border-color: var(--dfd-danger);
    background: #fef2f2;
}

:where(.dfd-quiz-feedback, .dfd-quiz-explain) {
    margin-top: 12px;
    overflow-wrap: anywhere;
}

:where(.dfd-lesson-progress) {
    margin: 20px 0;
}

:where(.dfd-lesson-progress-track) {
    height: 12px;
    border-radius: 999px;
    background: var(--dfd-line);
    overflow: hidden;
}

:where(.dfd-lesson-progress-fill) {
    height: 100%;
    width: 0;
    background: var(--dfd-accent);
}

:where(.dfd-diagram) {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

:where(.dfd-diagram svg, svg.dfd-responsive) {
    display: block;
    max-width: 100%;
    height: auto;
}

:where(.dfd-diagram-controls) {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

:where(.dfd-scroll) {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

:where(pre, .code-block) {
    max-width: 100%;
}

@media (prefers-reduced-motion: no-preference) {
    [data-dfd-reveal].dfd-reveal-pending {
        opacity: 0;
        transform: translateY(12px);
    }

    [data-dfd-reveal].dfd-revealed {
        opacity: 1;
        transform: none;
        transition: opacity 420ms var(--dfd-ease), transform 420ms var(--dfd-ease);
    }
}


/* Responsive chrome. Layout only: safe areas, touch size, and iOS input zoom.
   Colors stay in the family stylesheets. 768px matches the nav query above. */

*,
*::before,
*::after {
    box-sizing: border-box;
}

.main-nav {
    top: max(8px, env(safe-area-inset-top, 0px));
    width: min(1100px, calc(100% - 32px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
}

.top-nav {
    top: max(8px, env(safe-area-inset-top, 0px));
    max-width: min(1100px, calc(100% - 16px - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px)));
}

.footer {
    padding-bottom: max(24px, env(safe-area-inset-bottom, 0px));
}

.section-subtitle {
    white-space: normal;
    overflow-wrap: anywhere;
}

.top-offset-for-nav,
body.page-home .home-stage {
    padding-top: max(76px, calc(64px + env(safe-area-inset-top, 0px))) !important;
}

.back-to-top {
    right: max(16px, env(safe-area-inset-right, 0px));
    bottom: max(16px, env(safe-area-inset-bottom, 0px));
}

#contactModal,
#paywall-overlay,
.admin-signin-modal,
.auth-modal {
    box-sizing: border-box;
    padding-top: max(20px, env(safe-area-inset-top, 0px)) !important;
    padding-right: max(20px, env(safe-area-inset-right, 0px)) !important;
    padding-bottom: max(20px, env(safe-area-inset-bottom, 0px)) !important;
    padding-left: max(20px, env(safe-area-inset-left, 0px)) !important;
}

@media (max-width: 1024px) {
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="button"]):not([type="submit"]):not([type="reset"]):not([type="hidden"]):not([type="image"]):not([type="file"]),
    select,
    textarea {
        font-size: 16px !important;
    }
}

@media (max-width: 768px) {
    .mobile-menu-toggle,
    .back-to-top,
    #contactModal button,
    #paywall-cta,
    .home-btn,
    .home-tools button,
    .ds-btn,
    .auth-submit,
    .lesson-nav a,
    .quiz-option,
    .quiz-opt,
    .dfd-quiz-choice,
    .opt-btn,
    .medal-btn,
    .tab-btn,
    .btn-add,
    .btn-quick,
    .btn-export {
        min-height: 48px;
    }

    .mobile-menu-toggle,
    .back-to-top,
    #contactModal button {
        min-width: 48px;
    }

    .nav-links .nav-link,
    .nav-links .nav-dropdown-trigger,
    .nav-links .nav-dropdown-link {
        min-height: 48px;
        display: flex;
        align-items: center;
    }

    .nav-links.nav-open {
        justify-content: flex-start;
        align-items: stretch;
    }

    .nav-links.nav-open .nav-dropdown-panel {
        position: static;
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: none;
        display: flex;
        flex-direction: column;
        width: 100%;
        min-width: 0;
        margin: 0;
        padding: 0;
        border: 0;
        box-shadow: none;
        background: transparent;
    }
}

:where(.dfd-legal) {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin: 12px 0 0;
}

:where(.dfd-legal a) {
    text-underline-offset: 3px;
}

/* Learn menu stays closed until hover, keyboard focus, or the mobile menu opens.
   Tool pages do not load hub-styles.css, so this rule has to live here. */
.nav-dropdown {
    position: relative;
    flex: 0 0 auto;
}

.nav-dropdown-trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 0;
    background: transparent;
    color: #475569;
    font: inherit;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
}

.top-nav .nav-dropdown-panel,
.main-nav .nav-dropdown-panel {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 1002;
    display: flex;
    flex-direction: column;
    min-width: 220px;
    margin: 0;
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.14);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-4px);
}

.nav-dropdown:hover .nav-dropdown-panel,
.nav-dropdown:focus-within .nav-dropdown-panel {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
}

.nav-dropdown-link {
    display: flex;
    align-items: center;
    min-height: 40px;
    padding: 8px 12px;
    border-radius: 10px;
    color: #334155;
    font-weight: 650;
    text-decoration: none;
    white-space: nowrap;
}

.nav-dropdown-link:hover {
    background: #eef2ff;
    color: #4338ca;
}

#auth-nav-slot,
.app-download-nav {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
    white-space: nowrap;
}

.app-download-nav {
    gap: 4px;
    color: #64748b;
    font-weight: 700;
    text-decoration: none;
}

.app-download-nav-text {
    max-width: 0;
    overflow: hidden;
    opacity: 0;
    white-space: nowrap;
}

.app-download-nav:hover .app-download-nav-text,
.app-download-nav:focus-visible .app-download-nav-text {
    max-width: 160px;
    opacity: 1;
}

/* Step-through lesson diagrams (scripts/build_lesson_diagrams.py). */
.dfd-flow {
    --flow-accent: var(--hub-color, var(--dfd-accent));
    overflow: visible;
}

.dfd-flow .dfd-flow-intro {
    margin: 4px 0 16px;
    color: var(--dfd-muted);
}

.dfd-flow .dfd-flow-controls {
    margin: 0 0 18px;
}

.dfd-flow .dfd-flow-controls button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 8px 14px 8px 8px;
    border: 1px solid var(--dfd-line);
    border-radius: 999px;
    background: var(--dfd-surface);
    color: var(--dfd-text);
    font: 600 0.95rem/1.2 var(--dfd-font);
    cursor: pointer;
    transition: border-color var(--dfd-fast) var(--dfd-ease), background var(--dfd-fast) var(--dfd-ease), color var(--dfd-fast) var(--dfd-ease);
}

.dfd-flow .dfd-flow-controls button:hover {
    border-color: var(--flow-accent);
}

.dfd-flow .dfd-flow-controls button[aria-pressed="true"] {
    border-color: var(--flow-accent);
    background: var(--flow-accent);
    color: #ffffff;
}

.dfd-flow-num {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--dfd-accent-soft);
    color: var(--dfd-accent-strong);
    font-size: 0.85rem;
    font-weight: 700;
}

.dfd-flow .dfd-flow-controls button[aria-pressed="true"] .dfd-flow-num {
    background: rgba(255, 255, 255, 0.22);
    color: #ffffff;
}

.dfd-flow-track {
    display: flex;
    align-items: stretch;
    gap: 28px;
    margin: 0;
    padding: 0;
    list-style: none;
    counter-reset: none;
}

.dfd-flow-node {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    padding: 16px;
    border: 1px solid var(--dfd-line);
    border-radius: var(--dfd-radius-sm);
    background: var(--dfd-wash);
    color: var(--dfd-muted);
    transition: transform 240ms var(--dfd-ease), border-color 240ms var(--dfd-ease), background 240ms var(--dfd-ease), box-shadow 240ms var(--dfd-ease), opacity 240ms var(--dfd-ease);
    opacity: 0.72;
}

.dfd-flow-node + .dfd-flow-node::before {
    content: "";
    position: absolute;
    top: 50%;
    left: -24px;
    width: 20px;
    height: 2px;
    background: var(--dfd-line);
}

.dfd-flow-node + .dfd-flow-node::after {
    content: "";
    position: absolute;
    top: calc(50% - 4px);
    left: -10px;
    border: 5px solid transparent;
    border-left-color: var(--dfd-line);
}

.dfd-flow-node.is-active {
    border-color: var(--flow-accent);
    background: var(--dfd-surface);
    color: var(--dfd-text);
    box-shadow: 0 0 0 3px var(--dfd-accent-soft), var(--dfd-shadow);
    transform: translateY(-2px);
    opacity: 1;
}

.dfd-flow-node.is-fed::before {
    background: repeating-linear-gradient(90deg, var(--flow-accent) 0 6px, transparent 6px 10px);
    background-size: 20px 2px;
    animation: dfdFlowDash 900ms linear infinite;
}

.dfd-flow-node.is-fed::after {
    border-left-color: var(--flow-accent);
}

.dfd-flow-label {
    color: var(--dfd-ink);
    font-weight: 700;
    font-size: 1rem;
    line-height: 1.3;
    overflow-wrap: anywhere;
}

.dfd-flow-role {
    font-size: 0.88rem;
    line-height: 1.4;
}

.dfd-flow-explain {
    margin-top: 18px;
    padding: 16px 18px;
    border-left: 4px solid var(--flow-accent);
    border-radius: 0 var(--dfd-radius-sm) var(--dfd-radius-sm) 0;
    background: var(--dfd-wash);
}

.dfd-flow-caption {
    margin: 0;
    color: var(--dfd-text);
    line-height: 1.6;
}

.dfd-flow-count {
    display: block;
    margin-bottom: 4px;
    color: var(--flow-accent);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.dfd-flow-example {
    margin: 12px 0 0;
    padding: 12px 14px;
    border-radius: 8px;
    background: #0f172a;
    color: #e2e8f0;
    padding-right: 52px;
    font: 0.86rem/1.55 var(--dfd-mono);
    font-variant-ligatures: none;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.dfd-flow-example code {
    background: none;
    color: inherit;
    padding: 0;
    font: inherit;
}

.dfd-flow-example-ui {
    background: var(--dfd-surface);
    color: var(--dfd-text);
    border: 1px dashed var(--dfd-line);
    font-family: var(--dfd-font);
}

.dfd-flow-panel:not([hidden]) {
    animation: dfdFlowIn 260ms var(--dfd-ease);
}

@keyframes dfdFlowDash {
    to { background-position: 20px 0; }
}

@keyframes dfdFlowIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

@media (max-width: 640px) {
    .dfd-flow-track {
        flex-direction: column;
        gap: 22px;
    }

    .dfd-flow-node + .dfd-flow-node::before {
        top: -18px;
        left: 24px;
        width: 2px;
        height: 14px;
    }

    .dfd-flow-node.is-fed::before {
        background: repeating-linear-gradient(180deg, var(--flow-accent) 0 6px, transparent 6px 10px);
        background-size: 2px 20px;
        animation-name: dfdFlowDashDown;
    }

    .dfd-flow-node + .dfd-flow-node::after {
        top: -6px;
        left: 20px;
        border-left-color: transparent;
        border-top-color: var(--dfd-line);
    }

    .dfd-flow-node.is-fed::after {
        border-left-color: transparent;
        border-top-color: var(--flow-accent);
    }

    .dfd-flow .dfd-flow-controls button {
        flex: 1 1 100%;
    }
}

@keyframes dfdFlowDashDown {
    to { background-position: 0 20px; }
}

@media (prefers-reduced-motion: reduce) {
    .dfd-flow-node,
    .dfd-flow-panel:not([hidden]),
    .dfd-flow-node.is-fed::before {
        animation: none;
        transition: none;
        transform: none;
    }
}
