/* =====================================================================
   AI GENERALIST VIEW + VIEW SWITCH
   Works on top of style.css. The <html> element gets the class
   "mode-ai" when the AI Generalist view is active.
===================================================================== */

/* ---------- which elements belong to which view ---------- */
html:not(.mode-ai) [data-mode="ai"] { display: none !important; }
html.mode-ai [data-mode="ds"]       { display: none !important; }

/* ---------- AI accent colour (re-tints the whole site) ---------- */
html.mode-ai {
    --green: #ff9f6b;                       /* warm "film" amber-coral */
    --green-tint: rgba(255, 159, 107, 0.1);
    --accent-rgb: 255, 159, 107;
}
html { --accent-rgb: 100, 255, 218; }

html.mode-ai .cta-button::before { background-color: rgba(var(--accent-rgb), 0.1); }
html.mode-ai .logo a:hover svg   { filter: drop-shadow(0 0 10px rgba(var(--accent-rgb), 0.4)); }
html.mode-ai .logo a:hover polygon { fill: rgba(var(--accent-rgb), 0.1); }
html.mode-ai .tab-panel__company a:hover { color: var(--green); }

/* transparent so the scroll-scrub background shows through, like the DS sections */
#ai-work, #ai-toolkit { position: relative; background: transparent; }

/* =====================================================================
   VIEW SWITCH (in the navbar)
===================================================================== */
.mode-switch {
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: center;
    padding: 4px;
    border: 1px solid var(--lightest-navy);
    border-radius: 999px;
    background: rgba(17, 34, 64, 0.7);
    font-family: var(--font-mono);
    isolation: isolate;
    margin: 0 auto 0 40px;            /* sits next to the logo, same spot in both views */
    transition: border-color 0.3s var(--easing), box-shadow 0.3s var(--easing);
}
.mode-switch:hover {
    border-color: rgba(var(--accent-rgb), 0.5);
    box-shadow: 0 0 0 4px rgba(var(--accent-rgb), 0.06), 0 8px 24px -12px rgba(var(--accent-rgb), 0.5);
}

.mode-switch__btn {
    position: relative;
    z-index: 1;
    padding: 8px 16px;
    border: 0;
    background: none;
    color: var(--slate);
    font: inherit;
    font-size: var(--fz-xs);
    letter-spacing: 0.02em;
    white-space: nowrap;
    cursor: pointer;
    border-radius: 999px;
    transition: color 0.3s var(--easing);
}
.mode-switch__btn:hover { color: var(--lightest-slate); }
.mode-switch__btn[aria-pressed="true"] { color: var(--navy); font-weight: 600; cursor: default; }
.mode-switch__btn:focus-visible { outline: 1px dashed var(--green); outline-offset: 2px; }
.mode-switch__short { display: none; }

.mode-switch__thumb {
    position: absolute;
    z-index: 0;
    top: 4px; bottom: 4px; left: 4px;
    width: calc(50% - 4px);
    border-radius: 999px;
    background: var(--green);
    box-shadow: 0 0 18px rgba(var(--accent-rgb), 0.45);
    transition: transform 0.5s cubic-bezier(0.7, 0, 0.2, 1), background-color 0.5s ease, box-shadow 0.5s ease;
}
html.mode-ai .mode-switch__thumb { transform: translateX(100%); }

/* "lean" toward the other option on hover — a small invitation to click.
   Mouse only: on phones a tap leaves :hover stuck, which would leave the thumb off-centre. */
@media (hover: hover) and (pointer: fine) {
    html:not(.mode-ai) .mode-switch:hover .mode-switch__thumb { transform: translateX(7%); }
    html.mode-ai .mode-switch:hover .mode-switch__thumb       { transform: translateX(93%); }
}

.mode-switch__hint {
    position: absolute;
    top: calc(100% + 10px);
    left: 50%;
    padding: 6px 10px;
    border-radius: var(--border-radius);
    background: var(--light-navy);
    color: var(--light-slate);
    font-size: var(--fz-xxs);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, -4px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    box-shadow: 0 10px 30px -15px var(--navy-shadow);
}
.mode-switch:hover .mode-switch__hint { opacity: 1; transform: translate(-50%, 0); }

/* =====================================================================
   VIEW-SWITCH TRANSITION (circle wipe + title card)
===================================================================== */
.mode-wipe {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: grid;
    place-items: center;
    background: radial-gradient(circle at var(--wx, 50%) var(--wy, 0%), rgba(var(--wipe-rgb, 255,159,107), 0.95) 0%, var(--navy) 55%);
    clip-path: circle(0px at var(--wx, 50%) var(--wy, 0%));
    pointer-events: none;
    visibility: hidden;
}
.mode-wipe.is-in {
    visibility: visible;
    pointer-events: auto;
    clip-path: circle(150vmax at var(--wx, 50%) var(--wy, 0%));
    transition: clip-path 0.65s cubic-bezier(0.7, 0, 0.3, 1);
}
.mode-wipe.is-out {
    visibility: visible;
    clip-path: circle(150vmax at var(--wx, 50%) var(--wy, 0%));
    opacity: 0;
    transition: opacity 0.5s ease 0.05s;
}
.mode-wipe__label {
    color: var(--lightest-slate);
    font-family: var(--font-mono);
    font-size: clamp(22px, 5vw, 44px);
    letter-spacing: 0.08em;
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 0.35s ease, transform 0.35s ease;
}
.mode-wipe.is-in .mode-wipe__label { opacity: 1; transform: none; transition-delay: 0.3s; }
.mode-wipe__label::before {
    content: '> ';
    color: rgb(var(--wipe-rgb, 255,159,107));
}

/* =====================================================================
   AI HERO
===================================================================== */
.ai-hero__bg {
    position: absolute;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    background: radial-gradient(ellipse at 75% 30%, rgba(255,159,107,0.18), transparent 60%), var(--navy);
}
.ai-hero__video { filter: hue-rotate(155deg) saturate(0.9); }
.ai-hero__vimeo {
    position: absolute;
    top: 50%; left: 50%;
    width: 100vw; height: 56.25vw;          /* 16:9 */
    min-height: 100vh; min-width: 177.78vh; /* cover */
    transform: translate(-50%, -50%);
    border: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 1s ease;
}
.ai-hero__vimeo.is-loaded { opacity: 1; }

.ai-hero__headline { color: var(--slate); }

/* "Currently at" headline badge */
.now-badge {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    margin: 0 0 34px;
    padding: 10px 16px 10px 14px;
    border: 1px solid rgba(var(--accent-rgb), 0.35);
    border-radius: 999px;
    background: rgba(10, 25, 47, 0.65);
    backdrop-filter: blur(6px);
    color: var(--lightest-slate);
    font-family: var(--font-mono);
    font-size: var(--fz-sm);
    text-decoration: none;
    transition: var(--transition);
}
.now-badge:hover {
    border-color: var(--green);
    transform: translateY(-2px);
    box-shadow: 0 10px 30px -12px rgba(var(--accent-rgb), 0.5);
}
.now-badge__pulse {
    position: relative;
    width: 9px; height: 9px;
    border-radius: 50%;
    background: var(--green);
}
.now-badge__pulse::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: var(--green);
    animation: nowPulse 1.8s ease-out infinite;
}
@keyframes nowPulse {
    from { transform: scale(1); opacity: 0.7; }
    to   { transform: scale(3); opacity: 0; }
}
.now-badge__label {
    color: var(--green);
    text-transform: uppercase;
    font-size: var(--fz-xxs);
    letter-spacing: 0.12em;
}
.now-badge__text strong { color: var(--white); font-weight: 600; }
.now-badge__at { color: var(--green); margin: 0 2px; }
.now-badge__meta { color: var(--slate); font-size: var(--fz-xs); }
.now-badge__meta::before { content: '· '; color: var(--dark-slate); }

/* =====================================================================
   AI WORK GRID
===================================================================== */
.ai-work__intro {
    margin: -10px 0 40px;
    color: var(--slate);
    font-family: var(--font-mono);
    font-size: var(--fz-sm);
}

.ai-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 28px;
}

.ai-card {
    position: relative;
    display: flex;
    flex-direction: column;
    border-radius: 8px;
    background: var(--light-navy);
    box-shadow: 0 10px 30px -15px var(--navy-shadow);
    overflow: hidden;
    cursor: pointer;
    outline: none;
    transition: transform 0.35s var(--easing), box-shadow 0.35s var(--easing);
}
.ai-card::after {                     /* glowing border on hover */
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    border: 1px solid transparent;
    pointer-events: none;
    transition: border-color 0.35s var(--easing);
}
.ai-card:hover,
.ai-card:focus-visible {
    transform: translateY(-8px);
    box-shadow: 0 24px 40px -18px rgba(2, 12, 27, 0.9), 0 0 0 1px rgba(var(--accent-rgb), 0.15);
}
.ai-card:hover::after,
.ai-card:focus-visible::after { border-color: rgba(var(--accent-rgb), 0.55); }

.ai-card--featured { grid-column: span 2; }
.ai-card--featured .ai-card__title { font-size: clamp(22px, 3vw, 28px); }

/* media box */
.ai-card__media {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: linear-gradient(135deg, var(--lightest-navy), var(--navy));
}
.ai-card__thumb,
.ai-card__thumb-blur {
    position: absolute;
    inset: 0;
    width: 100%; height: 100%;
    object-fit: cover;
    transition: transform 0.8s var(--easing), opacity 0.4s ease, filter 0.4s ease;
}
.ai-card__thumb-blur { filter: blur(22px) brightness(0.55); transform: scale(1.2); }
.ai-card__thumb.is-contain { object-fit: contain; }
.ai-card:hover .ai-card__thumb { transform: scale(1.05); }
.ai-card__thumb.is-contain,
.ai-card:hover .ai-card__thumb.is-contain { transform: none; }

/* the Vimeo hover preview */
.ai-card__preview {
    position: absolute;
    top: 50%; left: 50%;
    height: 100%;
    aspect-ratio: var(--ar, 16 / 9);
    max-width: none;
    transform: translate(-50%, -50%);
    border: 0;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease;
}
.ai-card__preview.is-wide { width: 100%; height: auto; }
.ai-card__preview.is-playing { opacity: 1; }

/* shade + play button */
.ai-card__shade {
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(10,25,47,0) 45%, rgba(10,25,47,0.85) 100%);
    transition: opacity 0.4s ease;
}
.ai-card:hover .ai-card__shade { opacity: 0.4; }

.ai-card__play {
    position: absolute;
    left: 18px; bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--white);
    font-family: var(--font-mono);
    font-size: var(--fz-xs);
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.ai-card__play-icon {
    position: relative;
    display: grid;
    place-items: center;
    width: 42px; height: 42px;
    border-radius: 50%;
    border: 1px solid rgba(var(--accent-rgb), 0.8);
    background: rgba(10, 25, 47, 0.55);
    color: var(--green);
    backdrop-filter: blur(4px);
}
.ai-card__play-icon::after {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: 50%;
    border: 1px solid var(--green);
    animation: playRing 2s ease-out infinite;
}
@keyframes playRing {
    from { transform: scale(1); opacity: 0.8; }
    to   { transform: scale(1.6); opacity: 0; }
}
.ai-card__play-icon svg { margin-left: 3px; }
.ai-card:hover .ai-card__play-text { opacity: 0; }
.ai-card__play-text { transition: opacity 0.3s ease; }

.ai-card__badge {
    position: absolute;
    top: 14px; left: 14px;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(10, 25, 47, 0.75);
    border: 1px solid rgba(var(--accent-rgb), 0.4);
    color: var(--green);
    font-family: var(--font-mono);
    font-size: var(--fz-xxs);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    backdrop-filter: blur(4px);
}
.ai-card__badge--draft {
    left: auto; right: 14px;
    color: #ffd166;
    border-color: rgba(255, 209, 102, 0.5);
}

/* body */
.ai-card__body {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 22px 24px 24px;
}
.ai-card__meta {
    margin-bottom: 8px;
    color: var(--green);
    font-family: var(--font-mono);
    font-size: var(--fz-xs);
}
.ai-card__title {
    margin-bottom: 12px;
    color: var(--lightest-slate);
    font-size: var(--fz-xxl);
    font-weight: 600;
    line-height: 1.25;
    transition: color 0.25s ease;
}
.ai-card:hover .ai-card__title { color: var(--green); }
.ai-card__desc {
    color: var(--light-slate);
    font-size: 16px;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.ai-card--featured .ai-card__desc { -webkit-line-clamp: 4; }
.ai-card__tools {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    margin-top: auto;
    padding-top: 18px;
    list-style: none;
    color: var(--slate);
    font-family: var(--font-mono);
    font-size: var(--fz-xxs);
}

/* "What I did" chips */
.ai-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 14px;
    padding: 0;
    list-style: none;
}
.ai-chips li {
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--green-tint);
    color: var(--green);
    font-family: var(--font-mono);
    font-size: var(--fz-xxs);
}
.ai-chips li:first-child::before { content: 'I did: '; color: var(--slate); }

/* card appear animation */
.ai-card.fade-up { transition: opacity 0.6s var(--easing), transform 0.6s var(--easing), box-shadow 0.35s var(--easing); }
.ai-card.fade-up.appear:hover { transform: translateY(-8px); }

/* empty state */
.ai-empty {
    padding: 50px 30px;
    border: 1px dashed var(--lightest-navy);
    border-radius: 8px;
    text-align: center;
    color: var(--slate);
}
.ai-empty__title { color: var(--lightest-slate); font-size: var(--fz-xxl); margin-bottom: 8px; }
.ai-empty a { color: var(--green); }

/* skeleton while JSON loads */
.ai-skeleton {
    aspect-ratio: 16 / 12;
    border-radius: 8px;
    background: linear-gradient(100deg, var(--light-navy) 30%, var(--lightest-navy) 50%, var(--light-navy) 70%);
    background-size: 300% 100%;
    animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* =====================================================================
   VIDEO MODAL
===================================================================== */
.ai-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 30px;
}
.ai-modal[hidden] { display: none; }
.ai-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 12, 27, 0.88);
    backdrop-filter: blur(8px);
    animation: fadeInSimple 0.3s ease;
}
.ai-modal__panel {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    width: min(1280px, 100%);
    max-height: calc(100vh - 60px);
    border-radius: 10px;
    background: var(--light-navy);
    box-shadow: 0 30px 60px -20px rgba(0,0,0,0.8);
    overflow: hidden;
    animation: modalIn 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}
.ai-modal.is-vertical .ai-modal__panel { width: min(900px, 100%); grid-template-columns: auto 340px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(30px) scale(0.96); } to { opacity: 1; transform: none; } }
@keyframes fadeInSimple { from { opacity: 0; } to { opacity: 1; } }

.ai-modal__player {
    position: relative;
    background: #000;
    aspect-ratio: var(--ar, 16 / 9);
    max-height: calc(100vh - 60px);
    align-self: center;
}
.ai-modal.is-vertical .ai-modal__player { height: min(78vh, 780px); }
.ai-modal__player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.ai-modal__info {
    padding: 34px 28px 28px;
    overflow-y: auto;
}
.ai-modal__title {
    margin: 0 0 16px;
    color: var(--lightest-slate);
    font-size: 24px;
    line-height: 1.2;
}
.ai-modal__desc {
    margin-bottom: 18px;
    color: var(--light-slate);
    font-size: 16px;
    line-height: 1.6;
    white-space: pre-line;
}
.ai-modal__tools { justify-content: flex-start !important; margin: 0 0 22px; }
.ai-modal__vimeo {
    color: var(--green);
    font-family: var(--font-mono);
    font-size: var(--fz-xs);
    text-decoration: none;
}
.ai-modal__vimeo:hover { text-decoration: underline; }
.ai-modal__close {
    position: absolute;
    top: 10px; right: 10px;
    z-index: 2;
    display: grid;
    place-items: center;
    width: 38px; height: 38px;
    border: 0;
    border-radius: 50%;
    background: rgba(10, 25, 47, 0.8);
    color: var(--lightest-slate);
    cursor: pointer;
    transition: var(--transition);
}
.ai-modal__close:hover { color: var(--green); transform: rotate(90deg); }

/* =====================================================================
   HIDDEN EDIT DOT (localhost only — added by ai-mode.js)
   Almost invisible until hovered, so visitors won't notice it.
===================================================================== */
.edit-dot {
    position: fixed;
    right: 10px;
    bottom: 10px;
    z-index: 900;
    display: inline-flex;
    align-items: center;
    gap: 0;
    height: 24px;
    min-width: 24px;
    padding: 0 6px;
    border-radius: 999px;
    color: var(--slate);
    font-family: var(--font-mono);
    font-size: 11px;
    text-decoration: none;
    opacity: 0.12;
    transition: opacity 0.3s ease, background-color 0.3s ease, color 0.3s ease, gap 0.3s ease;
}
.edit-dot span {
    max-width: 0;
    overflow: hidden;
    white-space: nowrap;
    transition: max-width 0.3s var(--easing);
}
.edit-dot:hover,
.edit-dot:focus-visible {
    opacity: 1;
    gap: 6px;
    color: var(--green);
    background: rgba(17, 34, 64, 0.9);
    outline: none;
}
.edit-dot:hover span,
.edit-dot:focus-visible span { max-width: 40px; }

/* =====================================================================
   PHONE POLISH (both views)
===================================================================== */
@media (max-width: 768px) {
    /* hero: brighter headline, darker scrim behind the text */
    .hero .subtitle { color: var(--light-slate); line-height: 1.05; margin-top: 10px; }
    .hero .hero-description { color: var(--light-slate); }
    .hero-overlay {
        background: linear-gradient(180deg, rgba(10,25,47,0.55) 0%, rgba(10,25,47,0.86) 40%, rgba(10,25,47,0.86) 75%, rgba(10,25,47,0.6) 100%) !important;
    }
    .hero .cta-button { margin-top: 36px; }

    /* scroll background (robot frames): quieter on small screens so text stays readable */
    .bg-scrub-canvas.is-active { opacity: 0.32; }

    /* featured projects: screenshot as a clear image on top, text underneath (no overlap) */
    .featured-project,
    .featured-project.reverse { padding: 0 0 1.75rem; overflow: hidden; gap: 0; margin-bottom: 40px; }
    .project-image,
    .featured-project.reverse .project-image {
        grid-area: 1 / 1 / 2 / -1 !important;
        opacity: 1 !important;
        height: auto;
    }
    .project-image a { border-radius: var(--border-radius) var(--border-radius) 0 0; aspect-ratio: 16 / 10; }
    .project-image a::before { display: none; }
    .project-image img { filter: none; border-radius: 0; }
    .project-content,
    .featured-project.reverse .project-content {
        grid-area: 2 / 1 / 3 / -1 !important;
        padding: 1.5rem 1.5rem 0;
    }
    .project-description { padding: 14px 0 18px; }
    .project-links a { padding: 10px; }          /* bigger tap targets */

    /* section headings: no overflow on narrow phones */
    .section-heading { font-size: clamp(22px, 6.4vw, 28px); }

    /* project cards and AI cards: comfortable tap area */
    .project-card-links a { padding: 8px; }
}
@media (max-width: 480px) {
    .project-content,
    .featured-project.reverse .project-content { padding: 1.25rem 1.15rem 0; }
}

/* =====================================================================
   RESPONSIVE
===================================================================== */
@media (max-width: 1080px) {
    .ai-modal__panel,
    .ai-modal.is-vertical .ai-modal__panel { grid-template-columns: 1fr; overflow-y: auto; }
    .ai-modal__player { max-height: 60vh; width: 100%; }
    .ai-modal.is-vertical .ai-modal__player { height: 62vh; aspect-ratio: auto; }
    .ai-modal__info { overflow: visible; }
}

@media (max-width: 900px) {
    .ai-card--featured { grid-column: auto; }
}

@media (max-width: 768px) {
    /* centred in the navbar, wide, with thumb-sized tap targets */
    .mode-switch {
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
        width: min(62vw, 270px);
        margin: 0;
        padding: 5px;
    }
    .mode-switch__btn {
        min-height: 40px;
        padding: 0 8px;
        font-size: 12px;
    }
    .mode-switch__thumb { top: 5px; bottom: 5px; left: 5px; width: calc(50% - 5px); }
    .mode-switch__hint { display: none; }
    /* hide it while the slide-out menu is open so it doesn't sit on top of the links */
    nav:has(.nav-links.active) .mode-switch { opacity: 0; pointer-events: none; }
}

@media (max-width: 380px) {
    .mode-switch { width: min(56vw, 210px); }
    .mode-switch__full { display: none; }
    .mode-switch__short { display: inline; }
    .mode-switch__btn { font-size: 13px; }
}

@media (max-width: 768px) {

    .ai-grid { grid-template-columns: 1fr; gap: 22px; }
    .now-badge { border-radius: 14px; font-size: var(--fz-xs); }
    .ai-modal { padding: 12px; }
    .ai-modal__panel { max-height: calc(100vh - 24px); }
}

@media (max-width: 480px) {
    .ai-card__body { padding: 18px; }
    .now-badge__meta { width: 100%; }
    .now-badge__meta::before { content: ''; }
}

@media (prefers-reduced-motion: reduce) {
    .mode-wipe, .mode-wipe.is-in, .mode-wipe.is-out { transition: none; }
    .ai-card__play-icon::after, .now-badge__pulse::after, .ai-skeleton { animation: none; }
}
