/* ============================================
   eyes.cash — Earth-Tone Dopamine Stylesheet
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
    /* Earth-Tone Dopamine Palette */
    --deep-ground:       #2C1A0E;  /* Espresso Loam */
    --primary-surface:   #A0522D;  /* Fired Clay */
    --secondary-surface: #C9A86C;  /* Desert Sandstone */
    --accent-warm:       #D4712A;  /* Molten Copper */
    --accent-hot:        #C13B2A;  /* Cayenne Spark */
    --highlight:         #E8A317;  /* Saffron Flash */
    --neutral-light:     #F2E8D5;  /* Parchment Cream */
    --neutral-mid:       #B8A48C;  /* Dust Trail */
    --text-primary:      #3D2517;  /* Burnt Umber Deep */
    --text-secondary:    #7A6B5D;  /* Sandstone Gray */

    /* Gradients */
    --hero-gradient:     linear-gradient(165deg, #2C1A0E 0%, #A0522D 45%, #D4712A 100%);
    --card-gradient:     linear-gradient(180deg, #F2E8D5 0%, #C9A86C 100%);
    --receipt-bg:        #F2E8D5;

    /* Shadows */
    --shadow-deep:    0 12px 24px rgba(44, 26, 14, 0.25);
    --shadow-mid:     0 6px 12px rgba(160, 82, 45, 0.15);
    --shadow-subtle:  0 3px 6px rgba(184, 164, 140, 0.10);

    /* Transitions */
    --pop-in:   280ms cubic-bezier(0.34, 1.56, 0.64, 1);
    --pop-out:  350ms ease-out;

    /* Fonts */
    --font-display: 'Righteous', cursive;
    --font-ui:      'Saira', sans-serif;
    --font-mono:    'Share Tech Mono', monospace;
}

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: var(--font-ui);
    font-weight: 400;
    font-size: 1.05rem;
    line-height: 1.65;
    color: var(--text-primary);
    background-color: var(--neutral-light);
    overflow-x: hidden;
    position: relative;
}

/* Paper grain noise overlay on the whole page */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    filter: url(#noise);
    opacity: 0.05;
    pointer-events: none;
    z-index: 9999;
}

/* --- Typography --- */
h1 {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 4.5rem;
    letter-spacing: -0.03em;
    line-height: 1.05;
    color: var(--neutral-light);
}

h2 {
    font-family: var(--font-display);
    font-weight: 400;
    font-size: 2.8rem;
    letter-spacing: -0.03em;
    line-height: 1.05;
}

h3 {
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: 1.4rem;
    letter-spacing: 0.02em;
    line-height: 1.2;
}

.card-label {
    font-family: var(--font-ui);
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.card-body {
    font-family: var(--font-ui);
    font-weight: 400;
    font-size: 1.05rem;
    line-height: 1.65;
}

.card-subtitle {
    font-family: var(--font-ui);
    font-weight: 400;
    font-size: 1.2rem;
    line-height: 1.55;
    color: var(--neutral-mid);
    margin-top: 1.5rem;
}

/* --- Coin Circle Accents --- */
.coin-accents {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.coin {
    position: absolute;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.6s ease;
}

/* --- Tray Container (left-offset grid) --- */
.tray-container {
    width: 84%;
    margin-left: 8%;
    margin-right: 8%;
    position: relative;
}

/* --- Card System --- */
.card {
    position: relative;
    border-radius: 6px;
    cursor: default;
    /* Entry animation initial state */
    opacity: 0;
    transform: translateY(30px) scale(0.92);
    transition:
        transform var(--pop-out),
        box-shadow var(--pop-out),
        opacity 500ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.card.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.card-inner {
    position: relative;
    overflow: hidden;
    border-radius: 6px;
    padding: 2.5rem;
    height: 100%;
    z-index: 2;
    /* Embossed ridge lines */
    background-image:
        repeating-linear-gradient(
            180deg,
            transparent,
            transparent 39px,
            rgba(255, 255, 255, 0.06) 39px,
            rgba(255, 255, 255, 0.06) 40px
        );
}

/* Card depth levels */
.card-primary .card-inner {
    background-color: var(--primary-surface);
    background-image:
        repeating-linear-gradient(
            180deg,
            transparent,
            transparent 39px,
            rgba(255, 255, 255, 0.06) 39px,
            rgba(255, 255, 255, 0.06) 40px
        );
    color: var(--neutral-light);
}

.card-primary {
    box-shadow: var(--shadow-deep);
}

.card-secondary .card-inner {
    background: var(--card-gradient);
    color: var(--text-primary);
}

.card-secondary {
    box-shadow: var(--shadow-mid);
}

.card-tertiary .card-inner {
    background-color: var(--neutral-light);
    color: var(--text-primary);
}

.card-tertiary {
    box-shadow: var(--shadow-subtle);
}

/* --- Ghost Card Stack --- */
.card-ghost {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 6px;
    background: var(--neutral-mid);
    z-index: 0;
    transition: transform var(--pop-out);
}

.ghost-1 {
    transform: translate(3px, 3px);
    opacity: 0.6;
}

.ghost-2 {
    transform: translate(6px, 6px);
    opacity: 0.3;
}

.ghost-3 {
    transform: translate(9px, 9px);
    opacity: 0.15;
}

/* Ghost fan on hover */
.card:hover .ghost-1 {
    transform: translate(5px, 5px);
}

.card:hover .ghost-2 {
    transform: translate(10px, 10px);
}

.card:hover .ghost-3 {
    transform: translate(15px, 15px);
}

/* --- Scale-Hover Interaction --- */
.card:hover {
    transform: translateY(0) scale(1.09);
    transition: transform var(--pop-in), box-shadow var(--pop-in);
    z-index: 10;
}

.card-primary:hover {
    box-shadow: 0 18px 36px rgba(44, 26, 14, 0.35);
}

.card-primary:hover .card-inner {
    background-color: #B05E33;
}

.card-secondary:hover {
    box-shadow: 0 12px 24px rgba(160, 82, 45, 0.25);
}

.card-secondary:hover .card-inner {
    background: linear-gradient(180deg, #F5ECD8 0%, #D4B87A 100%);
}

.card-tertiary:hover {
    box-shadow: 0 9px 18px rgba(184, 164, 140, 0.20);
}

.card-tertiary:hover .card-inner {
    background-color: #F7EDD8;
}

/* --- Counter Watermark --- */
.counter-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 10rem;
    opacity: 0.09;
    color: inherit;
    z-index: 0;
    pointer-events: none;
    white-space: nowrap;
    line-height: 1;
}

.counter-watermark-large {
    font-size: 14rem;
}

/* ============================================
   SECTION 1: Hero Tray
   ============================================ */
.hero-tray {
    min-height: 100vh;
    display: flex;
    align-items: center;
    background: var(--hero-gradient);
    position: relative;
    z-index: 2;
    padding: 4rem 0;
}

.hero-tray-grid {
    display: grid;
    grid-template-columns: 1.5fr 5fr 1.5fr;
    gap: 16px;
    align-items: stretch;
}

.card-hero .card-inner {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    min-height: 60vh;
    padding: 4rem;
}

.card-flanking .card-inner {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 40vh;
    padding: 2rem;
}

.hero-tray .card-secondary .card-inner {
    background: linear-gradient(180deg, rgba(242, 232, 213, 0.15) 0%, rgba(201, 168, 108, 0.15) 100%);
    color: var(--neutral-light);
}

.hero-tray .card-secondary .card-label {
    color: var(--neutral-mid);
}

.hero-tray .card-tertiary .card-inner {
    background-color: rgba(242, 232, 213, 0.08);
    color: var(--neutral-light);
}

.hero-tray .card-tertiary .card-label {
    color: var(--neutral-mid);
}

/* Tray recessed background for hero */
.hero-tray .tray-container {
    background: rgba(44, 26, 14, 0.3);
    border: 2px solid rgba(184, 164, 140, 0.2);
    border-radius: 8px;
    padding: 16px;
}

/* ============================================
   SECTION 2: Sorting Grid
   ============================================ */
.sorting-grid {
    padding: 6rem 0;
    position: relative;
    z-index: 2;
}

.tray-group {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 16px;
    background: rgba(184, 164, 140, 0.12);
    border: 2px solid rgba(184, 164, 140, 0.2);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 2rem;
}

/* Tray Group 1 layout */
.tray-group:nth-child(1) .card-wide {
    grid-column: span 6;
}

.tray-group:nth-child(1) .card-square:nth-child(2) {
    grid-column: span 3;
}

.tray-group:nth-child(1) .card-square:nth-child(3) {
    grid-column: span 3;
}

/* Tray Group 2 layout */
.tray-group:nth-child(2) .card-tall {
    grid-column: span 4;
    min-height: 380px;
}

.tray-group:nth-child(2) .card-medium {
    grid-column: span 5;
}

.tray-group:nth-child(2) .card-small {
    grid-column: span 3;
}

.sorting-grid h2 {
    margin-bottom: 1rem;
}

.sorting-grid h3 {
    margin-bottom: 0.75rem;
}

/* ============================================
   SECTION 3: Receipt Strip Dividers
   ============================================ */
.receipt-strip {
    position: relative;
    z-index: 2;
    background: var(--receipt-bg);
    border-top: 1px dashed var(--neutral-mid);
    border-bottom: 1px dashed var(--neutral-mid);
    padding: 0;
    overflow: hidden;
}

.receipt-content {
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 2rem;
}

.receipt-strip-short .receipt-content {
    height: 65px;
}

.receipt-strip-shorter .receipt-content {
    height: 50px;
}

.receipt-text {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    line-height: 1.4;
    color: var(--text-secondary);
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.receipt-cursor {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--accent-hot);
    animation: blink 600ms step-end infinite;
    margin-left: 2px;
    display: none;
}

.receipt-cursor.active {
    display: inline;
}

.receipt-cursor.fade-out {
    animation: cursorFadeOut 800ms forwards;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

@keyframes cursorFadeOut {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

/* Receipt tear edges */
.receipt-tear-top,
.receipt-tear-bottom {
    height: 6px;
    width: 100%;
    position: relative;
    overflow: hidden;
}

.receipt-tear-top {
    background: linear-gradient(90deg,
        var(--receipt-bg) 0px, transparent 0px,
        transparent 4px, var(--receipt-bg) 4px,
        var(--receipt-bg) 8px, transparent 8px,
        transparent 12px, var(--receipt-bg) 12px
    );
    background-size: 16px 6px;
    clip-path: polygon(
        0% 100%, 2% 40%, 4% 100%, 6% 30%, 8% 100%, 10% 50%,
        12% 100%, 14% 35%, 16% 100%, 18% 45%, 20% 100%, 22% 30%,
        24% 100%, 26% 50%, 28% 100%, 30% 40%, 32% 100%, 34% 35%,
        36% 100%, 38% 45%, 40% 100%, 42% 30%, 44% 100%, 46% 50%,
        48% 100%, 50% 40%, 52% 100%, 54% 35%, 56% 100%, 58% 45%,
        60% 100%, 62% 30%, 64% 100%, 66% 50%, 68% 100%, 70% 40%,
        72% 100%, 74% 35%, 76% 100%, 78% 45%, 80% 100%, 82% 30%,
        84% 100%, 86% 50%, 88% 100%, 90% 40%, 92% 100%, 94% 35%,
        96% 100%, 98% 45%, 100% 100%
    );
}

.receipt-tear-bottom {
    background: linear-gradient(90deg,
        var(--receipt-bg) 0px, transparent 0px,
        transparent 4px, var(--receipt-bg) 4px,
        var(--receipt-bg) 8px, transparent 8px,
        transparent 12px, var(--receipt-bg) 12px
    );
    background-size: 16px 6px;
    clip-path: polygon(
        0% 0%, 2% 60%, 4% 0%, 6% 70%, 8% 0%, 10% 50%,
        12% 0%, 14% 65%, 16% 0%, 18% 55%, 20% 0%, 22% 70%,
        24% 0%, 26% 50%, 28% 0%, 30% 60%, 32% 0%, 34% 65%,
        36% 0%, 38% 55%, 40% 0%, 42% 70%, 44% 0%, 46% 50%,
        48% 0%, 50% 60%, 52% 0%, 54% 65%, 56% 0%, 58% 55%,
        60% 0%, 62% 70%, 64% 0%, 66% 50%, 68% 0%, 70% 60%,
        72% 0%, 74% 65%, 76% 0%, 78% 55%, 80% 0%, 82% 70%,
        84% 0%, 86% 50%, 88% 0%, 90% 60%, 92% 0%, 94% 65%,
        96% 0%, 98% 55%, 100% 0%
    );
}

/* ============================================
   SECTION 4: Deep Tray
   ============================================ */
.deep-tray {
    padding: 6rem 0;
    position: relative;
    z-index: 2;
}

.deep-tray .tray-container {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.card-deep {
    width: 75%;
}

.card-deep[data-offset="0"] {
    margin-left: 0;
}

.card-deep[data-offset="1"] {
    margin-left: 12.5%;
    margin-top: 20px;
}

.card-deep[data-offset="2"] {
    margin-left: 25%;
    margin-top: 20px;
}

.card-deep .card-inner {
    min-height: 240px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 3rem;
}

.deep-tray h2 {
    margin-bottom: 1rem;
}

/* Deep section card text adjustments for dark bg */
.deep-tray .card-primary h2 {
    color: var(--neutral-light);
}

.deep-tray .card-primary .card-body {
    color: var(--neutral-mid);
}

.deep-tray .card-secondary h2 {
    color: var(--text-primary);
}

/* ============================================
   SECTION 5: Final Register
   ============================================ */
.final-register {
    min-height: 100vh;
    display: flex;
    align-items: center;
    position: relative;
    z-index: 2;
    padding: 4rem 0;
}

.card-final {
    width: 100%;
}

.card-final .card-inner {
    min-height: 70vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 5rem;
}

.card-final {
    box-shadow: 0 20px 40px rgba(44, 26, 14, 0.4);
}

.card-final h1 {
    margin-bottom: 2rem;
}

.card-final .card-body {
    max-width: 720px;
    color: var(--neutral-mid);
    font-size: 1.15rem;
    line-height: 1.7;
}

.final-domain {
    margin-top: 3rem;
    padding: 1rem 3rem;
    border: 2px solid var(--accent-warm);
    border-radius: 4px;
}

.domain-text {
    font-family: var(--font-display);
    font-size: 2rem;
    color: var(--highlight);
    letter-spacing: 0.05em;
}

/* ============================================
   Scroll-Driven Depth Progression
   (JS toggles .depth-* classes on body)
   ============================================ */
body {
    transition: background-color 0.4s ease, color 0.4s ease;
}

body.depth-surface {
    background-color: var(--neutral-light);
    color: var(--text-primary);
}

body.depth-mid {
    background-color: var(--secondary-surface);
    color: var(--text-primary);
}

body.depth-deep {
    background-color: #5A3820;
    color: var(--neutral-light);
}

body.depth-abyss {
    background-color: var(--deep-ground);
    color: var(--neutral-light);
}

/* Inverted text colors at depth */
body.depth-deep .sorting-grid .card-secondary .card-body,
body.depth-abyss .sorting-grid .card-secondary .card-body {
    color: var(--text-primary);
}

body.depth-deep .receipt-text,
body.depth-abyss .receipt-text {
    color: var(--neutral-mid);
}

body.depth-deep .receipt-strip,
body.depth-abyss .receipt-strip {
    background: rgba(44, 26, 14, 0.5);
    border-color: rgba(184, 164, 140, 0.3);
}

body.depth-deep .tray-group,
body.depth-abyss .tray-group {
    background: rgba(44, 26, 14, 0.2);
    border-color: rgba(184, 164, 140, 0.15);
}

/* ============================================
   Mobile / Responsive
   ============================================ */
@media (max-width: 768px) {
    .tray-container {
        width: 92%;
        margin-left: 4%;
        margin-right: 4%;
    }

    h1 {
        font-size: 2.8rem;
    }

    h2 {
        font-size: 2rem;
    }

    .hero-tray-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .card-hero .card-inner {
        min-height: 50vh;
        padding: 2.5rem;
    }

    .card-flanking .card-inner {
        min-height: auto;
        padding: 1.5rem;
    }

    .tray-group {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .tray-group .card-wide,
    .tray-group .card-square,
    .tray-group .card-tall,
    .tray-group .card-medium,
    .tray-group .card-small {
        grid-column: span 1;
        min-height: auto;
    }

    .card-deep {
        width: 100%;
        margin-left: 0 !important;
    }

    .counter-watermark {
        font-size: 5rem;
    }

    .counter-watermark-large {
        font-size: 7rem;
    }

    .card-final .card-inner {
        padding: 2.5rem;
        min-height: 60vh;
    }

    .receipt-text {
        font-size: 0.75rem;
        white-space: normal;
        text-align: center;
    }

    /* Touch: scale-hover on tap-hold is handled via JS */
    .card:hover {
        transform: translateY(0) scale(1);
    }

    .card.touch-active {
        transform: translateY(0) scale(1.06);
        z-index: 10;
    }

    .card.touch-active .ghost-1 {
        transform: translate(5px, 5px);
    }

    .card.touch-active .ghost-2 {
        transform: translate(10px, 10px);
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 2.2rem;
    }

    h2 {
        font-size: 1.6rem;
    }

    .card-inner {
        padding: 1.5rem;
    }

    .domain-text {
        font-size: 1.4rem;
    }
}
