/*
    STRICT CONTRIBUTION GUIDELINES
    ==============================
    * semantic HTML
    * proper indentation
    * meaningful class names
    * clean modular JavaScript
    * maintainable code quality
    * responsive design
    * optimized rendering
    * smooth animations
    * comments only where necessary
*/

:root {
    /* Color Palette */
    --color-bg-start: #fff7f5; /* Soft Peach */
    --color-bg-end: #ffe8e0;   /* Warm Cream */
    --color-ambient-glow: rgba(255, 210, 190, 0.5);

    --coin-gold-lightest: #faf3d1;
    --coin-gold-lighter: #f3e5ab;
    --coin-gold-light: #e8d384;
    --coin-gold-mid: #d7b95f;
    --coin-gold-dark: #b99845;
    --coin-gold-darker: #9a7b30;
    --coin-shadow-light: rgba(154, 123, 48, 0.2);
    --coin-shadow-dark: rgba(80, 60, 20, 0.4);
    --coin-engraving-color: rgba(0, 0, 0, 0.04);

    --coating-start: #8c5a44; /* Oxidized Copper */
    --coating-end: #5b3a29;   /* Deep Rusted Bronze */

    --reward-text-color: #8c5a44;
    --heart-color: #d48a70;

    --button-bg: #fff;
    --button-text: #8c5a44;
    --button-shadow: rgba(0, 0, 0, 0.1);

    /* Dimensions */
    --coin-size: clamp(280px, 80vmin, 400px);
    --coin-border-width: calc(var(--coin-size) * 0.05);
    --coin-inner-padding: calc(var(--coin-size) * 0.05);

    /* Animation */
    --pulse-duration: 2.5s;
    --fade-duration: 0.5s;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    font-family: 'Segoe UI', 'Roboto', 'Helvetica Neue', sans-serif;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at center, var(--color-bg-start), var(--color-bg-end));
    perspective: 1000px;
    padding: 1rem;
}

main.experience-container {
    max-width: 100%;
}


.ambient-background {
    position: absolute;
    width: 150%;
    height: 150%;
    background: radial-gradient(ellipse at center, var(--color-ambient-glow) 0%, transparent 60%);
    filter: blur(100px);
    z-index: -1;
}

.experience-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
    position: relative;
}

.coin-wrapper {
    width: var(--coin-size);
    height: var(--coin-size);
    position: relative;
    cursor: none; /* Hide default cursor */
    -webkit-tap-highlight-color: transparent; /* Disable tap highlight on mobile */
    transform-style: preserve-3d;
    transition: transform 0.5s ease-out;
}

.coin-wrapper:hover {
    transform: rotateY(5deg) rotateX(5deg) scale(1.05);
}

.coin-3d {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    position: absolute;
    transform-style: preserve-3d;
    box-shadow: 
        0 2px 5px var(--coin-shadow-light),
        0 10px 20px var(--coin-shadow-dark),
        inset 0 0 15px rgba(255, 255, 255, 0.2);
}

.coin-rim {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: linear-gradient(145deg, var(--coin-gold-darker), var(--coin-gold-light));
    transform: translateZ(-10px); /* Gives the coin thickness */
    box-shadow: 0 0 20px var(--coin-shadow-dark);
}

.coin-face {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, var(--coin-gold-lightest), var(--coin-gold-mid));
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
    transform: translateZ(0);
}

.coin-face::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.3) 0%, rgba(255, 255, 255, 0) 50%);
    transform: rotate(0deg);
    transition: transform 0.5s;
}

.coin-wrapper:hover .coin-face::before {
    transform: rotate(20deg);
}

.coin-detail-ring, .coin-engraving {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
}

.coin-detail-ring {
    border: 1px solid var(--coin-engraving-color);
    box-shadow: inset 0 0 5px var(--coin-engraving-color);
}

.ring-1 {
    width: 90%;
    height: 90%;
    opacity: 0.8;
}

.ring-2 {
    width: 80%;
    height: 80%;
    opacity: 0.6;
}

.ring-3 {
    width: 50%;
    height: 50%;
    opacity: 0.4;
}

.coin-engraving {
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at center, transparent 50%, var(--coin-engraving-color) 50.5%, transparent 51%),
        repeating-radial-gradient(
            circle at center,
            var(--coin-engraving-color),
            var(--coin-engraving-color) 1px,
            transparent 1px,
            transparent 20px
        );
    opacity: 0.5;
    transform: scale(0.95);
}

.dotted-border {
    position: absolute;
    width: calc(100% - var(--coin-inner-padding) * 2);
    height: calc(100% - var(--coin-inner-padding) * 2);
    border-radius: 50%;
    border: 2px dashed var(--coin-gold-dark);
    opacity: 0.5;
}

.coin-content {
    text-align: center;
    color: var(--reward-text-color);
    opacity: 0; /* Initially hidden, controlled by JS */
    transition: opacity 0.5s ease-in-out;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.reward-animation-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    position: relative;
}

.heart-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: transform 0.8s cubic-bezier(0.25, 1, 0.5, 1); /* Smooth upward movement */
}

.heart-icon {
    font-size: calc(var(--coin-size) * 0.25);
    line-height: 1;
    color: var(--heart-color);
    text-shadow: 
        1px 1px 0 var(--coin-gold-lightest), 
        -1px -1px 0 var(--coin-gold-darker),
        0 0 20px rgba(255, 180, 150, 0.7); /* Warm glow */
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 1s cubic-bezier(0.19, 1, 0.22, 1), transform 1s cubic-bezier(0.19, 1, 0.22, 1);
    animation: heart-glow 3s infinite ease-in-out;
}

.reward-text {
    font-size: calc(var(--coin-size) * 0.08);
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    /* margin-top is removed to allow positioning relative to the heart */
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.5);
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.8s cubic-bezier(0.19, 1, 0.22, 1) 0.2s, transform 0.8s cubic-bezier(0.19, 1, 0.22, 1) 0.2s; /* Delayed appearance */
    position: absolute; /* Positioned relative to the container */
    bottom: 30%; /* Adjust as needed */
}

/* States triggered by JavaScript */
.coin-content.stage-1 .heart-icon {
    opacity: 1;
    transform: scale(1);
}

.coin-content.stage-2 .heart-container {
    transform: translate(-50%, -120%); /* Moves the heart up */
}

.coin-content.stage-2 .reward-text {
    opacity: 1;
    transform: translateY(0);
}
.brush-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.7);
    padding: 12px 18px;
    border-radius: 40px;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.brush-controls label {
    font-size: 14px;
    font-weight: 600;
    color: var(--button-text);
}

.brush-controls input[type="range"] {
    width: 140px;
    cursor: pointer;
}

#brush-size-value {
    min-width: 24px;
    text-align: center;
    font-weight: 600;
    color: var(--button-text);
}

@keyframes heart-glow {
    0%, 100% {
        text-shadow: 
            1px 1px 0 var(--coin-gold-lightest), 
            -1px -1px 0 var(--coin-gold-darker),
            0 0 20px rgba(255, 180, 150, 0.7);
    }
    50% {
        text-shadow: 
            1px 1px 0 var(--coin-gold-lightest), 
            -1px -1px 0 var(--coin-gold-darker),
            0 0 35px rgba(255, 200, 180, 1);
    }
}

#scratch-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    z-index: 2;
    transition: opacity var(--fade-duration) ease-out;
}

.scratch-instruction {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: calc(var(--coin-size) * 0.07);
    font-weight: 300;
    letter-spacing: 1px;
    text-transform: uppercase;
    pointer-events: none;
    z-index: 3;
    text-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    animation: pulse-glow 2.5s infinite ease-in-out;
    opacity: 1;
    transition: opacity 1s ease-out;
}

.scratch-instruction.fade-out {
    opacity: 0;
    animation: none;
}

@keyframes pulse-glow {
    0%, 100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.7;
        text-shadow: 0 0 8px rgba(255, 255, 255, 0.4);
    }
    50% {
        transform: translate(-50%, -50%) scale(1.03);
        opacity: 1;
        text-shadow: 0 0 15px rgba(255, 255, 255, 0.7);
    }
}

.reset-button {
    padding: 15px 30px;
    font-size: 16px;
    font-weight: 600;
    color: var(--button-text);
    background-color: var(--button-bg);
    border: 2px solid var(--button-text);
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px var(--button-shadow);
}

.reset-button:hover {
    background-color: var(--button-text);
    color: var(--button-bg);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px var(--button-shadow);
}

.reset-button:active {
    transform: translateY(0);
    box-shadow: 0 4px 15px var(--button-shadow);
}

.custom-cursor {
    display: none; /* Hidden by default, shown via JS */
    position: fixed;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    pointer-events: none;
    transform: translate(-50%, -50%);
    z-index: 9999;
    transition: transform 0.1s ease-out;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .experience-container {
        gap: 25px;
        /* Make container relative to position the card inside it */
        position: relative; 
        justify-content: center;
        height: 100%;
    }

    .reset-button {
        padding: 14px 28px;
        font-size: 15px;
    }

    .recommendation-card {
        /* Position above the coin, relative to the experience-container */
        position: absolute;
        bottom: calc(var(--coin-size) + 80px); /* coin-size + gap + button height */
        top: auto;
        left: 50%;
        transform: translateX(-50%);
        
        padding: 12px 20px;
        width: calc(100% - 40px);
        max-width: 350px;
        
        /* Add fade-out transition */
        transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1), transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    }

    /* Fade-out state for mobile/tablet */
    .recommendation-card.fade-out {
        opacity: 0;
        transform: translate(-50%, -15px); /* Slight upward movement */
        pointer-events: none;
    }

    .headphone-icon {
        font-size: 20px;
    }

    .recommendation-card p {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .experience-container {
        gap: 20px;
    }
    .reset-button {
        padding: 12px 24px;
        font-size: 14px;
    }
}

#restore-button:hover {
  background-color: #e0e0e0;
}

.recommendation-card {
  position: absolute;
  top: 30px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(255, 240, 245, 0.85);
  border: 1px solid rgba(210, 180, 140, 0.5);
  border-radius: 15px;
  padding: 15px 25px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 1001;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1), transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  width: auto;
  max-width: 90%;
}

.recommendation-card.hidden {
  opacity: 0;
  transform: translate(-50%, -20px);
  pointer-events: none;
}

.recommendation-content {
  display: flex;
  align-items: center;
  animation: breathing 4s ease-in-out infinite;
}

.headphone-icon {
  font-size: 22px;
  margin-right: 12px;
  animation: headphone-wiggle 3s ease-in-out infinite;
}

.recommendation-card p {
    font-size: 1rem;
    color: #000;
    line-height: 1.5;
}

/* Mobile and Tablet specific styles for fade-out animation */
@media (max-width: 768px) {
    .recommendation-card {
        opacity: 1;
        transition: opacity 1.5s ease, transform 1.5s ease;
    }

    .recommendation-card.fade-out {
        opacity: 0;
        transform: translateY(-20px);
    }
}

.hidden {
    display: none;
}

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

@keyframes headphone-wiggle {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(5deg); }
    75% { transform: rotate(-5deg); }
}
