/* ============================================================
   BASE.CSS — Shared foundation for all pages
   Design tokens, reset, typography, header, footer, nav dots,
   forms, content containers, animations, and global responsive.
   ============================================================ */

/* --- Design Tokens --- */
:root {
    /* Spacing scale */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    --space-3xl: 4rem;

    /* Colors */
    --color-primary: #42e3f5;
    --color-accent: #8affa4;
    --color-bg: #000000;
    --color-bg-subtle: #1a1a1a;
    --color-text: #f0f0f0;
    --color-text-muted: #888888;
    --color-text-dark: #111111;
    --color-text-dark-subtle: #333333;
    --color-white: #ffffff;
    --color-border-subtle: rgba(255, 255, 255, 0.1);
    --color-border-light: rgba(255, 255, 255, 0.3);

    /* Layout */
    --max-width: 1100px;
    --header-height: 60px;
    --footer-height: 90px;
    --content-width: 90%;
    --border-radius-sm: 10px;
    --border-radius-md: 20px;
    --border-radius-lg: 25px;

    /* Fluid typography */
    --font-size-base: clamp(0.9375rem, 0.9rem + 0.15vw, 1rem);
    --font-size-sm: clamp(0.8rem, 0.75rem + 0.15vw, 0.9rem);
    --font-size-md: clamp(0.9rem, 0.85rem + 0.2vw, 0.95rem);
    --font-size-lg: clamp(1.2rem, 1rem + 0.5vw, 1.4rem);
    --font-size-xl: clamp(1.4rem, 1.1rem + 0.8vw, 1.8rem);
    --font-size-2xl: clamp(1.6rem, 1.3rem + 1vw, 2rem);
    --font-size-h2-card: clamp(1.2rem, 1rem + 0.5vw, 1.6rem);
}

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

/* --- Scrollbar Hiding (all pages) --- */
html::-webkit-scrollbar,
body::-webkit-scrollbar {
    display: none;
}

html, body {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

/* --- Base Typography --- */
html {
    scroll-behavior: smooth;
    font-size: var(--font-size-base);
}

body {
    font-family: 'Poppins', sans-serif;
    line-height: 1.6;
    color: var(--color-text);
    background-color: var(--color-bg);
    overflow-x: hidden;
    position: relative;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color 0.3s ease;
}
a:hover {
    color: var(--color-accent);
}

h2 {
    font-size: var(--font-size-xl);
    font-weight: 600;
    margin-bottom: 1em;
    line-height: 1.3;
}

p {
    margin-bottom: 1em;
}

strong {
    font-weight: 600;
}

/* --- Layout Container --- */
.container {
    max-width: var(--max-width);
    width: 100%;
    margin: 0 auto;
    padding: 0 clamp(15px, 4vw, 30px);
    position: relative;
    z-index: 2;
}

/* --- Overlay Header ---
   No backdrop-filter here: on iOS Safari, `position: fixed` + `backdrop-filter`
   desyncs from the scroll compositor during momentum scroll and leaves a ghost
   of the header mid-page. A gradient gives us legibility without the GPU
   sampling cost, and translate3d keeps the header on its own layer. */
.overlay-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    padding: clamp(10px, 2vw, 15px) 0;
    z-index: 10;
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0.75) 0%,
        rgba(0, 0, 0, 0.55) 60%,
        rgba(0, 0, 0, 0) 100%
    );
    transform: translate3d(0, 0, 0);
    -webkit-transform: translate3d(0, 0, 0);
    will-change: transform;
}

.overlay-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: clamp(8px, 1.5vw, 15px);
}

.main-title {
    font-size: clamp(1.1rem, 0.9rem + 0.5vw, 1.4rem);
    font-weight: 600;
    color: var(--color-white);
    display: flex;
    align-items: center;
    white-space: nowrap;
}

.title-logo {
    height: clamp(22px, 3vw, 28px);
    width: auto;
    margin-right: clamp(6px, 1vw, 10px);
}

.jp-chars {
    font-weight: normal;
    font-size: 0.8em;
    color: #aaaaaa;
    margin-left: 8px;
}

/* --- Navigation Buttons --- */
.overlay-nav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: clamp(6px, 1vw, 10px);
}

.overlay-nav a.nav-button {
    color: var(--color-white);
    border: 1.5px solid var(--color-white);
    padding: clamp(5px, 1vw, 8px) clamp(10px, 2vw, 18px);
    border-radius: var(--border-radius-md);
    font-size: var(--font-size-sm);
    font-weight: 500;
    text-decoration: none;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.overlay-nav a.nav-button:hover {
    background-color: var(--color-white);
    color: var(--color-bg);
    border-color: var(--color-white);
}

.overlay-nav a.nav-button.current {
    background-color: rgba(255, 255, 255, 0.8);
    color: var(--color-bg);
    border-color: rgba(255, 255, 255, 0.8);
}

/* --- Refresh Particles Button --- */
.refresh-icon {
    vertical-align: middle;
    margin: 0;
    transition: transform 0.3s ease;
}

#reset-particles:hover .refresh-icon {
    transform: rotate(180deg);
}

/* --- Navigation Dropdown --- */
.nav-dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background-color: var(--color-white);
    border-radius: var(--border-radius-md);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    padding: var(--space-sm) 0;
    /* Size to the longest label DELIBERATELY, and never past the screen edge.
       Left to shrink-to-fit, the box came out exactly as wide as the longest
       item and no wider — measured at 268.92px against an item wanting 269px.
       With zero slack, any browser whose Poppins metrics run a few pixels wide
       (Safari against Chrome) pushed "Rent Calculator: Lease Tracker" into the
       `overflow: hidden` below, which cut it off mid-word. */
    width: max-content;
    min-width: 240px;
    max-width: min(360px, calc(100vw - 2rem));
    z-index: 1000;
    margin-top: var(--space-xs);
    overflow: hidden; /* keeps item hover backgrounds inside the rounded corners */
}

.nav-dropdown:hover .dropdown-menu {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    color: var(--color-text-dark);
    text-decoration: none;
    font-size: var(--font-size-sm);
    font-weight: 500;
    transition: background-color 0.2s ease, color 0.2s ease;
    border: none;
    border-radius: 0;
    /* Wrap, never clip. `width: max-content` already keeps every label on one
       line at any normal size; this only decides what happens if the max-width
       above ever binds on a narrow screen, and a folded label beats a cut one. */
    white-space: normal;
}

.dropdown-icon {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    flex-shrink: 0;
}

.dropdown-item:hover {
    background-color: #f5f5f5;
    color: var(--color-text-dark);
}

.dropdown-toggle {
    position: relative;
}

.dropdown-toggle::after {
    content: "▾";
    font-size: 0.8em;
    margin-left: var(--space-xs);
    transition: transform 0.2s ease;
}

.nav-dropdown:hover .dropdown-toggle::after {
    transform: rotate(180deg);
}

/* --- Shared Header Basic Styles --- */
header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 999;
    background-color: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    padding: var(--space-md) var(--space-lg);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header .text-logo {
    color: var(--color-white);
    font-size: var(--font-size-lg);
    font-weight: 600;
}

header nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    gap: var(--space-lg);
}

header nav ul li {
    position: relative;
}

header nav ul li > a {
    color: var(--color-white);
    text-decoration: none;
    font-weight: 500;
    font-size: var(--font-size-sm);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--border-radius-md);
    transition: background-color 0.3s ease;
}

header nav ul li > a:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* --- Footer --- */
#footer {
    position: relative;
    z-index: 2;
    background-color: var(--color-bg);
}

#footer footer {
    padding: var(--space-xl) 0;
    background-color: var(--color-bg-subtle);
    text-align: center;
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    border-top: 1px solid #333333;
    width: 100%;
    position: relative;
    z-index: 3;
}

#footer footer .container {
    flex-direction: column;
    gap: var(--space-sm);
    align-items: center;
}

#footer footer p {
    margin-bottom: 0;
    color: var(--color-text-muted);
    padding: 0 var(--space-md);
}

#footer footer .container p:first-of-type {
    margin-bottom: 1em;
}

#footer footer nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

#footer footer nav ul li {
    display: flex;
    align-items: center;
}

#footer footer nav ul li + li::before {
    content: "|";
    margin: 0 var(--space-sm);
    color: #666666;
    font-weight: 300;
}

#footer footer nav ul li a {
    color: #aaaaaa;
    white-space: nowrap;
}

#footer footer nav ul li a:hover {
    color: var(--color-primary);
}

#footer footer nav.footer-links {
    margin-top: var(--space-sm);
}

/* --- Navigation Dots --- */
.nav-dots {
    position: fixed;
    top: 50%;
    right: clamp(8px, 2vw, 25px);
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: clamp(8px, 1.5vw, 18px);
    z-index: 11;
}

.nav-dot {
    display: block;
    width: clamp(6px, 1vw, 12px);
    height: clamp(6px, 1vw, 12px);
    background-color: var(--color-border-light);
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.2s ease;
    border: 1px solid var(--color-border-subtle);
}

.nav-dot:hover {
    background-color: rgba(255, 255, 255, 0.6);
    transform: scale(1.1);
}

.nav-dot.active {
    background-color: var(--color-white);
    transform: scale(1.2);
    border-color: rgba(255, 255, 255, 0.5);
}

/* --- Store Badges --- */
.store-badge {
    height: clamp(32px, 5vw, 40px);
    width: auto;
    display: inline-block;
    transition: transform 0.2s ease;
}

.store-badge:hover {
    transform: scale(1.05);
}

/* --- Content Container (translucent overlay pages) --- */
.content-section.translucent-overlay {
    padding: clamp(20px, 4vw, 40px) clamp(10px, 3vw, 20px);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

.content-container {
    max-width: 900px;
    width: min(92%, 900px);
    padding: clamp(20px, 4vw, 40px);
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    border-radius: var(--border-radius-md);
    color: var(--color-white);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--color-border-subtle);
    margin: clamp(50px, 8vw, 80px) auto clamp(20px, 4vw, 40px);
    max-height: none;
    overflow: visible;
}

.content-container h1 {
    font-size: var(--font-size-2xl);
    margin-bottom: var(--space-xl);
    text-align: center;
    color: var(--color-white);
}

.content-container h2 {
    margin-top: var(--space-xl);
    margin-bottom: var(--space-md);
    font-size: clamp(1.2rem, 1rem + 0.5vw, 1.5rem);
    color: var(--color-white);
}

.content-container h3 {
    margin-top: var(--space-lg);
    margin-bottom: var(--space-sm);
    font-size: clamp(1.1rem, 0.95rem + 0.4vw, 1.3rem);
    color: var(--color-white);
}

.content-container h4 {
    margin-top: var(--space-lg);
    margin-bottom: var(--space-sm);
    font-size: clamp(1rem, 0.9rem + 0.3vw, 1.1rem);
    color: var(--color-white);
}

.content-container p {
    margin-bottom: var(--space-md);
    line-height: 1.6;
    font-size: var(--font-size-md);
}

.content-container a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color 0.3s ease;
    word-break: break-word;
}

.content-container a:hover {
    color: var(--color-accent);
    text-decoration: underline;
}

.content-container ul {
    padding-left: var(--space-lg);
    margin-bottom: var(--space-lg);
}

.content-container ul li {
    margin-bottom: var(--space-sm);
    font-size: var(--font-size-md);
}

/* --- Forms (shared base) --- */
.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    margin-bottom: clamp(15px, 2.5vw, 20px);
}

.form-group label {
    font-weight: 500;
    font-size: var(--font-size-sm);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: clamp(10px, 1.5vw, 14px) clamp(12px, 2vw, 16px);
    border-radius: 8px;
    border: 1px solid #ddd;
    background-color: #f8f8f8;
    font-family: 'Poppins', sans-serif;
    font-size: var(--font-size-base);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
}

.form-group textarea {
    resize: vertical;
}

.form-message {
    padding: var(--space-md) 0;
    font-weight: 500;
}

/* --- Newsletter signup (shared, sits above the footer) --- */
#footer .newsletter {
    position: relative;
    z-index: 3;
    background-color: var(--color-bg);
    border-top: 1px solid var(--color-border-subtle);
    padding: var(--space-2xl) 0;
}

#footer .newsletter-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-xl);
}

#footer .newsletter-copy {
    flex: 1 1 280px;
}

#footer .newsletter-copy h2 {
    font-size: var(--font-size-xl);
    color: var(--color-white);
    margin-bottom: var(--space-xs);
}

#footer .newsletter-copy p {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    max-width: 46ch;
    margin: 0;
}

#footer .newsletter-form {
    flex: 1 1 340px;
    max-width: 480px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-sm);
}

#footer .newsletter-form input[type="email"] {
    flex: 1 1 200px;
    min-width: 0;
    padding: clamp(10px, 1.5vw, 14px) clamp(12px, 2vw, 16px);
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--color-border-light);
    background-color: rgba(255, 255, 255, 0.06);
    color: var(--color-text);
    font-family: 'Poppins', sans-serif;
    font-size: var(--font-size-base);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

#footer .newsletter-form input[type="email"]::placeholder {
    color: var(--color-text-muted);
}

#footer .newsletter-form input[type="email"]:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(66, 227, 245, 0.2);
}

#footer .newsletter-submit {
    flex: 0 0 auto;
    padding: clamp(10px, 1.5vw, 14px) var(--space-xl);
    border: none;
    border-radius: var(--border-radius-sm);
    background-color: var(--color-primary);
    color: var(--color-text-dark);
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    font-size: var(--font-size-base);
    cursor: pointer;
    transition: transform 0.2s ease, background-color 0.3s ease, opacity 0.3s ease;
}

#footer .newsletter-submit:hover {
    transform: translateY(-2px);
    background-color: var(--color-accent);
}

#footer .newsletter-submit:disabled {
    opacity: 0.6;
    cursor: default;
    transform: none;
}

/* Honeypot field — visually and semantically hidden, but still submittable. */
#footer .newsletter-hp {
    position: absolute !important;
    left: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

#footer .newsletter-status {
    flex: 1 1 100%;
    min-height: 1.2em;
    margin: 0;
    padding: 0;
    font-size: var(--font-size-sm);
    font-weight: 500;
}

#footer .newsletter-status.is-success {
    color: var(--color-accent);
}

#footer .newsletter-status.is-error {
    color: #ff8a8a;
}

@media (max-width: 768px) {
    #footer .newsletter-inner {
        flex-direction: column;
        align-items: stretch;
        /* In a column, `space-between` spreads the copy and the form to the
           two ends of whatever height the section has. Stack them instead and
           let `gap` be the only thing between them. */
        justify-content: flex-start;
        text-align: center;
        gap: var(--space-lg);
    }

    /* THE ONE THAT BROKE IT. `flex: 1 1 280px` and `flex: 1 1 340px` are
       written for the row layout above, where the basis is a WIDTH. Flipping
       the container to a column turns both into HEIGHTS — measured at 410px
       wide, the two-line copy block claimed 280px and the form claimed 340px,
       which is where the enormous gaps came from: a wrapping flex container
       given more height than its content spreads its lines to fill it. On a
       phone both should simply be as tall as what is in them. */
    #footer .newsletter-copy,
    #footer .newsletter-form {
        flex: 0 0 auto;
    }

    #footer .newsletter-copy p {
        margin: 0 auto;
    }

    #footer .newsletter-form {
        max-width: none;
    }

    #footer .newsletter-form input[type="email"],
    #footer .newsletter-submit {
        flex: 0 0 auto;
        width: 100%;
    }
}

/* --- Image / Trademark Grid --- */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr));
    gap: clamp(12px, 2vw, 20px);
    margin-top: var(--space-xl);
    width: 100%;
}

.image-item {
    text-align: center;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius-sm);
    padding: clamp(10px, 2vw, 15px);
    transition: transform 0.2s ease, background-color 0.3s ease;
}

.image-item:hover {
    transform: translateY(-5px);
    background-color: rgba(255, 255, 255, 0.15);
}

.image-item img {
    width: clamp(80px, 15vw, 120px);
    height: clamp(80px, 15vw, 120px);
    object-fit: contain;
    margin: 0 auto var(--space-md);
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: var(--border-radius-sm);
    padding: var(--space-sm);
}

.image-item p {
    margin: 0;
    font-weight: 500;
    font-size: var(--font-size-sm);
}

/* --- Privacy Policy --- */
.effective-date {
    font-style: italic;
    margin-bottom: var(--space-lg);
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
}

/* --- Scroll Animations --- */
.observe-me {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.observe-me.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* --- Background Fallback (shown while p5.js canvas loads) --- */
#bg-fallback {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    background-color: #000000;
    background-image: url('/assets/images/background.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: opacity 0.8s ease-out;
    transform: translate3d(0, 0, 0);
    -webkit-transform: translate3d(0, 0, 0);
}

#bg-fallback.hidden {
    opacity: 0;
    pointer-events: none;
}

@media (max-width: 768px) {
    #bg-fallback {
        background-image: url('/assets/images/background_mobile.png');
    }
}

/* --- p5.js Canvas (used on most pages) --- */
@keyframes canvas-fallback-reveal {
    to { opacity: 1; }
}

#defaultCanvas0 {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    opacity: 0;
    transition: opacity 1.2s ease-in;
    animation: canvas-fallback-reveal 0s 4s forwards;
    transform: translate3d(0, 0, 0);
    -webkit-transform: translate3d(0, 0, 0);
}

#defaultCanvas0.canvas-ready {
    animation: none;
    opacity: 1;
}

/* --- Global Responsive --- */
@media (max-width: 768px) {
    :root {
        --header-height: 90px;
    }

    .overlay-header .container {
        justify-content: center;
    }

    #footer footer nav ul {
        flex-wrap: nowrap;
    }
}
