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

:root {
    /* Colors */
    --bg-color: #fafafa;
    --text-color: #1d1d1f;
    --text-secondary: #5e5e63; /* Refined for better presence while maintaining AAA contrast */
    --grain-opacity: 0.045;

    /* Dot sizes */
    --dot-size: 12px;
    --dot-size-tablet: 10px;
    --dot-size-mobile: 9px;
    --dot-size-landscape: 8px;

    /* Animation timing */
    --duration-fast: 0.2s;
    --duration-squish: 0.3s;
    --duration-normal: 0.4s;
    --duration-slow: 0.6s;
    --duration-slower: 1s;

    /* Easing functions */
    --ease-out-quart: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-out-elastic: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-smooth: cubic-bezier(0.22, 1, 0.36, 1);
}

[data-theme="dark"] {
    --bg-color: #111111;
    --text-color: #f5f5f7;
    --text-secondary: #b1b1b6;
    --grain-opacity: 0.035;
}

html {
    font-size: 16px;
}

/* Page fade-in on load */
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-color);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.4s ease, color 0.4s ease, opacity 0.4s ease;
    opacity: 0;
}

body.loaded {
    opacity: 1;
}

/* Animated grain texture overlay - dual layer for organic feel */
body::before,
body::after {
    content: '';
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    pointer-events: none;
    z-index: 1000;
    opacity: var(--grain-opacity);
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
    animation: grainShift 8s steps(10) infinite;
}

body::after {
    opacity: calc(var(--grain-opacity) * 0.5);
    animation-delay: -4s;
    animation-direction: reverse;
}

@keyframes grainShift {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-2%, -2%); }
    20% { transform: translate(1%, 3%); }
    30% { transform: translate(-3%, 1%); }
    40% { transform: translate(3%, -1%); }
    50% { transform: translate(-1%, 2%); }
    60% { transform: translate(2%, -3%); }
    70% { transform: translate(-2%, 3%); }
    80% { transform: translate(3%, 1%); }
    90% { transform: translate(1%, -2%); }
}

/* Ambient color wash - elegant, subtle living gradient */
.ambient-glow {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0;
    transition: opacity 2s var(--ease-out-quart);
    overflow: hidden;
}

.ambient-glow.active {
    opacity: 1;
}

/* Soft, diffused blobs with very gentle movement */
.ambient-glow::before,
.ambient-glow::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    background: var(--glow-color, transparent);
    filter: blur(120px);
    opacity: 0.08;
}

.ambient-glow::before {
    width: 70vmax;
    height: 70vmax;
    top: -30%;
    left: -20%;
    animation: blobDrift1 30s ease-in-out infinite;
}

.ambient-glow::after {
    width: 60vmax;
    height: 60vmax;
    bottom: -25%;
    right: -15%;
    animation: blobDrift2 35s ease-in-out infinite;
    animation-delay: -12s;
}

/* Center blob - gentlest, most diffused */
.ambient-blob {
    position: absolute;
    width: 50vmax;
    height: 50vmax;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: var(--glow-color, transparent);
    filter: blur(100px);
    opacity: 0.06;
    animation: blobDrift3 25s ease-in-out infinite;
    animation-delay: -8s;
}

/* Slow, subtle drift animations */
@keyframes blobDrift1 {
    0%, 100% {
        transform: translate(0, 0) scale(1);
    }
    50% {
        transform: translate(3%, 5%) scale(1.02);
    }
}

@keyframes blobDrift2 {
    0%, 100% {
        transform: translate(0, 0) scale(1);
    }
    50% {
        transform: translate(-4%, -3%) scale(1.03);
    }
}

@keyframes blobDrift3 {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
    }
    33% {
        transform: translate(-48%, -52%) scale(1.01);
    }
    66% {
        transform: translate(-52%, -48%) scale(0.99);
    }
}

/* Dark mode - slightly more visible with screen blend */
[data-theme="dark"] .ambient-glow::before,
[data-theme="dark"] .ambient-glow::after {
    filter: blur(140px);
    opacity: 0.06;
}

[data-theme="dark"] .ambient-blob {
    filter: blur(120px);
    opacity: 0.05;
}

.container {
    text-align: center;
    padding: 2rem;
    max-width: 600px;
    position: relative;
    z-index: 1;
}

/* Logo Container */
.logo-container {
    position: relative;
    height: 120px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 4rem;
}

/* The dot that animates */
.animated-dot {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--dot-size);
    height: var(--dot-size);
    background-color: var(--text-color);
    border-radius: 50%;
    opacity: 0;
    z-index: 10;
    will-change: transform, opacity;
    /* Height-based shadow - intensity controlled by --dot-height custom property */
    --dot-height: 0;
    --shadow-opacity: calc(min(0.15, var(--dot-height) / 400));
    --shadow-blur: calc(min(20px, var(--dot-height) / 8));
    --shadow-offset: calc(min(15px, var(--dot-height) / 12));
    filter: drop-shadow(0 var(--shadow-offset) var(--shadow-blur) rgba(0, 0, 0, var(--shadow-opacity)));
}

[data-theme="dark"] .animated-dot {
    --shadow-opacity: calc(min(0.3, var(--dot-height) / 300));
}

.animated-dot.animation-complete {
    will-change: auto;
}


/* Logo wrapper for smooth recentering */
.logo-wrapper {
    display: flex;
    justify-content: center;
    align-items: baseline;
    transition: transform var(--duration-slow) var(--ease-out-quart);
}

/* Logo text */
.logo {
    font-size: 4.5rem;
    font-weight: 500;
    letter-spacing: -0.03em;
    color: var(--text-color);
    display: flex;
    align-items: baseline;
    position: relative;
    /* Enable OpenType features for better typography */
    font-feature-settings: 'kern' 1, 'liga' 1, 'calt' 1;
    /* Optical sizing for better rendering at large sizes */
    font-optical-sizing: auto;
    /* Subtle text rendering optimization */
    text-rendering: optimizeLegibility;
}

/* .com suffix */
.logo-suffix {
    font-size: 4.5rem;
    font-weight: 500;
    letter-spacing: -0.03em;
    color: var(--text-color);
    display: inline-flex;
    overflow: hidden;
    max-width: 0;
    opacity: 0;
    transform: translateX(-8px);
    transition: max-width 1s var(--ease-smooth),
                opacity 0.8s var(--ease-smooth) 0.1s,
                transform 1s var(--ease-smooth);
    /* Match logo typography settings */
    font-feature-settings: 'kern' 1, 'liga' 1, 'calt' 1;
    font-optical-sizing: auto;
    text-rendering: optimizeLegibility;
}

.logo-suffix.visible {
    max-width: 200px;
    opacity: 1;
    transform: translateX(0);
}

.logo-suffix span {
    display: inline-block;
    white-space: nowrap;
}

.logo .letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(25px);
    will-change: transform, opacity;
}

.logo .letter.animation-complete {
    will-change: auto;
}

.logo .letter.visible {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.6s var(--ease-out-quart),
                transform 0.6s var(--ease-out-quart);
}

.logo .letter.squish {
    animation: letterSquish var(--duration-squish) var(--ease-out-elastic);
}

@keyframes letterSquish {
    0% { transform: scaleY(1) scaleX(1); }
    30% { transform: scaleY(0.85) scaleX(1.1); }
    60% { transform: scaleY(1.05) scaleX(0.98); }
    100% { transform: scaleY(1) scaleX(1); }
}

/* The final dot (period) */
.logo .dot {
    display: inline-block;
    width: var(--dot-size);
    height: var(--dot-size);
    background-color: var(--text-color);
    border-radius: 50%;
    margin-left: 0.12em;
    margin-bottom: 10px;
    opacity: 0;
    transform: scale(0);
    will-change: transform, opacity;
    cursor: pointer;
    position: relative;
    outline: none;
}

.logo .dot.animation-complete {
    will-change: auto;
}

/* Larger touch target for the dot */
.logo .dot::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 44px;
    height: 44px;
    border-radius: 50%;
}

/* Keyboard focus indicator */
.logo .dot:focus-visible {
    box-shadow: 0 0 0 3px var(--bg-color), 0 0 0 5px var(--text-color);
}

.logo .dot.visible {
    opacity: 1;
    animation: finalSettle 0.4s var(--ease-out-elastic) forwards;
}

.logo .dot.clickable {
    transform: scale(1);
}

@keyframes finalSettle {
    0% { transform: scale(0.8); }
    50% { transform: scale(1.12); }
    75% { transform: scale(0.96); }
    100% { transform: scale(1); }
}

/* Tagline */
.tagline {
    font-size: 1.375rem;
    font-weight: 300;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
    opacity: 0;
    transform: translateY(15px);
    will-change: transform, opacity;
}

.tagline.visible {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 1s var(--ease-out-quart),
                transform 1s var(--ease-out-quart);
}

.tagline.animation-complete {
    will-change: auto;
}

/* Subtle hint */
.hint {
    position: fixed;
    bottom: clamp(2rem, 5vh, 4rem);
    font-size: 0.875rem;
    color: var(--text-secondary);
    opacity: 0;
    letter-spacing: 0.03em;
    will-change: opacity;
    z-index: 1;
    cursor: pointer;
    transition: color 0.2s ease;
    /* Reset button styles */
    background: none;
    border: none;
    font-family: inherit;
    padding: 0;
}

.hint:hover {
    color: var(--text-color);
    cursor: pointer;
}

/* Press feedback for hint */
.hint:active {
    transform: scale(0.97);
}

/* Focus visible for keyboard navigation */
.hint:focus-visible {
    outline: 2px solid var(--text-color);
    outline-offset: 4px;
    border-radius: 2px;
}

.hint.visible {
    opacity: 1;
    transition: opacity 1.2s var(--ease-out-quart);
    animation: hintReveal 2s var(--ease-out-quart) 0.5s;
}

/* Subtle attention-drawing animation on first reveal */
@keyframes hintReveal {
    0% { letter-spacing: 0.05em; }
    30% { letter-spacing: 0.08em; }
    100% { letter-spacing: 0.05em; }
}

.hint.animation-complete {
    will-change: auto;
}

/* Hint punctuation transition */
.hint .hint-punct {
    display: inline-block;
    transition: opacity 0.4s ease;
}


/* Dot color easter egg */
.logo .dot.color-active,
.animated-dot.color-active {
    transition: background-color 0.4s ease;
}

/* Chaos dots for .com reveal animation */
#chaosDots {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.chaos-dot {
    position: absolute;
    left: 0;
    top: 0;
    width: var(--dot-size);
    height: var(--dot-size);
    border-radius: 50%;
    opacity: 0;
    will-change: transform, opacity;
}

/* Hover effect */
.logo:hover .dot {
    animation: dotPulse 2s ease-in-out infinite;
}

/* Press feedback for dot */
.logo .dot:active {
    transform: scale(0.85);
    transition: transform 0.1s ease-out;
}

@keyframes dotPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.12); }
}

/* Idle discovery pulse - subtle attention grabber */
.logo .dot.idle-pulse {
    animation: idlePulse 3s ease-in-out infinite;
}

@keyframes idlePulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 transparent;
    }
    50% {
        transform: scale(1.08);
        box-shadow: 0 0 0 8px rgba(128, 128, 128, 0.1);
    }
}

/* Hint nudge animation for discoverability */
.hint.nudge {
    animation: hintNudge var(--duration-slow) ease-in-out;
}

@keyframes hintNudge {
    0%, 100% { transform: translateY(0); }
    25% { transform: translateY(-3px); }
    50% { transform: translateY(0); }
    75% { transform: translateY(-2px); }
}

/* First-visit glow effect for dot */
.logo .dot.discovery-glow {
    animation: discoveryGlow 2.5s ease-in-out 2;
}

@keyframes discoveryGlow {
    0%, 100% {
        box-shadow: 0 0 0 0 transparent;
    }
    50% {
        box-shadow: 0 0 12px 4px rgba(128, 128, 128, 0.25);
    }
}

/* Menu Footer (Theme & Language) */
.menu-footer {
    position: absolute;
    bottom: 2.5rem;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 2rem;
    align-items: center;
    opacity: 0;
    transition: opacity 0.4s var(--ease-out-quart);
}

.menu-overlay.active .menu-footer {
    opacity: 1;
    transition-delay: 0.2s;
}

/* Theme Toggle in Menu */
.theme-toggle {
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px;
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: var(--text-secondary);
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: stroke 0.3s ease, transform 0.3s ease;
}

.theme-toggle:hover svg {
    stroke: var(--text-color);
}

.theme-toggle .sun-icon {
    display: block;
}

.theme-toggle .moon-icon {
    display: none;
}

[data-theme="dark"] .theme-toggle .sun-icon {
    display: none;
}

[data-theme="dark"] .theme-toggle .moon-icon {
    display: block;
}

/* Language Selector */
.lang-selector {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.lang-selector button {
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--text-secondary);
    padding: 4px 8px;
    transition: color 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    /* Minimum 44x44px touch target for accessibility */
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lang-selector button:hover {
    color: var(--text-color);
}

.lang-selector button.active {
    color: var(--text-color);
    font-weight: 500;
}

.lang-separator {
    color: var(--text-secondary);
    font-size: 0.875rem;
    opacity: 0.5;
}

/* Burger Menu */
.menu-toggle {
    position: fixed;
    top: 2rem;
    right: 2rem;
    width: 44px;
    height: 44px;
    background: transparent;
    border: none;
    cursor: pointer;
    z-index: 100;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 6px;
    padding: 10px;
}

.menu-toggle span {
    display: block;
    width: 24px;
    height: 1.5px;
    background-color: var(--text-color);
    border-radius: 0.75px;
    transition: transform 0.3s var(--ease-out-quart),
                opacity 0.3s var(--ease-out-quart);
}

.menu-toggle.active span:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
}

.menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.menu-toggle.active span:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
}

/* Menu Overlay */
.menu-overlay {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-color);
    z-index: 90;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s var(--ease-out-quart),
                visibility 0.4s var(--ease-out-quart);
}

.menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

.menu-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.menu-content nav {
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}

.menu-content a {
    font-size: 2rem;
    font-weight: 500;
    color: var(--text-color);
    text-decoration: none;
    letter-spacing: -0.02em;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s var(--ease-out-quart),
                transform 0.4s var(--ease-out-quart),
                color var(--duration-fast) ease;
}

.menu-content a:hover {
    color: var(--text-secondary);
}

.menu-overlay.active .menu-content .menu-item {
    opacity: 1;
    transform: translateY(0);
}

.menu-overlay.active .menu-content .menu-item:nth-child(1) {
    transition-delay: 0.1s;
}

.menu-overlay.active .menu-content .menu-item:nth-child(2) {
    transition-delay: 0.15s;
}

/* Menu Items with fold-out */
.menu-item {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s var(--ease-out-quart),
                transform 0.4s var(--ease-out-quart);
}

.menu-item-header {
    font-size: 2rem;
    font-weight: 500;
    color: var(--text-color);
    letter-spacing: -0.02em;
    cursor: pointer;
    transition: color 0.2s ease;
    background: none;
    border: none;
    font-family: inherit;
    text-transform: lowercase;
    display: inline-flex;
    align-items: baseline;
    gap: 0.15em;
}

/* Menu item dots */
.menu-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    background-color: var(--text-color);
    border-radius: 50%;
    margin-bottom: 0.2em;
    transition: background-color var(--duration-normal) ease, transform 0.3s var(--ease-out-elastic);
}

.menu-dot.color-active {
    transition: background-color var(--duration-normal) ease, transform 0.3s var(--ease-out-elastic);
}

.menu-item-header:hover .menu-dot {
    transform: translateY(-6px);
}

.menu-item.expanded .menu-dot {
    animation: menuDotFall var(--duration-normal) var(--ease-out-elastic);
}

@keyframes menuDotFall {
    0% { transform: translateY(-6px); }
    60% { transform: translateY(2px); }
    100% { transform: translateY(0); }
}

.menu-item-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--duration-normal) var(--ease-out-quart),
                opacity 0.3s ease,
                margin var(--duration-normal) var(--ease-out-quart);
    opacity: 0;
    margin-top: 0;
}

.menu-item.expanded .menu-item-content {
    max-height: 200px;
    opacity: 1;
    margin-top: 1rem;
}

.menu-item-content a {
    font-size: 1.25rem;
    font-weight: 400;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s ease;
    display: inline-block;
    opacity: 1;
    transform: none;
    text-transform: lowercase;
}

.menu-item-content a:hover {
    color: var(--text-color);
}

.menu-item-content p {
    font-size: 1rem;
    font-weight: 300;
    color: var(--text-secondary);
    line-height: 1.6;
    max-width: 400px;
    margin: 0 auto;
}

/* Responsive */
@media (max-width: 768px) {
    :root {
        --dot-size: var(--dot-size-tablet);
    }

    .logo {
        font-size: 3.5rem;
    }

    .logo-suffix {
        font-size: 3.5rem;
    }

    .logo-container {
        height: 90px;
    }

    .logo .dot {
        margin-bottom: 8px;
    }

    .tagline {
        font-size: 1.1rem;
    }
}

@media (max-width: 480px) {
    :root {
        --dot-size: var(--dot-size-mobile);
    }

    .logo {
        font-size: 3rem;
    }

    .logo-suffix {
        font-size: 3rem;
    }

    .logo .dot {
        margin-bottom: 5px;
    }
}

/* Landscape orientation on small screens */
@media (max-height: 500px) and (orientation: landscape) {
    :root {
        --dot-size: var(--dot-size-landscape);
    }

    .logo {
        font-size: 2.75rem;
    }

    .logo-suffix {
        font-size: 2.75rem;
    }

    .logo-container {
        height: 70px;
        margin-bottom: 1.5rem;
    }

    .logo .dot {
        margin-bottom: 4px;
    }

    .tagline {
        font-size: 1rem;
    }

    .hint {
        bottom: 1.5rem;
        font-size: 0.75rem;
    }

    .menu-toggle {
        top: 1rem;
        right: 1rem;
    }

    .menu-footer {
        bottom: 1.5rem;
    }

    .container {
        padding: 1rem;
    }
}

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

/* Reduced motion preference - CSS fallback */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    /* Keep essential state changes visible */
    .logo .letter.visible,
    .logo .dot.visible,
    .tagline.visible,
    .hint.visible,
    .menu-overlay.active,
    .logo-suffix.visible {
        opacity: 1;
        transform: none;
    }
}
