/* ============================================
   Gold Scrap Price Calculator - Premium Edition
   Aesthetic: Luxury Bullion / Refined Financial
   ============================================ */

/* Google Fonts Import - Distinctive Typography */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;500;600;700&family=DM+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* CSS Custom Properties */
:root {
    /* Rich, deep backgrounds */
    --bg-primary: #0a0a0b;
    --bg-secondary: #111113;
    --bg-card: #18181b;
    --bg-elevated: #1f1f23;

    /* Refined gold palette */
    --gold-deep: #8b6914;
    --gold-primary: #c9a227;
    --gold-bright: #e4c655;
    --gold-light: #f5e6a3;
    --gold-shimmer: linear-gradient(135deg, #c9a227 0%, #f5e6a3 25%, #c9a227 50%, #f5e6a3 75%, #c9a227 100%);

    /* Text hierarchy */
    --text-primary: #fafafa;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --text-gold: #e4c655;

    /* Borders and accents */
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-gold: rgba(201, 162, 39, 0.4);
    --border-gold-bright: rgba(228, 198, 85, 0.6);

    /* Status colors */
    --success: #22c55e;
    --error: #ef4444;

    /* Shadows and glows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);
    --shadow-gold: 0 0 40px rgba(201, 162, 39, 0.15);
    --glow-gold: 0 0 20px rgba(228, 198, 85, 0.3);

    /* Spacing scale */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;

    /* Border radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl: 24px;

    /* Transitions */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --duration-fast: 150ms;
    --duration-normal: 300ms;
    --duration-slow: 500ms;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    font-family: 'DM Sans', system-ui, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;

    /* Subtle noise texture overlay */
    background-image:
        url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' 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");
    background-blend-mode: overlay;
    background-size: 200px;
}

/* Hidden attribute support */
[hidden] {
    display: none !important;
}

/* Accessibility: Visually Hidden */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================
   Container & Layout
   ============================================ */
.container {
    max-width: 880px;
    margin: 0 auto;
    padding: var(--space-6);
    position: relative;
}

/* Decorative background elements */
.container::before {
    content: '';
    position: fixed;
    top: -50%;
    right: -20%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(201, 162, 39, 0.03) 0%, transparent 70%);
    pointer-events: none;
    z-index: -1;
}

.container::after {
    content: '';
    position: fixed;
    bottom: -30%;
    left: -10%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(201, 162, 39, 0.02) 0%, transparent 70%);
    pointer-events: none;
    z-index: -1;
}

/* ============================================
   Header
   ============================================ */
.header {
    text-align: center;
    padding: var(--space-12) 0 var(--space-10);
    position: relative;
    animation: fadeInDown 0.8s var(--ease-out) both;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.logo-area {
    position: relative;
    display: inline-block;
}

/* Decorative line above title */
.logo-area::before {
    content: '';
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 2px;
    background: var(--gold-shimmer);
    background-size: 200% 100%;
    animation: shimmer 3s linear infinite;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.site-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: clamp(1.75rem, 5vw, 2.5rem);
    font-weight: 600;
    letter-spacing: -0.02em;
    background: var(--gold-shimmer);
    background-size: 200% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shimmer 4s linear infinite;
}

/* ============================================
   Section Headings
   ============================================ */
.section-heading {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-bottom: var(--space-6);
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.heading-icon {
    font-size: 1rem;
    color: var(--gold-primary);
    opacity: 0.8;
}

/* ============================================
   Price Cards Section
   ============================================ */
.price-section {
    margin-bottom: var(--space-12);
    animation: fadeInUp 0.8s var(--ease-out) 0.2s both;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.price-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-4);
}

.price-card {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    text-align: center;
    position: relative;
    overflow: hidden;
    transition:
        transform var(--duration-normal) var(--ease-out),
        border-color var(--duration-normal) var(--ease-out),
        box-shadow var(--duration-normal) var(--ease-out);
}

/* Subtle top accent line */
.price-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, var(--gold-primary) 50%, transparent 100%);
    opacity: 0.5;
}

/* Hover glow effect */
.price-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 0%, rgba(201, 162, 39, 0.08) 0%, transparent 60%);
    opacity: 0;
    transition: opacity var(--duration-normal) var(--ease-out);
}

.price-card:hover {
    transform: translateY(-4px);
    border-color: var(--border-gold);
    box-shadow: var(--shadow-gold);
}

.price-card:hover::after {
    opacity: 1;
}

/* Staggered animation for cards */
.price-card:nth-child(1) { animation: fadeInUp 0.6s var(--ease-out) 0.1s both; }
.price-card:nth-child(2) { animation: fadeInUp 0.6s var(--ease-out) 0.15s both; }
.price-card:nth-child(3) { animation: fadeInUp 0.6s var(--ease-out) 0.2s both; }
.price-card:nth-child(4) { animation: fadeInUp 0.6s var(--ease-out) 0.25s both; }
.price-card:nth-child(5) { animation: fadeInUp 0.6s var(--ease-out) 0.3s both; }
.price-card:nth-child(6) { animation: fadeInUp 0.6s var(--ease-out) 0.35s both; }

/* Price Card Content */
.price-card-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    position: relative;
    z-index: 1;
}

.karat-label {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1rem;
    font-weight: 500;
    color: var(--gold-bright);
    letter-spacing: 0.02em;
}

.price-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--text-primary);
    margin: var(--space-2) 0;
    letter-spacing: -0.02em;
}

.price-timestamp {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

/* Skeleton Loading */
.price-card-skeleton {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
}

.skeleton-label,
.skeleton-price,
.skeleton-timestamp {
    background: linear-gradient(
        90deg,
        var(--bg-secondary) 25%,
        var(--bg-elevated) 50%,
        var(--bg-secondary) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

.skeleton-label {
    width: 70px;
    height: 16px;
}

.skeleton-price {
    width: 90px;
    height: 28px;
}

.skeleton-timestamp {
    width: 100px;
    height: 12px;
}

@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Error Message */
.error-message {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-6);
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--radius-md);
    margin-top: var(--space-6);
    backdrop-filter: blur(8px);
}

.error-icon {
    font-size: 1rem;
    color: var(--error);
}

.error-text {
    color: var(--error);
    font-size: 0.875rem;
    font-weight: 500;
}

/* ============================================
   Calculator Section
   ============================================ */
.calculator-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: var(--space-8);
    margin-bottom: var(--space-12);
    position: relative;
    overflow: hidden;
    animation: fadeInUp 0.8s var(--ease-out) 0.4s both;
}

/* Decorative corner accent */
.calculator-section::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 150px;
    height: 150px;
    background: radial-gradient(circle at 100% 0%, rgba(201, 162, 39, 0.04) 0%, transparent 70%);
    pointer-events: none;
}

.calculator-info {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: var(--space-6);
    padding-bottom: var(--space-5);
    border-bottom: 1px solid var(--border-subtle);
}

/* Calculator Form */
.calculator-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.calculator-row {
    display: grid;
    grid-template-columns: 90px 1fr auto auto auto;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-5);
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    transition:
        border-color var(--duration-fast) var(--ease-out),
        background-color var(--duration-fast) var(--ease-out);
}

.calculator-row:hover {
    background: var(--bg-elevated);
}

.calculator-row:focus-within {
    border-color: var(--border-gold);
    background: var(--bg-elevated);
}

/* Karat Label */
.calc-karat-label {
    display: flex;
    align-items: baseline;
    gap: var(--space-1);
}

.karat-badge {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gold-bright);
}

.karat-text {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* Input Group */
.calc-input-group {
    display: flex;
    align-items: center;
    background: var(--bg-primary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    overflow: hidden;
    transition: border-color var(--duration-fast) var(--ease-out);
}

.calc-input-group:focus-within {
    border-color: var(--gold-primary);
}

.weight-input {
    width: 100%;
    min-width: 80px;
    padding: var(--space-3) var(--space-4);
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9375rem;
    font-weight: 500;
    outline: none;
    -moz-appearance: textfield;
}

.weight-input::-webkit-outer-spin-button,
.weight-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.weight-input::placeholder {
    color: var(--text-muted);
    opacity: 0.5;
}

.input-suffix {
    padding: var(--space-3) var(--space-4);
    color: var(--text-muted);
    font-size: 0.8125rem;
    font-weight: 500;
    border-left: 1px solid var(--border-subtle);
    background: rgba(255, 255, 255, 0.02);
}

/* Price Display */
.calc-price {
    display: flex;
    align-items: center;
    gap: 2px;
    color: var(--text-muted);
    font-size: 0.8125rem;
    white-space: nowrap;
}

.price-label {
    opacity: 0.6;
}

.calc-price-value {
    font-family: 'JetBrains Mono', monospace;
    color: var(--gold-primary);
    font-weight: 500;
}

.price-unit {
    opacity: 0.6;
}

/* Equals Sign */
.calc-equals {
    color: var(--text-muted);
    font-size: 1rem;
    opacity: 0.4;
}

/* Calculated Value */
.calc-value {
    min-width: 100px;
    text-align: right;
}

.calc-value-amount {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

/* Total Section */
.total-section {
    margin-top: var(--space-8);
    padding: var(--space-8);
    background: var(--bg-card);
    border: 1px solid var(--border-gold);
    border-radius: var(--radius-lg);
    text-align: center;
    position: relative;
    overflow: hidden;
}

/* Premium gold border glow */
.total-section::before {
    content: '';
    position: absolute;
    inset: -1px;
    background: var(--gold-shimmer);
    background-size: 200% 100%;
    animation: shimmer 3s linear infinite;
    border-radius: var(--radius-lg);
    z-index: -1;
    opacity: 0.3;
}

.total-section::after {
    content: '';
    position: absolute;
    inset: 1px;
    background: var(--bg-card);
    border-radius: calc(var(--radius-lg) - 1px);
    z-index: -1;
}

.total-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.2em;
    margin-bottom: var(--space-2);
}

.total-amount {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: clamp(2rem, 6vw, 3rem);
    font-weight: 600;
    background: var(--gold-shimmer);
    background-size: 200% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: shimmer 4s linear infinite;
    letter-spacing: -0.02em;
}

/* ============================================
   CTA Section
   ============================================ */
.cta-section {
    text-align: center;
    padding: var(--space-12) var(--space-8);
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    margin-bottom: var(--space-10);
    position: relative;
    overflow: hidden;
    animation: fadeInUp 0.8s var(--ease-out) 0.6s both;
}

/* Decorative background pattern */
.cta-section::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 20% 80%, rgba(201, 162, 39, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(201, 162, 39, 0.03) 0%, transparent 50%);
    pointer-events: none;
}

.cta-heading {
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-3);
    position: relative;
}

.cta-disclaimer {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: var(--space-8);
    position: relative;
}

.cta-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-4);
    position: relative;
}

.cta-button {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-8);
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    font-weight: 600;
    text-decoration: none;
    transition:
        transform var(--duration-fast) var(--ease-spring),
        box-shadow var(--duration-fast) var(--ease-out),
        background-color var(--duration-fast) var(--ease-out),
        border-color var(--duration-fast) var(--ease-out);
}

.cta-button:hover {
    transform: translateY(-2px);
}

.cta-button:active {
    transform: translateY(0);
}

.cta-button-primary {
    background: linear-gradient(135deg, var(--gold-primary) 0%, var(--gold-deep) 100%);
    color: var(--bg-primary);
    border: none;
}

.cta-button-primary:hover {
    box-shadow: var(--glow-gold);
}

.cta-button-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
}

.cta-button-secondary:hover {
    border-color: var(--gold-primary);
    color: var(--gold-bright);
}

.cta-button-accent {
    background: var(--success);
    color: white;
    border: none;
}

.cta-button-accent:hover {
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.3);
}

.cta-icon {
    font-size: 1.125rem;
}

/* ============================================
   Footer
   ============================================ */
.footer {
    text-align: center;
    padding: var(--space-8) 0;
    animation: fadeInUp 0.8s var(--ease-out) 0.8s both;
}

.footer-text {
    color: var(--text-muted);
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

/* ============================================
   Responsive Styles
   ============================================ */

/* Tablet */
@media (max-width: 768px) {
    .container {
        padding: var(--space-4);
    }

    .header {
        padding: var(--space-8) 0;
    }

    .price-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-3);
    }

    .price-card {
        padding: var(--space-5);
    }

    .price-value {
        font-size: 1.25rem;
    }

    .calculator-section {
        padding: var(--space-6);
    }

    .calculator-row {
        grid-template-columns: 80px 1fr auto auto auto;
        gap: var(--space-3);
        padding: var(--space-3) var(--space-4);
    }

    .calc-price {
        font-size: 0.75rem;
    }

    .calc-value-amount {
        font-size: 0.9375rem;
    }

    .total-amount {
        font-size: 2rem;
    }

    .cta-section {
        padding: var(--space-10) var(--space-6);
    }

    .cta-buttons {
        flex-direction: column;
        align-items: center;
    }

    .cta-button {
        width: 100%;
        max-width: 280px;
        justify-content: center;
    }
}

/* Mobile */
@media (max-width: 480px) {
    .site-title {
        font-size: 1.5rem;
    }

    .section-heading {
        font-size: 0.75rem;
    }

    .price-grid {
        grid-template-columns: 1fr 1fr;
    }

    .price-card {
        padding: var(--space-4);
    }

    .karat-label {
        font-size: 0.875rem;
    }

    .price-value {
        font-size: 1.125rem;
    }

    .calculator-row {
        grid-template-columns: 1fr;
        gap: var(--space-3);
        text-align: center;
        padding: var(--space-4);
    }

    .calc-karat-label {
        justify-content: center;
    }

    .calc-input-group {
        max-width: 180px;
        margin: 0 auto;
    }

    .calc-price {
        justify-content: center;
    }

    .calc-equals {
        display: none;
    }

    .calc-value {
        text-align: center;
        background: rgba(201, 162, 39, 0.05);
        padding: var(--space-3);
        border-radius: var(--radius-sm);
    }

    .calc-value-amount {
        font-size: 1.125rem;
    }

    .total-section {
        padding: var(--space-6);
    }

    .total-amount {
        font-size: 1.75rem;
    }

    .cta-heading {
        font-size: 1.375rem;
    }
}

/* Print Styles */
@media print {
    body {
        background: white;
        color: black;
    }

    .price-card {
        border: 1px solid #ccc;
    }

    .cta-section,
    .footer {
        display: none;
    }

    .site-title,
    .total-amount {
        -webkit-text-fill-color: #c9a227;
        color: #c9a227;
    }
}

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