/* Portfolio — slide-based storytelling view */

/* ── Color tokens ── */
#portfolio {
    --pf-bg: #0a0a0f;
    --pf-text: rgba(235, 225, 200, 1);
    --pf-text-mid: rgba(235, 225, 200, 0.8);
    --pf-text-dim: rgba(235, 225, 200, 0.6);
    --pf-text-faint: rgba(235, 225, 200, 0.25);
    --pf-accent: rgba(212, 178, 100, 0.75);
    --pf-border: rgba(235, 225, 200, 0.12);
    --pf-border-strong: rgba(235, 225, 200, 0.28);
    --pf-footer-bg: rgba(10, 10, 15, 0.85);
    --pf-link: rgba(235, 225, 200, 0.85);
    --pf-link-hover: rgba(235, 225, 200, 1);
    --pf-link-underline: rgba(235, 225, 200, 0.3);
    --pf-link-underline-hover: rgba(235, 225, 200, 0.6);
    --pf-visual-bg: #f5f5f5;
    --pf-expand-bg: rgba(10, 10, 15, 0.8);
    --pf-name: rgba(235, 225, 200, 0.9);
}

/* Noise texture overlay */
.pf-slide::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.72' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-size: 200px 200px;
    opacity: 0.25;
    mix-blend-mode: overlay;
}

.pf-light .pf-slide::before {
    opacity: 0.6;
    mix-blend-mode: overlay;
}

/* Dark mode animated background texture */
.pf-slide::after {
    content: '';
    position: absolute;
    inset: -50%;
    width: 200%;
    height: 200%;
    background:
        radial-gradient(ellipse 50% 40% at 20% 25%, rgba(196,163,90,0.10), transparent 70%),
        radial-gradient(ellipse 45% 50% at 80% 75%, rgba(196,163,90,0.08), transparent 65%),
        radial-gradient(ellipse 35% 30% at 50% 45%, rgba(196,163,90,0.04), transparent 60%);
    pointer-events: none;
    z-index: 0;
    animation: shaderDrift 25s ease-in-out infinite alternate;
}

/* Light mode animated background texture */
.pf-light .pf-slide::after {
    content: '';
    position: absolute;
    inset: -50%;
    width: 200%;
    height: 200%;
    background:
        radial-gradient(ellipse 40% 30% at 30% 35%, rgba(56,73,148,0.12), transparent 70%),
        radial-gradient(ellipse 35% 40% at 70% 65%, rgba(56,73,148,0.10), transparent 65%),
        radial-gradient(ellipse 30% 25% at 50% 50%, rgba(56,73,148,0.05), transparent 60%);
    pointer-events: none;
    z-index: 0;
    animation: shaderDrift 25s ease-in-out infinite alternate;
}

@keyframes shaderDrift {
    0% { transform: translate(0%, 0%) rotate(0deg); }
    33% { transform: translate(-8%, 5%) rotate(2deg); }
    66% { transform: translate(5%, -8%) rotate(-1.5deg); }
    100% { transform: translate(-3%, 3%) rotate(1deg); }
}

.pf-light .pf-slide > * {
    position: relative;
    z-index: 1;
}

#portfolio.pf-light {
    --pf-bg: #f5f4f0;
    --pf-text: rgba(25, 20, 10, 0.95);
    --pf-text-mid: rgba(25, 20, 10, 0.7);
    --pf-text-dim: rgba(25, 20, 10, 0.5);
    --pf-text-faint: rgba(25, 20, 10, 0.15);
    --pf-accent: rgba(150, 120, 45, 0.8);
    --pf-border: rgba(25, 20, 10, 0.1);
    --pf-border-strong: rgba(25, 20, 10, 0.2);
    --pf-footer-bg: rgba(245, 244, 240, 0.9);
    --pf-link: rgba(150, 120, 45, 0.9);
    --pf-link-hover: rgba(150, 120, 45, 1);
    --pf-link-underline: rgba(150, 120, 45, 0.3);
    --pf-link-underline-hover: rgba(150, 120, 45, 0.6);
    --pf-visual-bg: #fff;
    --pf-expand-bg: rgba(245, 244, 240, 0.9);
    --pf-name: rgba(25, 20, 10, 0.8);
}

/* When portfolio is active, override body defaults */
body.portfolio-active {
    overflow: hidden;
}

body.portfolio-active::before {
    /* Disable CRT scanlines in portfolio */
    display: none;
}

/* Portfolio container */
#portfolio {
    position: fixed;
    inset: 0;
    z-index: 800;
    background-color: var(--pf-bg);
    overflow: hidden;
    transition: background-color 0.4s ease;
}


#portfolio.hidden {
    display: none;
}

/* ── Slides ── */

.pf-slide {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    padding: 0;
    opacity: 0;
    pointer-events: none;
    overflow-y: auto;
}

/* Incoming slide fades in */
.pf-slide.active {
    opacity: 1;
    pointer-events: auto;
    z-index: 2;
    transition: opacity 0.5s ease;
}

/* Outgoing slides disappear fast — no overlap with incoming */
.pf-slide.prev,
.pf-slide.next {
    opacity: 0;
    z-index: 1;
    transition: opacity 0.1s ease;
}

/* Same-section transition: header stays, only visual animates */
.pf-slide.active.pf-same-section {
    transition: none;
    opacity: 1;
}

.pf-slide.active.pf-same-section .pf-slide-visual {
    animation: visualSwap 0.4s ease both;
}

@keyframes visualSwap {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ── Slide content layouts ── */

/* Inner wrapper */
.pf-slide-inner {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Individual vertical panel (snaps to viewport) */
.pf-panel {
    min-height: 100%;
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding: 43px 49px;
    padding-bottom: 80px; /* space for footer */
    box-sizing: border-box;
}

.pf-panel-full {
    padding: 0;
}

/* Slide header area — heading left, body pinned right */
.pf-slide-head {
    display: flex;
    align-items: flex-start;
    gap: 48px;
    width: 100%;
}

.pf-slide-head .pf-heading {
    flex: 0 0 auto;
    max-width: 480px;
    margin-right: auto;
}

.pf-slide-head .pf-body {
    flex: 1 1 0;
    max-width: 580px;
    text-align: right;
}

/* Visual asset area below header */
.pf-slide-visual {
    flex: 1;
    width: 100%;
    margin-top: 24px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--pf-border-strong);
    position: relative;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.pf-slide-visual:hover {
    transform: scale(1.02);
    border-color: rgba(196, 163, 90, 0.4);
    box-shadow:
        0 16px 50px rgba(0, 0, 0, 0.4),
        0 0 40px rgba(196, 163, 90, 0.06);
}

.pf-light .pf-slide-visual:hover {
    border-color: rgba(56, 73, 148, 0.3);
    box-shadow:
        0 16px 50px rgba(0, 0, 0, 0.1),
        0 0 40px rgba(56, 73, 148, 0.06);
}

.pf-slide-visual iframe {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 6px;
    background: #0a0a0f;
    pointer-events: none;
}

.pf-slide-visual {
    background: #0a0a0f;
    position: relative;
    z-index: 2;
}

.pf-light .pf-slide-visual {
    background: #f5f4f0;
    border-color: var(--pf-border-strong);
}

/* CRT / ink bleed — subtle glow on hover */
.pf-heading,
.pf-body,
.pf-fn-text,
.pf-fn-body {
    transition: text-shadow 0.4s ease, color 0.4s ease;
}

/* Per-character ink bleed / phosphor glow on hover */
.pf-char {
    transition: text-shadow 2s ease-out;
    cursor: default;
}

.pf-char:hover {
    text-shadow: 0 0 2px currentColor;
    transition: text-shadow 0.1s ease;
}

.pf-light .pf-char:hover {
    text-shadow: 0 0 1.5px currentColor;
}

/* ── Bouncing title slide ── */
.pf-slide-bounce {
    overflow: hidden;
}

.pf-bounce-text {
    position: absolute;
    top: 0;
    left: 0;
    font-family: 'JetBrains Mono', monospace;
    font-size: clamp(14px, 2vw, 22px);
    font-weight: 500;
    letter-spacing: 0.08em;
    color: var(--pf-text-dim);
    white-space: nowrap;
    will-change: transform;
    z-index: 3;
    text-shadow: 0 0 2px currentColor, 0 0 6px currentColor;
}

/* ── Quote slide ── */
.pf-slide-quote {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px;
}

.pf-quote-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    max-width: 800px;
}

.pf-quote-line {
    font-family: 'Instrument Serif', Georgia, serif;
    font-size: clamp(24px, 3.5vw, 48px);
    line-height: 1.4;
    color: var(--pf-text);
    text-align: center;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
    transition: transform 0.6s ease, opacity 0.6s ease;
}

.pf-quote-line-1 {
    font-size: clamp(32px, 5vw, 64px);
    white-space: nowrap;
}

.pf-quote-line-2,
.pf-quote-line-3 {
    opacity: 0;
    transform: translateY(20px);
    max-height: 0;
    overflow: hidden;
    transition: transform 0.6s ease, opacity 0.6s ease, max-height 0.6s ease;
}

.pf-quote-line-2.visible,
.pf-quote-line-3.visible {
    opacity: 1;
    transform: translateY(0);
    max-height: 200px;
}

/* Shrink line 1 when later lines appear */
.pf-quote-stack.stage-2 .pf-quote-line-1,
.pf-quote-stack.stage-3 .pf-quote-line-1 {
    font-size: clamp(24px, 3vw, 40px);
    color: var(--pf-text-dim);
}

.pf-quote-stack.stage-3 .pf-quote-line-2 {
    font-size: clamp(24px, 3vw, 40px);
    color: var(--pf-text-dim);
}

/* ── Split panel slide (structured vs unstructured) ── */
.pf-slide-split-panel {
    display: flex;
    align-items: stretch;
    padding: 0;
}

.pf-split-left,
.pf-split-right {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px;
}

.pf-split-divider {
    width: 2px;
    background: var(--pf-border-strong);
    flex-shrink: 0;
}

.pf-split-label {
    font-family: 'Instrument Serif', Georgia, serif;
    font-size: clamp(28px, 5vw, 56px);
    color: var(--pf-text);
    text-align: center;
}

/* ── Three pillars slide ── */
.pf-pillars-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: auto;
    max-width: 1000px;
    width: 100%;
}

/* Concentric rings diagram */
.pf-rings-svg {
    width: 300px;
    height: 300px;
    margin-bottom: 36px;
    flex-shrink: 0;
}

.pf-ring-center {
    fill: var(--pf-text-dim);
}

.pf-ring {
    transition: stroke 0.3s ease, opacity 0.3s ease;
}

.pf-ring-inner {
    stroke: var(--pf-text-faint);
}

.pf-ring-pillar {
    stroke: var(--pf-text-dim);
    cursor: pointer;
}

.pf-ring-pillar.active {
    stroke: var(--pf-accent);
}

.pf-ring-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    fill: var(--pf-text-mid);
    transition: fill 0.3s ease;
    pointer-events: none;
}

.pf-ring-label-dim {
    fill: var(--pf-text-dim);
}

.pf-ring-label-inner {
    fill: var(--pf-text-mid);
}

.pf-ring-label.active {
    fill: var(--pf-accent);
}

/* Pillar columns */
.pf-pillars-wrap {
    display: flex;
    align-items: flex-start;
    gap: 0;
    width: 100%;
}

.pf-pillar {
    flex: 1;
    padding: 32px 40px;
    text-align: left;
    cursor: default;
}

.pf-pillar-divider {
    width: 1px;
    background: var(--pf-border-strong);
    align-self: stretch;
    flex-shrink: 0;
}

.pf-pillar-category {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--pf-accent);
    margin-bottom: 16px;
}

.pf-pillar-title {
    font-family: 'Instrument Serif', Georgia, serif;
    font-size: clamp(28px, 4vw, 48px);
    font-weight: 400;
    color: var(--pf-text);
    margin: 0 0 8px;
    line-height: 1.1;
    transition: color 0.3s ease;
}

.pf-pillar-subtitle {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    font-weight: 300;
    color: var(--pf-text-mid);
    margin-bottom: 4px;
}

.pf-pillar-type {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    font-weight: 300;
    color: var(--pf-text-dim);
    font-style: italic;
}

.pf-pillar.pf-pillar-active .pf-pillar-title {
    color: var(--pf-accent);
}

@media (max-width: 768px) {
    .pf-slide-split-panel { flex-direction: column; }
    .pf-split-divider { width: 100%; height: 2px; }
    .pf-pillars-wrap { flex-direction: column; }
    .pf-pillar-divider { width: 100%; height: 1px; }
    .pf-rings-svg { width: 200px; height: 200px; }
}

/* ── Footnotes slide ── */

.pf-slide-footnotes .pf-panel {
    overflow-y: auto;
}

.pf-fn-text {
    font-family: 'Instrument Serif', Georgia, serif;
    font-size: clamp(22px, 3.5vw, 40px);
    line-height: 1.7;
    color: var(--pf-text);
    max-width: 560px;
    position: relative;
    z-index: 2;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.pf-fn-ref {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.45em;
    color: var(--pf-accent);
    cursor: pointer;
    vertical-align: super;
    line-height: 0;
    padding: 0 2px;
    transition: color 0.2s;
}

.pf-fn-ref:hover {
    color: var(--pf-text);
}

.pf-fn-ref.active {
    color: var(--pf-text);
}

.pf-fn-note {
    display: none;
    margin-top: 24px;
    padding: 24px 0;
    border-top: 1px solid var(--pf-border-strong);
    animation: fnFadeIn 0.35s ease both;
    flex: 1;
    gap: 32px;
    align-items: flex-start;
}

.pf-fn-note.open {
    display: flex;
}

.pf-fn-body {
    font-family: 'JetBrains Mono', monospace;
    font-size: clamp(12px, 1.1vw, 14px);
    font-weight: 300;
    line-height: 1.8;
    color: var(--pf-text-mid);
    max-width: 480px;
    position: relative;
    z-index: 2;
}

.pf-fn-body p {
    margin: 0;
}

.pf-fn-body p + p {
    margin-top: 1.4em;
}

.pf-fn-body a {
    color: var(--pf-text-mid);
    text-decoration: underline;
    text-decoration-color: var(--pf-border-strong);
    text-underline-offset: 3px;
    transition: text-decoration-color 0.2s, color 0.2s;
}

.pf-fn-body a:hover {
    color: var(--pf-text);
    text-decoration-color: var(--pf-text-dim);
}

/* Footnote image gallery — reflowing tiles, right side */
.pf-fn-visual {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-content: flex-start;
    justify-content: flex-end;
    animation: fnVisualIn 0.8s ease both;
}

.pf-fn-visual:empty {
    display: none;
}

.pf-fn-img {
    flex: 0 0 200px;
    border-radius: 13px;
    overflow: hidden;
    border: 1px solid #353332;
    background: var(--pf-bg);
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: border-color 0.25s, transform 0.25s, box-shadow 0.25s;
}

.pf-fn-img:hover {
    border-color: var(--pf-border-strong);
    transform: scale(1.05);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3), 0 0 30px rgba(196, 163, 90, 0.08);
}

.pf-light .pf-fn-img:hover {
    border-color: rgba(56, 73, 148, 0.3);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.pf-fn-img img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
}

/* Embedded iframe tile */
.pf-fn-img-embed {
    position: relative;
}

.pf-fn-img-embed iframe {
    width: 100%;
    height: 100%;
    border: none;
    pointer-events: none;
    background: #0a0a0f;
}

.pf-fn-img-label {
    padding: 8px 10px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    font-weight: 400;
    letter-spacing: 0.12em;
    text-align: center;
    color: #0a0a0f;
    background: rgba(203, 194, 173, 0.75);
    border-top: 1px solid #353332;
}

.pf-light .pf-fn-img-label {
    background: rgba(56, 73, 148, 0.12);
    color: rgba(30, 25, 15, 0.8);
    border-color: rgba(30, 25, 15, 0.12);
}

/* Gallery lightbox — bespoke */
.pf-gallery-wrap {
    display: flex;
    max-width: 95vw;
    max-height: 90vh;
    width: 95%;
    cursor: default;
    gap: 0;
    border-radius: 13px;
    overflow: hidden;
    border: 1px solid #353332;
    animation: lbContentIn 0.4s ease both;
}

.pf-gallery-img {
    flex: 1;
    min-width: 0;
    object-fit: cover;
    display: block;
}

.pf-gallery-side {
    flex: 0 0 300px;
    background: rgba(15, 15, 20, 0.95);
    display: flex;
    flex-direction: column;
    padding: 0;
    border-left: 1px solid #353332;
}

.pf-gallery-titlebar {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 12px 20px;
    border-bottom: 1px solid #252525;
}

.pf-gallery-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.pf-gallery-dot-r { background: #ff5f57; }
.pf-gallery-dot-y { background: #febc2e; }
.pf-gallery-dot-g { background: #28c840; }

.pf-gallery-path {
    margin-left: 8px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: #555;
}

.pf-gallery-body {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.pf-gallery-counter {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    letter-spacing: 0.15em;
    color: var(--pf-accent);
    margin-bottom: 16px;
}

.pf-gallery-caption {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    font-weight: 300;
    line-height: 1.9;
    color: var(--pf-text-mid);
    flex: 1;
    padding-top: 12px;
    border-top: 1px solid #252525;
}

.pf-gallery-footer {
    padding: 14px 20px;
    border-top: 1px solid #252525;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.pf-gallery-nav {
    display: flex;
    gap: 6px;
}

.pf-gallery-prev,
.pf-gallery-next {
    background: none;
    border: 1px solid #353332;
    border-radius: 4px;
    color: var(--pf-text-dim);
    font-size: 16px;
    cursor: pointer;
    padding: 4px 12px;
    transition: color 0.2s, border-color 0.2s;
    font-family: serif;
}

.pf-gallery-prev:hover,
.pf-gallery-next:hover {
    color: var(--pf-text);
    border-color: var(--pf-accent);
}

.pf-gallery-hints {
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    letter-spacing: 0.08em;
    color: #333;
}

.pf-gallery-hints kbd {
    color: #444;
    font-family: inherit;
}

@media (max-width: 768px) {
    .pf-gallery-wrap {
        flex-direction: column;
        max-height: 90vh;
    }
    .pf-gallery-img {
        max-height: 50vh;
    }
    .pf-gallery-side {
        flex: 0 0 auto;
        border-left: none;
        border-top: 1px solid #353332;
    }
}

@keyframes fnFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fnVisualIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@media (max-width: 768px) {
    .pf-fn-note.open {
        flex-direction: column;
    }
    .pf-fn-visual {
        justify-content: flex-start;
    }
    .pf-fn-img {
        flex: 0 0 calc(50% - 6px);
    }
}

/* City name hover — subtle underline */
.pf-city-hover {
    text-decoration: underline;
    text-decoration-color: var(--pf-border-strong);
    text-underline-offset: 3px;
    cursor: default;
    transition: color 0.2s;
}

.pf-city-hover:hover {
    color: var(--pf-text);
}

/* Map visual — explicit height for iframe */
.pf-fn-visual-map {
    position: relative;
    flex: 1;
    height: 45vh;
    min-height: 300px;
}

/* Hover-reveal image — hidden until link is hovered */
.pf-fn-visual:has(.pf-reveal-img) {
    position: relative;
}

.pf-reveal-img {
    position: absolute;
    top: 0;
    right: 0;
    width: auto;
    max-width: 100%;
    max-height: 50vh;
    border-radius: 4px;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.4s ease, transform 0.4s ease;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    pointer-events: none;
}

.pf-reveal-img.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ASCII art default visual */
.pf-fn-ascii {
    font-family: 'JetBrains Mono', monospace;
    font-size: 9px;
    line-height: 1.2;
    color: var(--pf-text-dim);
    margin: 0;
    white-space: pre;
    position: absolute;
    top: 0;
    right: 0;
    opacity: 0.6;
    transition: opacity 0.4s ease;
}

.pf-fn-visual:has(.pf-reveal-img.visible) .pf-fn-ascii {
    opacity: 0;
}

/* Gallery wall — overlapping card stack */
.pf-gallery-wall {
    display: flex;
    align-items: center;
    flex: 1;
    flex-wrap: wrap;
    overflow: hidden;
    padding: 10px 30px 10px 0;
}

.pf-gallery-wall img {
    flex-shrink: 0;
    height: clamp(90px, 16vh, 190px);
    width: auto;
    border-radius: 3px;
    margin-right: -30px;
    margin-bottom: -8px;
    box-shadow: -2px 2px 10px rgba(0,0,0,0.4);
    transition: transform 0.4s ease, opacity 0.3s, box-shadow 0.4s ease;
    position: relative;
    opacity: 0.85;
    cursor: default;
}

.pf-gallery-wall img:hover {
    transform: translateY(-8px) scale(1.1);
    z-index: 10;
    opacity: 1;
    box-shadow: -4px 10px 30px rgba(0,0,0,0.5);
}

.pf-gallery-wall img:last-child { margin-right: 0; }


/* ── Tiles grid ── */

.pf-tiles {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: 1fr 1fr;
    gap: 20px;
    flex: 1;
    width: 100%;
    margin-top: 24px;
    padding: 20px 100px;
}

.pf-tile {
    background: var(--pf-bg);
    border: 1px solid #353332;
    border-radius: 13px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: border-color 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
}

.pf-tile:hover {
    border-color: rgba(196, 163, 90, 0.4);
    transform: scale(1.05);
    box-shadow:
        0 12px 40px rgba(0, 0, 0, 0.4),
        0 0 30px rgba(196, 163, 90, 0.08),
        inset 0 0 20px rgba(196, 163, 90, 0.03);
}

.pf-light .pf-tile:hover {
    border-color: rgba(56, 73, 148, 0.3);
    box-shadow:
        0 12px 40px rgba(0, 0, 0, 0.1),
        0 0 30px rgba(56, 73, 148, 0.08);
}

.pf-tile-content {
    flex: 1;
}

.pf-tile-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    font-weight: 400;
    letter-spacing: 0.12em;
    text-align: center;
    padding: 10px;
    color: #0a0a0f;
    background: rgba(203, 194, 173, 0.75);
    border-top: 1px solid #353332;
}

.pf-light .pf-tile {
    background: var(--pf-bg);
    border-color: rgba(30, 25, 15, 0.12);
}

.pf-light .pf-tile:hover {
    border-color: rgba(30, 25, 15, 0.25);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.pf-light .pf-tile-label {
    background: rgba(56, 73, 148, 0.12);
    color: rgba(30, 25, 15, 0.8);
    border-color: rgba(30, 25, 15, 0.12);
}


@media (max-width: 768px) {
    .pf-tiles {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(3, 1fr);
        gap: 12px;
        padding: 12px 0;
    }
}

@media (max-width: 480px) {
    .pf-tiles {
        grid-template-columns: 1fr;
        grid-template-rows: auto;
    }
    .pf-tile-content {
        min-height: 100px;
    }
}

/* ── Lightbox overlay (appended to #portfolio root) ── */

.pf-lightbox-overlay {
    position: fixed;
    inset: 0;
    z-index: 850;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    cursor: pointer;
    animation: lbIn 0.4s cubic-bezier(0.34, 1.4, 0.64, 1) both;
}

.pf-light .pf-lightbox-overlay {
    background: rgba(0, 0, 0, 0.4);
}

.pf-lightbox-content {
    max-width: 95vw;
    max-height: 90vh;
}

iframe.pf-lightbox-content {
    width: 95vw;
    height: 90vh;
    border-radius: 8px;
    border: 1px solid var(--pf-border-strong);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    cursor: default;
    background: #0e0e0e;
    animation: lbContentIn 0.5s ease 0.1s both;
}

.pf-lightbox-tile {
    background: var(--pf-bg);
    overflow: auto;
}

.pf-lightbox-overlay.pf-lb-out {
    animation: lbOut 0.3s cubic-bezier(0.36, 0, 0.66, -0.4) both;
}

.pf-lightbox-overlay.pf-lb-out .pf-lightbox-content {
    animation: lbContentOut 0.25s ease both;
}

@keyframes lbIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes lbOut {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0; transform: scale(0.95); }
}

@keyframes lbContentIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes lbContentOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* Title slides */
.pf-slide-title {
    text-align: center;
}

/* ── Smoke title slide ── */

.pf-slide-smoke {
    padding: 0;
    overflow: hidden;
}

.smoke-container {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

#smoke-art {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.smoke-row {
    white-space: pre;
    overflow: hidden;
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
}

/* Character weight/style classes */
.smoke-row .w3 { font-weight: 300; }
.smoke-row .w5 { font-weight: 500; }
.smoke-row .w8 { font-weight: 800; }
.smoke-row .it { font-style: italic; }

/* Smoke alpha ramp — dark mode: warm gold */
.smoke-row .a1  { color: rgba(196,163,90,0.08); }
.smoke-row .a2  { color: rgba(196,163,90,0.16); }
.smoke-row .a3  { color: rgba(196,163,90,0.24); }
.smoke-row .a4  { color: rgba(196,163,90,0.32); }
.smoke-row .a5  { color: rgba(196,163,90,0.42); }
.smoke-row .a6  { color: rgba(196,163,90,0.54); }
.smoke-row .a7  { color: rgba(196,163,90,0.66); }
.smoke-row .a8  { color: rgba(196,163,90,0.78); }
.smoke-row .a9  { color: rgba(196,163,90,0.90); }
.smoke-row .a10 { color: rgba(196,163,90,1.0); }

/* Smoke alpha ramp — light mode: deep blue */
.pf-light .smoke-row .a1  { color: rgba(56,73,148,0.08); }
.pf-light .smoke-row .a2  { color: rgba(56,73,148,0.16); }
.pf-light .smoke-row .a3  { color: rgba(56,73,148,0.24); }
.pf-light .smoke-row .a4  { color: rgba(56,73,148,0.32); }
.pf-light .smoke-row .a5  { color: rgba(56,73,148,0.42); }
.pf-light .smoke-row .a6  { color: rgba(56,73,148,0.54); }
.pf-light .smoke-row .a7  { color: rgba(56,73,148,0.66); }
.pf-light .smoke-row .a8  { color: rgba(56,73,148,0.78); }
.pf-light .smoke-row .a9  { color: rgba(56,73,148,0.90); }
.pf-light .smoke-row .a10 { color: rgba(56,73,148,1.0); }

/* Sticky footer */
.pf-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 810;
    padding: 20px 40px;
    pointer-events: none;
    border-top: 1px solid var(--pf-border-strong);
    background: var(--pf-footer-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.smoke-name {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 400;
    font-size: 12px;
    letter-spacing: 0.12em;
    margin: 0;
    color: var(--pf-name);
    pointer-events: auto;
    cursor: default;
    transition: color 0.4s ease;
}

.smoke-name-pf {
    color: var(--pf-accent);
    transition: color 0.4s ease;
}

/* Settings menu */
.pf-settings {
    position: absolute;
    right: 40px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: auto;
}

.pf-settings-toggle {
    background: none;
    border: none;
    color: var(--pf-text-dim);
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    transition: color 0.2s;
}

.pf-settings-toggle:hover {
    color: var(--pf-text);
}

.pf-settings-toggle:focus {
    outline: none;
}

.pf-settings-menu {
    display: none;
    position: absolute;
    bottom: -8px;
    right: 0;
    background: var(--pf-footer-bg);
    border: 1px solid var(--pf-border-strong);
    border-radius: 8px;
    padding: 6px 0;
    min-width: 220px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.pf-settings.open .pf-settings-menu {
    display: block;
}

.pf-settings-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    margin: 2px 6px;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.15s;
}

.pf-settings-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.pf-light .pf-settings-item:hover {
    background: rgba(0, 0, 0, 0.04);
}

.pf-light .pf-toggle {
    background: rgba(30, 25, 15, 0.25);
}

.pf-light .pf-toggle::after {
    background: #f5f4f0;
}

.pf-settings-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    letter-spacing: 0.12em;
    color: var(--pf-text-dim);
}

/* Toggle switch */
.pf-toggle {
    width: 32px;
    height: 18px;
    border-radius: 9px;
    background: #353332;
    position: relative;
    cursor: pointer;
    transition: background 0.2s;
    flex-shrink: 0;
}

.pf-toggle::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--pf-text-dim);
    transition: transform 0.2s, background 0.2s;
}

.pf-toggle.on {
    background: var(--pf-accent);
}

.pf-toggle.on::after {
    transform: translateX(14px);
    background: #0a0a0f;
}

/* ── Reduced motion ── */

#portfolio.pf-reduced .pf-slide {
    transition: none;
}

#portfolio.pf-reduced .pf-slide.active {
    transition: none;
}

#portfolio.pf-reduced .pf-slide.prev,
#portfolio.pf-reduced .pf-slide.next {
    transition: none;
}

#portfolio.pf-reduced .pf-slide::after {
    animation: none;
}

#portfolio.pf-reduced .pf-char {
    transition: none;
}

#portfolio.pf-reduced .pf-char:hover {
    text-shadow: none;
}

#portfolio.pf-reduced .pf-tile,
#portfolio.pf-reduced .pf-fn-img,
#portfolio.pf-reduced .pf-slide-visual {
    transition: none;
}

#portfolio.pf-reduced .pf-tile:hover,
#portfolio.pf-reduced .pf-fn-img:hover,
#portfolio.pf-reduced .pf-slide-visual:hover {
    transform: none;
}

#portfolio.pf-reduced .pf-lightbox-overlay {
    animation: none;
}

#portfolio.pf-reduced .pf-lightbox-content,
#portfolio.pf-reduced .pf-gallery-wrap {
    animation: none;
}

/* Also respect OS-level prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) {
    .pf-slide, .pf-slide.active, .pf-slide.prev, .pf-slide.next { transition: none; }
    .pf-slide::after { animation: none; }
    .pf-char { transition: none; }
    .pf-char:hover { text-shadow: none; }
    .pf-tile, .pf-fn-img, .pf-slide-visual { transition: none; }
    .pf-tile:hover, .pf-fn-img:hover, .pf-slide-visual:hover { transform: none; }
    .pf-lightbox-overlay, .pf-lightbox-content, .pf-gallery-wrap { animation: none; }
}

/* Footer nav — clickable name with dropdown */
.pf-footer-nav {
    position: relative;
    pointer-events: auto;
    cursor: pointer;
}

.pf-footer-nav:hover .smoke-name {
    color: var(--pf-text);
}

.pf-footer-nav:hover .smoke-name-pf {
    color: var(--pf-accent);
    filter: brightness(1.3);
}

/* Slide menu dropdown — anchored to section label, extends upward */
.pf-slide-menu {
    display: none;
    position: absolute;
    bottom: -10px;
    background: var(--pf-footer-bg);
    border: 1px solid var(--pf-border-strong);
    border-radius: 8px;
    padding: 0;
    min-width: 200px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    flex-direction: column;
}

.pf-footer-nav.open .pf-slide-menu {
    display: flex;
}

.pf-slide-menu-separator {
    height: 1px;
    background: var(--pf-border-strong);
    margin: 0;
}

.pf-slide-menu-current {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    letter-spacing: 0.12em;
    color: var(--pf-accent);
    padding: 8px 14px;
    margin: 2px 6px;
    cursor: default;
}

.pf-slide-menu-item {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    letter-spacing: 0.12em;
    color: var(--pf-text-dim);
    padding: 8px 14px;
    margin: 2px 6px;
    border-radius: 5px;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}

.pf-slide-menu-item:hover {
    color: var(--pf-text);
    background: rgba(255, 255, 255, 0.05);
}

.pf-light .pf-slide-menu-item:hover {
    background: rgba(0, 0, 0, 0.04);
}

.pf-slide-menu-item.active {
    color: var(--pf-accent);
}

@media (max-width: 1080px) {
    .pf-slide-head {
        flex-direction: column;
        gap: 20px;
    }
    .pf-slide-head .pf-heading {
        max-width: 100%;
    }
    .pf-slide-head .pf-body {
        max-width: 480px;
        text-align: left;
    }
}

@media (max-width: 768px) {
    .pf-footer {
        padding: 14px 24px;
    }
    .smoke-name {
        font-size: 10px;
    }
    .pf-panel {
        padding: 24px;
        padding-bottom: 64px;
    }
}

/* Screen reader only */
.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;
}

/* ── Typography ── */

.pf-heading {
    font-family: 'Instrument Serif', Georgia, serif;
    color: var(--pf-text);
    font-size: clamp(28px, 4vw, 50px);
    line-height: 1.15;
    margin: 0;
    font-weight: 400;
    transition: color 0.4s ease;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.pf-subheading {
    font-family: 'JetBrains Mono', monospace;
    color: rgba(225, 215, 190, 0.4);
    font-size: clamp(11px, 1.2vw, 13px);
    line-height: 1.6;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
    font-weight: 400;
}

.pf-body {
    font-family: 'JetBrains Mono', monospace;
    color: var(--pf-text-mid);
    font-size: clamp(13px, 1.2vw, 16px);
    line-height: 1.65;
    font-weight: 300;
    transition: color 0.4s ease;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}


.pf-body p {
    margin-bottom: 1em;
}

.pf-body a {
    color: var(--pf-link);
    text-decoration: underline;
    text-decoration-color: var(--pf-link-underline);
    text-underline-offset: 3px;
    transition: text-decoration-color 0.2s, color 0.2s;
}

.pf-body a:hover {
    color: var(--pf-link-hover);
    text-decoration-color: var(--pf-link-underline-hover);
}

/* Accent label (small tag above headings) */
.pf-label {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: rgba(196, 163, 90, 0.5);
    letter-spacing: 0.18em;
    text-transform: uppercase;
    margin-bottom: 12px;
    display: block;
}

/* Decorative rule */
.pf-rule {
    border: none;
    border-top: 1px solid var(--pf-border);
    margin: 24px 0;
}

/* ── Demo frame (full-panel) ── */

.pf-demo-frame {
    width: 100%;
    height: 100%;
    padding: 20px;
    padding-bottom: 80px; /* footer space */
}

.pf-demo-frame iframe {
    width: 100%;
    height: 100%;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    background: #111;
}

/* ── Media ── */

.pf-media {
    width: 100%;
    border-radius: 2px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.03);
}

.pf-media img,
.pf-media video {
    width: 100%;
    height: auto;
    display: block;
}

.pf-media-caption {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: rgba(225, 215, 190, 0.3);
    letter-spacing: 0.05em;
    margin-top: 8px;
    text-align: center;
}

/* Grid for multiple images */
.pf-media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
}

/* Arrow buttons — vertical scroll indicators */
.pf-arrow {
    position: fixed;
    z-index: 810;
    background: none;
    border: none;
    color: rgba(225, 215, 190, 0.15);
    font-size: 18px;
    cursor: pointer;
    padding: 2px 8px;
    line-height: 1;
    transition: color 0.25s;
    left: 50%;
    transform: translateX(-50%);
}

.pf-arrow:hover {
    color: rgba(225, 215, 190, 0.5);
}

.pf-arrow-hidden {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.pf-prev { bottom: 84px; display: none; }
.pf-next { bottom: 64px; display: none; }

/* Top-right menu area */
.pf-top-right {
    position: fixed;
    top: 24px;
    right: 28px;
    z-index: 810;
}

.pf-close-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.25);
    font-size: 22px;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
    transition: color 0.2s;
}

.pf-close-btn:hover {
    color: rgba(255, 255, 255, 0.6);
}

/* ── Responsive ── */

@media (max-width: 768px) {
    .pf-slide {
        padding: 32px 24px;
    }

    .pf-slide-split .pf-content {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .pf-arrow {
        display: none;
    }
}

@media (max-width: 480px) {
    .pf-slide {
        padding: 24px 16px;
    }

    .pf-media-grid {
        grid-template-columns: 1fr;
    }
}
