/* Site-wide micro-interactions (see polish.js) */

:root {
    --ease-out: cubic-bezier(0.2, 0.7, 0.1, 1);
    --ease-in-out: cubic-bezier(0.7, 0, 0.2, 1);
}

/* Scrollbars take the current page's accent color */
html {
    scrollbar-color: var(--page-accent, rgba(255, 255, 255, 0.28)) transparent;
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--page-accent, rgba(255, 255, 255, 0.28));
    border: 2px solid transparent;
    border-radius: 10px;
    background-clip: padding-box;
}

::selection {
    background: var(--accent);
    color: #000;
}

/* ---------- Custom cursor ---------- */
html.dt-has-cursor,
html.dt-has-cursor * {
    cursor: none !important;
}
html.dt-has-cursor input:not([type="radio"]):not([type="checkbox"]),
html.dt-has-cursor textarea {
    cursor: text !important;
}

.dt-cursor {
    --s: 0.2;
    position: fixed;
    left: 0;
    top: 0;
    width: 0;
    height: 0;
    z-index: 10050;
    pointer-events: none;
    mix-blend-mode: difference;
}
.dt-cursor::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #fff;
    opacity: 0;
    transform: translate(-50%, -50%) scale(var(--s));
    transition: transform 0.35s var(--ease-out), opacity 0.2s ease;
}
.dt-cursor.is-visible::before { opacity: 1; }
.dt-cursor.is-hover { --s: 1; }
.dt-cursor.has-label { --s: 1.9; mix-blend-mode: normal; }
.dt-cursor.is-pressed::before { transform: translate(-50%, -50%) scale(calc(var(--s) * 0.82)); }
.dt-cursor.is-text::before { opacity: 0; }

.dt-cursor-label {
    position: absolute;
    left: 0;
    top: 0;
    transform: translate(-50%, -50%) scale(0.6);
    color: #000;
    font-family: "Inter", sans-serif;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.35s var(--ease-out);
}
.dt-cursor.has-label .dt-cursor-label {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* ---------- Headline reveals ---------- */
.dt-word {
    display: inline-block;
    overflow: hidden;
    vertical-align: top;
    /* Room for descenders without clipping */
    padding-bottom: 0.12em;
    margin-bottom: -0.12em;
}
.dt-word-inner {
    display: inline-block;
    transform: translateY(110%);
    transition: transform 0.9s var(--ease-out);
}
.dt-reveal.is-in .dt-word-inner {
    transform: none;
}

[data-fade] {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.8s ease, transform 0.9s var(--ease-out);
}
[data-fade].is-in {
    opacity: 1;
    transform: none;
}

/* ---------- Card tilt + shine (DT.attachTilt) ---------- */
.dt-tilt.dt-tilt {
    --rx: 0deg;
    --ry: 0deg;
    --ts: 1;
    --gx: 50%;
    --gy: 50%;
    transform: perspective(1000px) rotateX(var(--rx)) rotateY(var(--ry)) scale(var(--ts));
    /* Transform is driven every frame from JS, so it must not be transitioned */
    transition: opacity 0.5s ease, filter 0.5s ease, background-color 0.5s ease, border-color 0.5s ease;
    overflow: hidden;
}
.dt-tilt.dt-tilt.is-tilting {
    filter: drop-shadow(0 14px 28px rgba(0, 0, 0, 0.35));
}

.dt-glare,
.dt-shine {
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
}

/* Soft light that follows the mouse while tilting */
.dt-glare {
    opacity: 0;
    transition: opacity 0.45s ease;
    background:
        radial-gradient(circle at var(--gx) var(--gy), rgba(255, 255, 255, 0.22), transparent 55%),
        linear-gradient(115deg,
            transparent calc(var(--gx) - 30%),
            rgba(255, 255, 255, 0.07) var(--gx),
            transparent calc(var(--gx) + 30%));
    mix-blend-mode: screen;
}
.dt-tilt.is-tilting .dt-glare { opacity: 1; }

/* A bright streak that sweeps across on hover in (left to right) and out (back) */
.dt-shine {
    opacity: 0;
    background: linear-gradient(110deg,
        transparent 38%,
        rgba(255, 255, 255, 0.12) 44%,
        rgba(255, 255, 255, 0.55) 49%,
        rgba(255, 255, 255, 0.7) 50%,
        rgba(255, 255, 255, 0.12) 56%,
        transparent 62%);
    background-size: 250% 100%;
    background-repeat: no-repeat;
    background-position: 110% 0;
    mix-blend-mode: screen;
}
.dt-shine.is-in { animation: dt-shine-in 0.85s cubic-bezier(0.45, 0, 0.25, 1) both; }
.dt-shine.is-out { animation: dt-shine-out 0.65s cubic-bezier(0.45, 0, 0.25, 1) both; }

@keyframes dt-shine-in {
    from { opacity: 1; background-position: 110% 0; }
    to { opacity: 1; background-position: -10% 0; }
}
@keyframes dt-shine-out {
    from { opacity: 0.55; background-position: -10% 0; }
    to { opacity: 0.55; background-position: 110% 0; }
}

/* ---------- Scroll progress ---------- */
.dt-scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--page-accent, var(--accent));
    transform: scaleX(0);
    transform-origin: left center;
    z-index: 1001;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.4s ease;
}
.dt-scroll-progress.is-visible { opacity: 1; }

/* ---------- Film grain ---------- */
.dt-grain {
    position: fixed;
    inset: 0;
    z-index: 9990;
    pointer-events: none;
}
#dt-grain {
    inset: 0;
    width: 100%;
    height: 100%;
}

/* ---------- Footer: now-building line + sound toggle ---------- */
.dt-site-footer {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 14px 12px 18px;
    pointer-events: none;
}

button.dt-sound-toggle {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 8px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: #fff;
    font-family: "Inter", sans-serif;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    opacity: 0.4;
    cursor: pointer;
    pointer-events: auto;
    transition: opacity 0.2s ease;
}
button.dt-sound-toggle:hover,
button.dt-sound-toggle:focus-visible {
    opacity: 0.9;
    transform: none;
}
button.dt-sound-toggle i { width: 14px; }

.dt-footer-line {
    display: flex;
    gap: 14px;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #fff;
    opacity: 0.4;
    font-variant-numeric: tabular-nums;
}
.dt-footer-line > span + span::before {
    content: '·';
    margin-right: 14px;
}
.dt-footer-strong { font-weight: 700; }

/* Footer pieces a page placed in its own slots */
.dt-slot-text {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #fff;
    opacity: 0.6;
    font-variant-numeric: tabular-nums;
}
[data-slot] button.dt-sound-toggle {
    margin: 0;
    opacity: 0.6;
}

@media (max-width: 768px) {
    .dt-footer-line { display: none; }
    button.dt-sound-toggle span { display: none; }
}

/* Keyboard focus that matches the site */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        transition-delay: 0ms !important;
        scroll-behavior: auto !important;
    }
    [data-fade] { transform: none; }
}
