/* ==========================================================================
   RESPONSIVE BREAKPOINTS, REDUCED MOTION & PRINT EXPORT
   ========================================================================== */

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

    body,
    .status-dot,
    .section-index,
    .hero-stamp,
    .arch-flow,
    .pcb-line,
    .eq-bars i,
    .project-card.surprise-flash {
        animation: none !important;
    }

    .reveal,
    .stagger-item {
        opacity: 1 !important;
        transform: none !important;
    }

    .cursor-ring {
        display: none !important;
    }

    * {
        transition: none !important;
    }
}

/* TABLET */
@media (max-width: 980px) {
    .hero,
    .arcade-grid,
    .matrix-grid,
    .offscreen-grid,
    .principles-strip,
    .mcu-layout {
        grid-template-columns: 1fr;
    }

    .terminal {
        min-height: 410px;
        height: 430px;
        max-height: none;
    }

    .principle-cell {
        border-right: none;
        border-bottom: var(--border);
    }

    .principle-cell:last-child {
        border-bottom: none;
    }

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

    .pillar-card,
    .pillar-card:nth-child(1),
    .pillar-card:nth-child(2),
    .pillar-card:nth-child(3),
    .pillar-card:nth-child(4) {
        grid-column: span 1;
    }

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

/* MOBILE */
@media (max-width: 680px) {
    :root {
        --shadow: 4px 4px 0px var(--shadow-color);
        --shadow-sm: 2px 2px 0px var(--shadow-color);
        --shadow-lg: 6px 6px 0px var(--shadow-color);
    }

    .topbar {
        padding: 0.55rem 0.8rem 0.48rem;
        gap: 0.5rem;
    }

    .brand-group {
        width: 100%;
        justify-content: space-between;
        gap: 0.36rem;
        flex-wrap: nowrap;
    }

    .brand {
        font-size: 0.88rem;
        gap: 0.38rem;
        min-width: 0;
    }

    .brand .scramble {
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .status-dot {
        width: 9px;
        height: 9px;
    }

    .pill {
        font-size: 0.6rem;
        padding: 0.16rem 0.38rem;
    }

    .pill-btn,
    #clearanceBadge {
        min-width: 0;
    }

    .xp-popover {
        left: 0;
        right: 0;
        width: min(300px, calc(100vw - 1.5rem));
        padding: 0.78rem;
    }

    .nav-links {
        width: 100%;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 0.38rem;
        padding: 1px 2px 4px 0;
    }

    .nav-links::-webkit-scrollbar {
        display: none;
    }

    .nav-divider {
        display: none;
    }

    .nav-links a,
    .nav-links .btn {
        flex: 0 0 auto;
        font-size: 0.67rem;
        padding: 0.36rem 0.56rem;
    }

    .nav-links a {
        border: 1px solid var(--hairline-strong);
        background: var(--surface-2);
    }

    .nav-links a::after {
        display: none;
    }

    .nav-links a.nav-active {
        background: var(--surface-invert);
        color: var(--ink-invert);
    }

    #einkToggle,
    #sfxToggle,
    #themeCycleBtn {
        min-width: 0;
    }

    .marquee {
        font-size: 0.7rem;
        padding: 0.42rem 0;
    }

    .container {
        padding: 1.2rem 0.9rem 2.8rem;
    }

    section {
        margin-bottom: 2.9rem;
    }

    section[id] {
        scroll-margin-top: 104px;
    }

    .section-header {
        margin-bottom: 1.2rem;
        padding-bottom: 0.55rem;
        gap: 0.45rem 0.75rem;
        flex-wrap: wrap;
        align-items: center;
    }

    .section-line {
        display: none;
    }

    .section-title {
        font-size: clamp(1.34rem, 5.8vw, 1.85rem);
        flex: 1 1 auto;
        min-width: 0;
    }

    .section-index {
        font-size: 0.67rem;
        padding: 0.2rem 0.48rem;
        animation: none;
    }

    #heroInk {
        inset: 0;
        width: 100%;
        height: 100%;
    }

    .hero {
        gap: 1.25rem;
    }

    .hero-main {
        padding: 1.25rem 1.05rem 1.1rem;
    }

    .hero-top-row {
        margin-bottom: 0.85rem;
    }

    .hero-stamp {
        display: none;
    }

    .eyebrow {
        font-size: 0.64rem;
        padding: 0.22rem 0.5rem;
    }

    .hero h1 {
        font-size: clamp(2rem, 9.6vw, 2.8rem);
        gap: 0.24rem 0.38rem;
        margin-bottom: 0.9rem;
    }

    .hero h1 .highlight {
        padding: 0.04rem 0.3rem;
        box-shadow: 3px 3px 0 var(--shadow-color);
    }

    .hero-lead {
        font-size: 0.96rem;
        line-height: 1.56;
        margin-bottom: 1.2rem;
    }

    .hero-actions {
        display: grid;
        grid-template-columns: 1fr;
        gap: 0.55rem;
        width: 100%;
    }

    .hero-actions .btn,
    .hero-actions a {
        width: 100%;
        padding: 0.62rem 0.8rem;
        font-size: 0.74rem;
    }

    .ink-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.45rem;
        margin-top: 0.95rem;
    }

    .ink-hint {
        font-size: 0.65rem;
        line-height: 1.4;
    }

    .ink-btns {
        width: 100%;
    }

    #touchDrawBtn,
    #clearHeroInk {
        padding: 0.3rem 0.55rem;
        font-size: 0.68rem;
    }

    .hero-meta {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .hero-meta > div {
        padding: 0.75rem 0.95rem;
    }

    .hero-meta > div:nth-child(2) {
        border-right: none;
    }

    .hero-meta > div:last-child {
        grid-column: 1 / -1;
        border-right: none;
        border-top: 1px dashed var(--hairline-strong);
    }

    .meta-val {
        font-size: 0.8rem;
    }

    .terminal {
        min-height: 392px;
        height: 396px;
    }

    .terminal-bar {
        padding: 0.5rem 0.8rem;
        font-size: 0.67rem;
    }

    .terminal-body {
        padding: 0.8rem;
        font-size: 0.74rem;
        line-height: 1.54;
    }

    .term-ascii {
        font-size: 0.62rem;
        line-height: 1.3;
        overflow-x: auto;
    }

    .term-input-row {
        padding: 0.5rem 0.7rem;
        gap: 0.36rem;
    }

    .term-input-row label {
        font-size: 0.7rem;
    }

    .term-input {
        font-size: 16px;
    }

    .term-run-btn {
        padding: 0.28rem 0.52rem;
        font-size: 0.68rem;
    }

    .term-quick {
        padding: 0.52rem 0.7rem;
        gap: 0.32rem;
    }

    .cmd-chip {
        font-size: 0.66rem;
        padding: 0.24rem 0.44rem;
    }

    .pillars-grid,
    .projects-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .pillar-card {
        padding: 1.25rem;
        gap: 0.55rem;
    }

    .pillar-card h3 {
        font-size: 1.18rem;
    }

    .vault-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 0.6rem;
        margin-bottom: 1.2rem;
        padding: 0.65rem;
    }

    .filter-bar,
    .vault-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.45rem;
        width: 100%;
    }

    .filter-bar .btn,
    .vault-actions .btn {
        width: 100%;
        min-width: 0 !important;
        padding: 0.48rem 0.4rem;
        font-size: 0.67rem;
    }

    .project-top {
        padding: 1.15rem;
    }

    .project-card h3 {
        font-size: 1.18rem;
    }

    .project-card p {
        font-size: 0.89rem;
    }

    .project-foot {
        padding: 0.7rem 1rem;
        font-size: 0.68rem;
    }

    .arcade-grid {
        gap: 1.15rem;
    }

    .arcade-head {
        padding: 0.64rem 0.85rem;
        font-size: 0.67rem;
        gap: 0.4rem;
    }

    .arcade-body {
        padding: 0.92rem;
        gap: 0.74rem;
    }

    .physics-stage {
        height: 265px;
    }

    .stage-badge {
        font-size: 0.58rem;
        padding: 0.14rem 0.36rem;
    }

    .btn-row {
        width: 100%;
        gap: 0.36rem;
    }

    .btn-row .btn {
        flex: 1 1 auto;
        padding: 0.4rem 0.4rem;
        font-size: 0.65rem;
    }

    .drop-form {
        min-width: 0;
        width: 100%;
    }

    .brutal-input {
        font-size: 16px;
        padding: 0.38rem 0.55rem;
    }

    .hud-grid {
        gap: 0.35rem;
    }

    .hud-box {
        padding: 0.36rem 0.22rem;
    }

    .hud-label {
        font-size: 0.55rem;
    }

    .hud-val {
        font-size: 0.88rem;
    }

    .led-wrap {
        padding: 0.45rem;
    }

    .led-grid {
        gap: 0.4rem;
    }

    .led-pad {
        height: auto;
        aspect-ratio: 1 / 1;
        min-height: 50px;
        font-size: 0.74rem;
    }

    #rxStartBtn {
        width: 100%;
        padding: 0.54rem;
    }

    .mcu-head {
        padding: 0.64rem 0.85rem;
        font-size: 0.67rem;
    }

    .mcu-layout {
        padding: 0.92rem;
        gap: 0.95rem;
    }

    .chip-board {
        grid-template-columns: 1fr;
        padding: 0.8rem;
        gap: 0.6rem;
    }

    .pcb-traces,
    .fiducial {
        display: none;
    }

    .pin-col {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.36rem;
    }

    .pin-btn {
        font-size: 0.64rem;
        padding: 0.4rem 0.42rem;
    }

    .chip-core {
        width: 100%;
        height: 66px;
        flex-direction: row;
        padding: 0.5rem 0.85rem;
        box-shadow: 4px 4px 0 var(--accent);
    }

    .chip-notch {
        width: 10px;
        height: 22px;
        border: 2px solid #f4f4f0;
        border-left: none;
    }

    .pin-readout {
        padding: 1rem;
        min-height: 170px;
        gap: 0.55rem;
    }

    .pin-readout h4 {
        font-size: 1.15rem;
    }

    .pin-readout p {
        font-size: 0.87rem;
    }

    .matrix-grid {
        gap: 1rem;
        margin-bottom: 1rem;
    }

    .matrix-box {
        padding: 1.15rem;
    }

    .matrix-box h3 {
        font-size: 0.86rem;
    }

    .spec-list li {
        flex-direction: column;
        gap: 0.16rem;
        font-size: 0.86rem;
    }

    .spec-val {
        text-align: left;
    }

    .principles-strip {
        margin-bottom: 1rem;
    }

    .principle-cell {
        padding: 1rem;
    }

    .offscreen-grid {
        gap: 1rem;
    }

    .offscreen-card {
        padding: 1.2rem;
    }

    .contact-banner {
        padding: 1.45rem 1.1rem;
        gap: 1.15rem;
    }

    .contact-banner h2 {
        font-size: clamp(1.5rem, 7.2vw, 2.1rem);
    }

    .contact-banner p {
        font-size: 0.76rem;
    }

    footer {
        padding: 1rem 0.9rem;
        font-size: 0.69rem;
        line-height: 1.45;
    }

    .boot-box {
        padding: 1.1rem;
        box-shadow: 6px 6px 0 #df1b2f;
    }

    .boot-line {
        font-size: 0.72rem;
    }

    .modal-backdrop {
        padding: 0.6rem;
    }

    .modal-card {
        max-height: 88dvh;
    }

    .modal-head {
        padding: 0.72rem 0.9rem;
    }

    .modal-head-title {
        font-size: 0.72rem;
    }

    .modal-body {
        padding: 1rem;
        gap: 0.78rem;
    }

    .modal-body h3 {
        font-size: 1.28rem;
    }

    .modal-body p {
        font-size: 0.88rem;
    }

    .modal-highlights {
        font-size: 0.74rem;
        padding: 0.72rem 0;
    }

    .modal-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 0.55rem;
    }

    .modal-actions .btn,
    .modal-actions a {
        width: 100%;
        padding: 0.55rem;
    }

    .field-input,
    .field-textarea,
    .cmdk-input {
        font-size: 16px;
    }

    .cmdk-item {
        padding: 0.68rem 0.85rem;
        font-size: 0.74rem;
    }

    .toast {
        left: 0.75rem;
        right: 0.75rem;
        bottom: 0.85rem;
        text-align: center;
        font-size: 0.72rem;
        padding: 0.65rem 0.85rem;
    }

    .rebuild-bar {
        width: calc(100vw - 1.5rem);
        justify-content: space-between;
        font-size: 0.7rem;
        padding: 0.55rem 0.75rem;
        gap: 0.5rem;
    }
}

@media (max-width: 380px) {
    .hero h1 {
        font-size: 1.76rem;
    }

    .hud-val {
        font-size: 0.78rem;
    }

    .led-pad {
        min-height: 44px;
        font-size: 0.68rem;
    }

    .pin-btn {
        font-size: 0.6rem;
        padding: 0.34rem 0.36rem;
    }
}

/* PRINT EXPORT */
@media print {
    body {
        background: #ffffff !important;
        color: #000000 !important;
    }

    body::before {
        display: none !important;
    }

    .boot-curtain,
    .topbar-wrap,
    .marquee,
    #fxCanvas,
    .cursor-ring,
    #heroInk,
    .terminal,
    #arcade,
    .mcu-card,
    .ink-bar,
    .hero-actions,
    .vault-controls,
    .project-foot,
    .contact-banner,
    .modal-backdrop,
    .toast,
    .rebuild-bar,
    .pillar-motif,
    .offscreen-motif,
    .project-blueprint,
    .pin-wave {
        display: none !important;
    }

    .container {
        padding: 0 !important;
        max-width: 100% !important;
    }

    section {
        margin-bottom: 1.6rem !important;
        break-inside: avoid;
    }

    .hero {
        grid-template-columns: 1fr !important;
    }

    .pillars-grid,
    .projects-grid,
    .matrix-grid,
    .principles-strip,
    .offscreen-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.8rem !important;
    }

    .pillar-card,
    .pillar-card:nth-child(1),
    .pillar-card:nth-child(2),
    .pillar-card:nth-child(3),
    .pillar-card:nth-child(4) {
        grid-column: span 1 !important;
    }

    .hero-card,
    .pillar-card,
    .project-card,
    .matrix-box,
    .offscreen-card,
    .principles-strip {
        box-shadow: none !important;
        border: 2px solid #000 !important;
        background: #fff !important;
        color: #000 !important;
    }

    .reveal,
    .stagger-item {
        opacity: 1 !important;
        transform: none !important;
    }

    .redacted {
        background: #eee !important;
        color: #000 !important;
        border: 1px solid #000 !important;
    }

    .redacted::before {
        content: "[STEALTH]";
        color: #000 !important;
    }
}

