:root {
    --bg-color: #fbfbfd;
    --surface-color: #ffffff;
    --text-primary: #1d1d1f;
    --text-secondary: #86868b;
    --border-color: #d2d2d7;
    --primary-color: #000000;
    --primary-hover: #333333;
    --radius-lg: 16px;
    --radius-md: 10px;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.08);
    --shadow-lg: 0 12px 32px rgba(0,0,0,0.08);
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Navbar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 4rem;
    background-color: var(--bg-color);
    width: 100%;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
    font-size: 1.25rem;
    letter-spacing: -0.02em;
}

.logo img {
    height: 44px;
    width: auto;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-primary);
    margin-left: 2rem;
    font-size: 0.9rem;
    font-weight: 400;
    transition: color 0.2s;
}

.nav-links a:hover {
    color: var(--text-secondary);
}

.cart-btn {
    font-weight: 500 !important;
}

/* Main Layout */
.container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 1rem 4rem 2rem;
}

.content-split {
    display: grid;
    grid-template-columns: 1.45fr 1fr;
    gap: 4rem;
    align-items: start;
    /* No forced min-height: previously this stretched the row to nearly the
     * full viewport, which pushed the title down (visually) and left a lot of
     * dead space under the viewer. Let the row size itself to its content. */
}

/* 3D Viewer */
.viewer-section {
    position: relative;
    width: 100%;
    min-width: 0;
    aspect-ratio: 1 / 1;
    background-color: var(--surface-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

#canvas-container,
#frame-image-view {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    overflow: hidden;
    transition: opacity 0.2s ease;
}

/* Default: 3D preview is active, frame image hidden but kept in the DOM. */
#frame-image-view {
    opacity: 0;
    pointer-events: none;
}
.viewer-section.show-frame #canvas-container {
    opacity: 0;
    pointer-events: none;
}
.viewer-section.show-frame #frame-image-view {
    opacity: 1;
    pointer-events: auto;
}

.frame-detail-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Viewer column: the square render + a pill toggle beneath it. Moved out of
 * .viewer-section so the toggle never overlaps the 3D frame.
 */
.viewer-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.9rem;
    min-width: 0;
}

.viewer-column .viewer-section {
    width: 100%;
}

/* Pill toggle sitting below the render. Inline-flex so it shrinks to fit its
 * labels exactly; the labels themselves are nowrap so "Frame Detail" can't
 * break onto a second line on narrow viewports.
 */
.view-toggle {
    display: inline-flex;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    padding: 0.22rem;
    box-shadow: var(--shadow-sm);
}

.view-toggle-btn {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    padding: 0.38rem 1.1rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.view-toggle-btn.active {
    background: var(--text-primary);
    color: var(--surface-color);
}

/* Details Section */
.details-section {
    display: flex;
    flex-direction: column;
    /* No top padding — let the h1 sit at the same y as the top of the
     * viewer in the left column rather than 2rem below it. */
    min-width: 0;
}

.product-header {
    margin-bottom: 1.5rem;
}

.product-header h1 {
    font-size: 2.5rem;
    font-weight: 600;
    letter-spacing: -0.03em;
    margin-bottom: 0.5rem;
}

.price {
    font-size: 1.25rem;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Compact spec row directly under the price. Each spec is its own <li>
 * marked `white-space: nowrap`, so a wrap can only happen between specs —
 * never mid-phrase. The flex container with `flex-wrap: wrap` handles the
 * row breaks. Dividers are `::after` on each non-last item so they stay
 * glued to their phrase on the previous line when wrapping (trailing dot)
 * rather than orphaning at the start of the next line (leading dot). */
.product-specs {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    list-style: none;
    margin: 0.75rem 0 0.25rem;
    padding: 0;
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.45;
    color: var(--text-secondary);
}

.product-specs li {
    white-space: nowrap;
}

.product-specs li:not(:last-child)::after {
    content: "·";
    color: var(--border-color);
    padding: 0 0.55rem;
}

/* When JS detects that an item is the last visible spec on its row (the
 * next spec wrapped to a new line), this class hides the trailing dot —
 * it's no longer dividing two things side-by-side, so it'd just be visual
 * noise. `visibility: hidden` instead of `display: none` keeps the dot's
 * width in the layout, otherwise removing it would let more content fit
 * and re-wrap, causing oscillation. */
.product-specs li.spec-row-end::after {
    visibility: hidden;
}

.description {
    font-size: 1.05rem;
    color: var(--text-secondary);
    margin-top: 2.5rem;
    margin-bottom: 2.5rem;
    line-height: 1.6;
}

/* Section subtitle above the explanatory copy. Sized between the price
 * (1.25rem) and the body so it reads as a real section heading without
 * competing with the h1 product title above. */
.description-heading {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    margin-bottom: 0.6rem;
}

/* Spacing between the explanation paragraphs (previously hard-coded inline
 * on the second <p>). */
.description p + p {
    margin-top: 1rem;
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 3rem 2rem;
    text-align: center;
    margin-bottom: 2rem;
    transition: var(--transition);
    background-color: var(--surface-color);
    cursor: pointer;
}

.upload-area:hover, .upload-area.dragover {
    border-color: var(--text-secondary);
    background-color: #f5f5f7;
}

.upload-icon {
    width: 48px;
    height: 48px;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.upload-content h3 {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.upload-content p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}

.hidden-input {
    display: none;
}

.image-preview {
    width: 100%;
    max-height: 250px;
    object-fit: cover;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
    display: none;
}

/* Buttons */
.btn {
    padding: 0.8rem 1.5rem;
    border-radius: 999px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    font-family: inherit;
}

.primary-btn {
    background-color: var(--primary-color);
    color: white;
    width: 100%;
    padding: 1.2rem;
    font-size: 1.1rem;
}

.primary-btn:hover:not(:disabled) {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.primary-btn:disabled {
    background-color: var(--border-color);
    cursor: not-allowed;
    color: #ffffff;
}

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

.secondary-btn:hover {
    border-color: var(--text-primary);
    background-color: #f5f5f7;
}

/* Pre-launch reservation form. Sits above the upload-area in DOM order so
 * that when the backend returns a design and JS sets display:block, it pops
 * in directly above the dropzone — the bottom margin keeps it from touching
 * the upload-area's dashed border. */
#reserveBlock {
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background-color: var(--surface-color);
}

.reserve-heading {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 0.4rem;
}

.reserve-subtext {
    font-size: 0.92rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.reserve-email {
    width: 100%;
    padding: 0.85rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
    background-color: #fff;
    transition: var(--transition);
}

.reserve-email:focus {
    outline: none;
    border-color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.reserve-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
    font-size: 0.88rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.reserve-error {
    margin-top: 0.5rem;
    min-height: 1.1em;
    color: #c0392b;
    font-size: 0.88rem;
}

#reserveBlock .primary-btn {
    margin-top: 0.75rem;
}

.reserve-legal {
    margin-top: 0.75rem;
    font-size: 0.78rem;
    color: var(--text-secondary);
    text-align: center;
}

.reserve-legal a {
    color: var(--text-secondary);
    text-decoration: underline;
}

.reserve-success h3 {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.reserve-success p {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.reserve-success #reserveSuccessEmail {
    color: var(--text-primary);
    font-weight: 500;
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: opacity 0.3s;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 992px) {
    .content-split {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    
    .container {
        padding: 2rem;
    }

    .navbar {
        padding: 1.5rem 2rem;
    }
}

@media (max-width: 600px) {
    .container {
        padding: 1rem;
    }
    
    .navbar {
        padding: 1rem;
    }
    
    .nav-links a {
        margin-left: 1rem;
    }
}

/* Cropper.js Overrides */
.cropper-container,
.cropper-container img {
    -webkit-touch-callout: none !important;
    -webkit-user-drag: none !important;
    user-select: none !important;
    -webkit-user-select: none !important;
}

.cropper-modal {
    background-color: transparent !important;
    opacity: 0 !important;
}

/* Dim only the uncropped portion of the image */
.cropper-canvas img {
    filter: brightness(0.65) !important;
    opacity: 1 !important;
}

.cropper-view-box img {
    filter: brightness(1) !important;
    opacity: 1 !important;
}

.blurred-processing {
    filter: blur(4px) grayscale(50%);
    opacity: 0.7;
    pointer-events: none;
    transition: var(--transition);
}

/* Legal text above buy button */
.terms-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 0.75rem;
}

.terms-text a {
    color: var(--primary-color);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.terms-text a:hover {
    color: var(--text-secondary);
}

/* Footer */
.site-footer {
    border-top: 1px solid var(--border-color);
    padding: 3rem 4rem;
    margin-top: 4rem;
    background-color: var(--surface-color);
}
.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    margin-right: 2rem;
    font-size: 0.9rem;
    transition: var(--transition);
}
.footer-links a:hover {
    color: var(--text-primary);
}
.site-footer p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

@media (max-width: 600px) {
    .footer-content {
        flex-direction: column;
        gap: 1.5rem;
        text-align: center;
    }
    .footer-links a {
        margin: 0 1rem;
    }
    .site-footer {
        padding: 2rem 1rem;
    }
}
