@font-face {
    font-family: 'iAWriterDuoV';
    src: url('./fonts/iAWriterDuoV.woff2') format('woff2'),
         url('./fonts/iAWriterDuoV.ttf') format('truetype');
    font-weight: 100 900;
    font-style: normal;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #000000;
}

:root {

    --unlock-mask-radius: 0px;
    --unlock-mask-fade: 3;
    --ui-edge-padding: clamp(14px, 4vw, 28px);
    --scene-perspective: 620px;
    --lock-clock-size: min(100vmin, 800px);
    --clock-lens-blur: 26px;
    --lock-feedback-blur-boost: 0px;
    --clock-sharp-core: 56%;
    --clock-lens-warp: 1.08;
    --lock-feedback-lens-boost: 0;
    --unlock-duration: 1400ms;
    --unlock-zoom-scale: 3.6;
    --unlock-start-scale: 1;
    --unlock-end-scale: var(--unlock-zoom-scale);
    --lock-feedback-scale: 1;
    --px: 0;
    --py: 0;
}

body {
    text-transform: lowercase;
}

.lock-screen {
    position: fixed;
    inset: 0;
    z-index: 1800;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 35% 26%, rgba(255, 255, 255, 0.07) 0%, transparent 42%),
        radial-gradient(circle at 70% 72%, rgba(255, 255, 255, 0.04) 0%, transparent 45%),
        #000000;
    opacity: 1;
    visibility: visible;
    transition: opacity var(--unlock-duration) cubic-bezier(0.2, 0.6, 0.08, 1), visibility 0s linear var(--unlock-duration);
}

.lock-screen.mask-active {
    -webkit-mask-image: radial-gradient(
        circle var(--unlock-mask-radius) at center,
        transparent calc(100% - var(--unlock-mask-fade) * 1%),
        black 100%
    );
    mask-image: radial-gradient(
        circle var(--unlock-mask-radius) at center,
        transparent calc(100% - var(--unlock-mask-fade) * 1%),
        black 100%
    );
}

.lock-clock-shell {
    width: var(--lock-clock-size);
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translate(
        calc(var(--px) * 12px),
        calc(var(--py) * 12px)
    ) scale(var(--lock-feedback-scale));
    will-change: transform, opacity, filter;
}

@keyframes lock-zoom-through {
    0% {
        opacity: 1;
        transform: translate(
            calc(var(--px) * 12px),
            calc(var(--py) * 12px)
        ) scale(var(--unlock-start-scale));
    }
    100% {
        opacity: 0;
        transform: translate(0, 0) scale(var(--unlock-end-scale));
    }
}

body.state-unlocking .lock-screen {
    pointer-events: none;
    /* opacity stays 1 — mask handles the visual transition */
}

body.state-unlocking .lock-clock-shell {
    /* zoom-through removed — mask circle replaces it */
}

body.state-home .lock-screen {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    -webkit-mask-image: none;
    mask-image: none;
    transition: none; /* instant hide — no flash when mask is removed */
}

body.state-home .lock-clock-shell {
    opacity: 0;
    transform: translate(0, 0) scale(var(--unlock-end-scale));
}

.lock-clock {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    isolation: isolate;
    box-shadow:
        inset 0 -8px 24px rgba(255, 255, 255, 0.07),
        inset 0 16px 28px rgba(255, 255, 255, 0.1),
        0 36px 64px rgba(0, 0, 0, 0.65);
}

.clock-shader-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    z-index: 6;
    pointer-events: none;
    opacity: 0;
}

body.shader-clock .clock-shader-canvas {
    opacity: 1;
}

body.shader-clock .clock-fx-layer {
    opacity: 0;
    pointer-events: none;
}

.clock-fx-layer {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    overflow: hidden;
    background:
        radial-gradient(circle at 50% 67%, rgba(255, 255, 255, 0.33) 0%, rgba(255, 255, 255, 0.05) 35%, rgba(0, 0, 0, 0.95) 90%),
        radial-gradient(circle at 48% 33%, rgba(255, 255, 255, 0.08) 0%, transparent 55%),
        #080809;
    will-change: transform;
    z-index: 1;
}

.clock-fx-layer-base {
    z-index: 1;
    overflow: visible;
    filter: blur(calc(var(--clock-lens-blur) + var(--lock-feedback-blur-boost)));
    transform: scale(calc(var(--clock-lens-warp) + var(--lock-feedback-lens-boost)));
    transform-origin: 50% 50%;
}

.clock-fx-layer-edge {
    z-index: 3;
    pointer-events: none;
    filter: none;
    transform: scale(1);
    mix-blend-mode: normal;
    opacity: 1;
    -webkit-mask-mode: alpha;
    mask-mode: alpha;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-image: radial-gradient(
        circle at center,
        rgba(255, 255, 255, 1) var(--clock-sharp-core),
        rgba(255, 255, 255, 0.94) calc(var(--clock-sharp-core) + 8%),
        transparent 100%
    );
    mask-image: radial-gradient(
        circle at center,
        rgba(255, 255, 255, 1) var(--clock-sharp-core),
        rgba(255, 255, 255, 0.94) calc(var(--clock-sharp-core) + 8%),
        transparent 100%
    );
}

.clock-fx-layer-edge-outer {
    display: none;
}

.clock-fx-layer-edge .clock-date-chip,
.clock-fx-layer-edge .clock-center,
.clock-fx-layer-base .clock-date-chip,
.clock-fx-layer-base .clock-center {
    display: none;
}

.clock-face,
.clock-edge-glow,
.clock-vignette,
.clock-numerals,
.clock-markers,
.clock-hands,
.clock-date-chip {
    position: absolute;
    inset: 0;
}

.clock-face {
    border-radius: 50%;
    background:
        radial-gradient(circle at 50% 62%, rgba(255, 255, 255, 0.26) 0%, rgba(255, 255, 255, 0.05) 35%, transparent 70%),
        radial-gradient(circle at 50% 28%, rgba(255, 255, 255, 0.12) 0%, transparent 54%);
    transform: translate(
        calc(var(--px) * -7px),
        calc(var(--py) * -7px)
    );
}

.clock-edge-glow {
    border-radius: 50%;
    box-shadow:
        inset 0 0 0 8px rgba(255, 255, 255, 0.02),
        inset 0 0 36px rgba(255, 255, 255, 0.2);
    filter: blur(1.5px);
    transform: translate(
        calc(var(--px) * -3px),
        calc(var(--py) * -3px)
    );
}

.clock-vignette {
    border-radius: 50%;
    background:
        radial-gradient(circle at center, transparent 59%, rgba(0, 0, 0, 0.55) 89%, rgba(0, 0, 0, 0.88) 100%);
    transform: translate(
        calc(var(--px) * -2px),
        calc(var(--py) * -2px)
    );
}

.clock-numerals {
    transform: translate(
        calc(var(--px) * -15px),
        calc(var(--py) * -15px)
    );
}

.clock-num {
    position: absolute;
    color: #f5f3e8;
    font-family: 'iAWriterDuoV', -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 800;
    line-height: 1;
    text-shadow:
        0 1px 0 rgba(255, 255, 255, 0.2),
        0 10px 16px rgba(0, 0, 0, 0.45);
    user-select: none;
}

.clock-num.n12 {
    top: 13%;
    left: 50%;
    font-size: clamp(132px, 18vw, 182px);
    transform: translate(-50%, -50%) scale(1.15, 1.7);
}

.clock-num.n3 {
    top: 50%;
    right: -4%;
    font-size: clamp(126px, 17vw, 168px);
    transform: translate(0, -50%) scale(1.95, 0.82);
}

.clock-num.n6 {
    left: 50%;
    bottom: -8%;
    font-size: clamp(150px, 21vw, 210px);
    transform: translate(-50%, 0) scale(2.02, 1.03);
}

.clock-num.n9 {
    top: 50%;
    left: -4%;
    font-size: clamp(126px, 17vw, 168px);
    transform: translate(0, -50%) scale(1.95, 0.82);
}

.clock-markers {
    transform: translate(
        calc(var(--px) * -10px),
        calc(var(--py) * -10px)
    );
}

.clock-marker {
    position: absolute;
    width: 2px;
    height: 12%;
    border-radius: 4px;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.2));
    filter: blur(0.4px);
    transform-origin: center 100%;
}

.clock-marker.m1 {
    top: 13%;
    left: 23%;
    transform: rotate(-48deg);
}

.clock-marker.m2 {
    top: 13%;
    right: 23%;
    transform: rotate(48deg);
}

.clock-marker.m3 {
    bottom: 13%;
    left: 23%;
    transform: rotate(48deg);
}

.clock-marker.m4 {
    bottom: 13%;
    right: 23%;
    transform: rotate(-48deg);
}

.clock-hands {
    transform: translate(
        calc(var(--px) * -10px),
        calc(var(--py) * -10px)
    );
}

.clock-hand {
    position: absolute;
    left: 50%;
    bottom: 50%;
    transform-origin: 50% 100%;
    border-radius: 999px;
    will-change: transform;
}

.clock-fx-layer-edge .clock-hand {
    filter: none;
}

.clock-hand.hour {
    width: 20px;
    height: 25%;
    background: #f7f4ec;
    transform: translateX(-50%) rotate(0deg);
    box-shadow:
        inset 0 0 0 1px rgba(0, 0, 0, 0.12),
        0 3px 8px rgba(0, 0, 0, 0.32);
}

.clock-hand.hour::after {
    content: '';
    position: absolute;
    top: 11%;
    left: 50%;
    width: 8px;
    height: 52%;
    border-radius: 999px;
    transform: translateX(-50%);
    background: #e33c27;
}

.clock-hand.minute {
    width: 18px;
    height: 38%;
    background: #f7f4ec;
    transform: translateX(-50%) rotate(0deg);
    box-shadow:
        inset 0 0 0 1px rgba(0, 0, 0, 0.12),
        0 3px 8px rgba(0, 0, 0, 0.32);
}

.clock-hand.minute::after {
    content: '';
    position: absolute;
    top: 10%;
    left: 50%;
    width: 8px;
    height: 44%;
    border-radius: 999px;
    transform: translateX(-50%);
    background: #080808;
}

.clock-hand.second {
    width: 7px;
    height: 42%;
    background: #ff3a21;
    transform: translateX(-50%) rotate(0deg);
    border-radius: 99px;
    box-shadow: 0 1px 8px rgba(255, 58, 33, 0.6);
}

.second-trail {
    position: absolute;
    left: 50%;
    top: -52%;
    width: 9px;
    height: 74%;
    transform: translateX(-50%);
    border-radius: 999px;
    background: linear-gradient(
        to top,
        rgba(255, 58, 33, 0.45) 0%,
        rgba(255, 58, 33, 0.8) 56%,
        rgba(255, 90, 76, 0.85) 100%
    );
    filter: blur(5.5px);
    opacity: 0.68;
    mix-blend-mode: screen;
}

.clock-center {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 6px solid #ff3a21;
    transform: translate(-50%, -50%);
    background: #060606;
    z-index: 4;
}

.clock-date-chip {
    top: 59%;
    left: 50%;
    width: max-content;
    height: fit-content;
    transform: translate(
        calc(-50% + (var(--px) * -3px)),
        calc(var(--py) * -2px)
    );
    inset: auto;
    z-index: 5;
    padding: 6px 16px;
    border-radius: 999px;
    font-family: 'iAWriterDuoV', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: clamp(21px, 2.5vw, 32px);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #1a1a1a;
    background: #f3f0e6;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
}

body.state-lock .card-stack-container {
    opacity: 0;
    transform: scale(0.94);
    filter: none;
    pointer-events: none;
}

body.state-lock.portal-preview .card-stack-container {
    opacity: 1;
    transform: scale(1);
    transition: none;
}

body.state-unlocking .card-stack-container {
    opacity: 1;
    transform: scale(1);
    filter: none;
    pointer-events: none;
    transition: none;
}

body.state-home .card-stack-container {
    opacity: 1;
    transform: scale(1);
    filter: none;
    pointer-events: auto;
}

body.state-lock .top-nav,
body.state-lock .card-info {
    opacity: 0 !important;
    pointer-events: none !important;
}

.blur-debug {
    position: fixed;
    top: clamp(14px, 3vh, 30px);
    left: clamp(14px, 3vw, 28px);
    z-index: 2200;
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: min(340px, calc(100vw - 28px));
    max-height: min(78vh, 560px);
    overflow: auto;
    padding: 12px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(10, 10, 10, 0.58);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    font-family: 'iAWriterDuoV', -apple-system, BlinkMacSystemFont, sans-serif;
    color: rgba(255, 255, 255, 0.9);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-8px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

body.debug-settings-visible .blur-debug {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

body.state-home .blur-debug {
    opacity: 0 !important;
    pointer-events: none !important;
    transform: translateY(-8px) !important;
}

.blur-debug-head {
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: lowercase;
    opacity: 0.82;
}

.blur-debug-row {
    display: grid;
    grid-template-columns: 52px 1fr 44px;
    align-items: center;
    gap: 10px;
}

.blur-debug-label {
    font-size: 12px;
    letter-spacing: 0.02em;
    text-transform: lowercase;
    opacity: 0.82;
}

.blur-debug-slider {
    width: 100%;
}

.blur-debug-row.blur-primary-row .blur-debug-label,
.blur-debug-row.blur-primary-row .blur-debug-value {
    font-size: 13px;
    font-weight: 700;
}

.blur-debug-row.blur-primary-row .blur-debug-slider {
    height: 28px;
}

.blur-debug-value {
    font-size: 12px;
    min-width: 36px;
    text-align: right;
    opacity: 0.92;
}

/* Top Navigation */
.top-nav {
    position: fixed;
    top: 8%;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 var(--ui-edge-padding);
    z-index: 1000;
    transition: opacity 0.3s ease;
}

.nav-btn {
    background: none;
    border: none;
    font-family: 'iAWriterDuoV', -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 400;
    font-size: clamp(14px, 2vw, 18px);
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: color 0.2s ease;
    padding: 0;
    transform: scale(1.2);
}

.nav-btn:hover {
    color: #ffffff;
}

.card-stack-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    perspective: var(--scene-perspective);
    transition: opacity 0.35s ease, transform 0.45s ease;
}

/* Wrapper: stable hit area for pointer events, never tilts */
.card-wrapper {
    position: absolute;
    width: var(--card-width, 400px);
    height: var(--card-height, 400px);
    cursor: grab;
    user-select: none;
    touch-action: none;
    will-change: transform;
    perspective: var(--scene-perspective);
}

.card {
    position: relative;
    width: 100%;
    height: 100%;
    --card-radius: calc(var(--card-width, 300px) * 0.15);
    border-radius: var(--card-radius);
    --card-thickness: clamp(1.11px, calc(var(--card-width, 300px) * 0.00443), 2.33px);
    --depth-layers: 5;
    --slice-step: calc(var(--card-thickness) / var(--depth-layers));
    --depth-reactivity: 0.0089;
    will-change: transform;
    --mouse-x: 50%;
    --mouse-y: 50%;
    --tilt-x: 0;
    --tilt-y: 0;
    --shine-angle: 180deg;
    --shine-opacity: 0;
    transform-style: preserve-3d;
    overflow: visible;
    pointer-events: none;
}

.card-slice {
    position: absolute;
    inset: 0;
    border-radius: var(--card-radius);
    background-color: var(--card-edge-color, rgba(0, 0, 0, 0.25));
    transform: translate3d(
        calc(var(--slice-index) * var(--tilt-y) * var(--depth-reactivity) * -1px),
        calc(var(--slice-index) * var(--tilt-x) * var(--depth-reactivity) * 1px),
        calc(var(--slice-index) * var(--slice-step) * -1)
    );
    backface-visibility: hidden;
    pointer-events: none;
}

.card-front {
    position: absolute;
    inset: 0;
    border-radius: var(--card-radius);
    border: 2px solid;
    transform: translateZ(0.5px);
    overflow: hidden;
    backface-visibility: hidden;
    box-shadow:
        0 4px 6px rgba(0, 0, 0, 0.025),
        0 10px 20px rgba(0, 0, 0, 0.04),
        0 20px 40px rgba(0, 0, 0, 0.05);
}

/* Ambient overhead light — linear gradient that shifts with tilt angle, masked to top half */
.card-front::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: linear-gradient(
        var(--shine-angle),
        rgba(255, 255, 255, var(--shine-opacity)) 0%,
        rgba(255, 255, 255, calc(var(--shine-opacity) * 0.3)) 40%,
        transparent 80%
    );
    -webkit-mask-image: linear-gradient(to bottom, black 0%, rgba(0,0,0,0.6) 30%, rgba(0,0,0,0.2) 55%, transparent 75%);
    mask-image: linear-gradient(to bottom, black 0%, rgba(0,0,0,0.6) 30%, rgba(0,0,0,0.2) 55%, transparent 75%);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    transform: none;
    z-index: 2;
}

.card.tilt-active .card-front::before {
    opacity: 1;
}

/* Cursor-following specular highlight */
.card-front::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: radial-gradient(
        circle at var(--mouse-x) var(--mouse-y),
        rgba(255, 255, 255, 0.125) 0%,
        rgba(255, 255, 255, 0.04) 30%,
        transparent 60%
    );
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    transform: none;
}

.card.tilt-active .card-front::after {
    opacity: 1;
}

/* Keep depth shadow visible by default; tilt variables still animate it on hover */
.card-front {
    box-shadow:
        calc(var(--tilt-y) * -1px) calc(var(--tilt-x) * 1px + 2px) 4px rgba(0, 0, 0, 0.1),
        calc(var(--tilt-y) * -2px) calc(var(--tilt-x) * 2px + 8px) 16px rgba(0, 0, 0, 0.12),
        calc(var(--tilt-y) * -4px) calc(var(--tilt-x) * 4px + 16px) 32px rgba(0, 0, 0, 0.15),
        calc(var(--tilt-y) * -6px) calc(var(--tilt-x) * 6px + 24px) 48px rgba(0, 0, 0, 0.12);
}

.card-wrapper:active {
    cursor: grabbing;
}

.card-wrapper.dragging {
    cursor: grabbing;
}

.card-wrapper.dragging .card-front {
    box-shadow:
        0 10px 20px rgba(0, 0, 0, 0.05),
        0 20px 40px rgba(0, 0, 0, 0.06),
        0 40px 80px rgba(0, 0, 0, 0.075);
}

.card-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: calc(var(--card-width, 300px) * 0.08);
    pointer-events: none;
}

.card-content {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: calc(var(--card-width, 300px) * 0.08);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.9);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 24px;
    font-weight: 600;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.card-number {
    font-size: 64px;
    font-weight: 700;
    opacity: 0.3;
}

/* Card Info Text Display */
.card-info {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    padding-bottom: 3%;
    padding-top: 150px;
    text-align: center;
    z-index: 1000;
    pointer-events: none;
    transition: opacity 0.3s ease;
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0) 0%,
        rgba(0, 0, 0, 1) 100%
    );
}

.card-info-inner {
    opacity: 0;
    -webkit-transition: opacity 0.25s ease-out;
    transition: opacity 0.25s ease-out;
    -webkit-transform: translate3d(0, -80%, 0);
    transform: translate3d(0, -60%, 0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    will-change: opacity;
}

.card-info-inner.visible {
    opacity: 1;
}

.card-info-inner.fade-out {
    opacity: 0;
}


.card-info-title {
    font-family: 'iAWriterDuoV', -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 700;
    font-size: clamp(23px, 3.8vw, 40px);
    color: #ffffff;
    margin-bottom: 0;
    line-height: 1.12;
    letter-spacing: -0.02em;
}

.card-info-description {
    font-family: 'iAWriterDuoV', -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 400;
    font-size: clamp(13px, 1.9vw, 17px);
    color: rgba(255, 255, 255, 0.6);
    width: min(400px, calc(100% - (var(--ui-edge-padding) * 2)));
    margin: 0 auto;
    line-height: 1.5;
}


.fps-counter {
    position: fixed;
    top: 5%;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    font-family: 'iAWriterDuoV', monospace;
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
    pointer-events: none;
    user-select: none;
}
