/* Global Styles */
:root {
    --primary-gold: #D4AF37;
    --primary-accent: #f9d976;
    --bg-dark: #121212;
    --bg-card: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-bg: rgba(255, 255, 255, 0.03);
    --text-primary: #f0f0f0;
    --text-muted: #a0a0a0;
    --font-main: 'Outfit', sans-serif;
    --font-heading: 'Playfair Display', serif;
    --gold-gradient: linear-gradient(45deg, #D4AF37, #f9d976, #dfbd69, #926d15);
}

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-dark);
    color: var(--text-primary);
    overflow-x: hidden;
    line-height: 1.6;
}

/* Loader */
.loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-dark);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.golden-spinner {
    width: 80px;
    height: 80px;
    border: 4px solid var(--glass-border);
    border-top: 4px solid var(--primary-gold);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Navigation */
.navbar {
    position: fixed;
    top: 0;
    width: 100%;
    padding: 1.5rem 0;
    z-index: 1000;
    backdrop-filter: blur(15px);
    background-color: rgba(18, 18, 18, 0.7);
    border-bottom: 1px solid var(--glass-border);
    transition: all 0.3s ease;
}

.navbar.scrolled {
    padding: 0.8rem 0;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-weight: 800;
    font-size: 1.5rem;
    cursor: pointer;
}

.phi-symbol {
    font-size: 2.22rem; /* Golden Ratio proportions? Not quite, but feels good */
    background: var(--gold-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-family: var(--font-heading);
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.nav-links a {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.nav-links a:hover {
    color: var(--primary-gold);
}

/* Hero Section */
.hero-section {
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
    text-align: center;
    padding: 0 2rem;
}

.hero-content {
    position: relative;
    z-index: 2;
    max-width: 900px;
}

.hero-bg-spiral {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 150%;
    height: 150%;
    background-image: url('images/hero_bg_spiral.svg');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    opacity: 0.15;
    animation: rotateHero 60s linear infinite;
    pointer-events: none;
}

@keyframes rotateHero {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

h1.glitch {
    font-family: var(--font-heading);
    font-size: 5rem;
    font-weight: 800;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    position: relative;
}

.subtitle {
    font-size: 1.4rem;
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto 3rem;
    font-weight: 300;
}

.cta-button {
    display: inline-flex;
    align-items: center;
    gap: 0.8rem;
    background: var(--gold-gradient);
    color: #000;
    padding: 1.2rem 2.8rem;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.1rem;
    box-shadow: 0 10px 40px rgba(212, 175, 55, 0.3);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.cta-button:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 15px 50px rgba(212, 175, 55, 0.5);
}

/* General Layout */
.section {
    padding: 6rem 2rem 4rem; /* Adjusted: top 6rem, sides 2rem, bottom 4rem */
    position: relative;
}

.dark-section {
    background: linear-gradient(180deg, #121212 0%, #0a0a0c 100%);
}

.glass-section {
    background: radial-gradient(circle at 10% 20%, rgba(212, 175, 55, 0.05) 0%, transparent 40%);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4rem;
    align-items: center;
}

.text-center {
    text-align: center;
}

.section-tag {
    display: inline-block;
    padding: 0.5rem 1.2rem;
    background: var(--glass-bg);
    border: 1px solid var(--primary-gold);
    color: var(--primary-gold);
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 2rem;
}

h2 {
    font-family: var(--font-heading);
    font-size: 3.5rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

p {
    font-size: 1.15rem;
    margin-bottom: 1.5rem;
    color: var(--text-muted);
}

.max-w-700 {
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}

/* Info Elements */
.formula-box {
    margin-top: 3rem;
    padding: 2.5rem;
    border-radius: 24px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    display: inline-block;
    font-size: 2rem;
    color: var(--primary-gold);
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.featured-img {
    width: 100%;
    border-radius: 24px;
    box-shadow: 0 30px 80px rgba(0,0,0,0.5);
    border: 1px solid var(--glass-border);
    transition: transform 0.5s ease;
}

.featured-img:hover {
    transform: scale(1.02);
}

/* Gallery Section */
.section-header {
    text-align: center;
    margin-bottom: 5rem;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 2.5rem;
}

.gallery-item {
    position: relative;
    border-radius: 24px;
    overflow: hidden;
    height: 450px;
    border: 1px solid var(--glass-border);
    transition: all 0.5s ease;
    cursor: pointer;
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.7s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.item-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 3rem 2rem;
    background: linear-gradient(0deg, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.5) 60%, transparent 100%);
    color: #fff;
    transform: translateY(20px);
    opacity: 0;
    transition: all 0.5s ease;
}

.gallery-item:hover img {
    transform: scale(1.1) rotate(2deg);
}

.gallery-item:hover .item-overlay {
    transform: translateY(0);
    opacity: 1;
}

.item-overlay h3 {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
    color: var(--primary-gold);
}

.gallery-item:hover {
    box-shadow: 0 20px 60px rgba(212, 175, 55, 0.2);
    transform: translateY(-10px);
}

/* Curiosità & Math Cards */
.curiosita-card {
    padding: 4rem;
    border-radius: 32px;
    background: var(--glass-bg);
    border: 1px solid var(--primary-gold);
    max-width: 800px;
    margin: 4rem auto 0;
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-style: italic;
    color: var(--text-primary);
    position: relative;
    overflow: hidden;
}

.curiosita-card::before {
    content: "“";
    position: absolute;
    top: -20px;
    left: 40px;
    font-size: 8rem;
    color: var(--primary-gold);
    opacity: 0.3;
}

/* Math-specific card override */
.matematica .curiosita-card {
    padding: 2.5rem;
    font-style: normal;
    font-size: 1.1rem;
    font-family: var(--font-main);
}

.matematica .curiosita-card::before {
    display: none;
}

.matematica .curiosita-card h3 {
    font-family: var(--font-heading);
    color: var(--primary-gold);
    font-size: 1.8rem;
    margin-bottom: 1rem;
}

/* Featured Calculation Box */
.featured-calculation {
    grid-column: 1 / -1; /* Make it span full width in the grid */
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.1), rgba(212, 175, 55, 0.05));
    border: 2px solid var(--primary-gold);
    padding: 3rem !important;
    margin-top: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.featured-calculation h3 {
    font-size: 2.22rem !important;
    margin-bottom: 2rem !important;
}

.segment-diagram {
    width: 100%;
    max-width: 600px;
    margin: 2rem 0;
}

.segment-line {
    height: 4px;
    background: var(--text-muted);
    position: relative;
    margin: 40px 0;
    border-radius: 2px;
}

.segment-part {
    position: absolute;
    height: 100%;
    background: var(--primary-gold);
    border-radius: 2px;
}

.segment-label {
    position: absolute;
    top: -30px;
    font-family: var(--font-heading);
    font-weight: bold;
    color: var(--primary-gold);
}

.segment-brace {
    position: absolute;
    bottom: -15px;
    height: 10px;
    border: 2px solid var(--glass-border);
    border-top: none;
}

/* Footer */
.footer {
    padding: 6rem 2rem;
    background: #050505;
    text-align: center;
    border-top: 1px solid var(--glass-border);
}

.footer-logo {
    width: 100px;
    margin-bottom: 2rem;
    filter: invert(1);
}

.credits {
    margin-top: 2rem;
    font-size: 0.9rem;
    letter-spacing: 1px;
}

/* Glass Utility */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
}

/* Responsiveness */
@media (max-width: 968px) {
    h1.glitch { font-size: 3.5rem; }
    h2 { font-size: 2.5rem; }
    .grid-2 { grid-template-columns: 1fr; gap: 3rem; }
    .nav-links { display: none; }
    .hero-section { height: 80vh; }
}

@media (max-width: 480px) {
    h1.glitch { font-size: 2.5rem; }
    .subtitle { font-size: 1.1rem; }
}
