/*
 * RosaGres pool configurator — visual design.
 *
 * Theme: porcelain specimen board. The sidebar is a glaze-white card over
 * the full-bleed 3D pool. Two material accents encode the two domains:
 *   --clay  (fired terracotta)  -> everything about tiles
 *   --agua  (glaze teal)        -> everything about water
 */

:root {
    --porcelain: #f7f3ec;   /* card background: glaze white */
    --bone: #efe8dd;        /* inset / hover surfaces */
    --ink: #33291f;         /* fired-umber text */
    --ink-soft: #7d7061;    /* secondary text */
    --clay: #a64b2a;        /* terracotta accent: tile domain */
    --clay-deep: #7e3a21;
    --agua: #2e7f8f;        /* glaze teal accent: water domain */
    --line: #dcd2c3;        /* hairlines */
    --radius: 14px;
}

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

body {
    font: 14px/1.45 "Segoe UI", -apple-system, "Helvetica Neue", Arial, sans-serif;
    background: #000;
    color: var(--ink);
    overflow: hidden;
}

/* The WebGL canvas fills the viewport behind the UI */
canvas {
    position: absolute;
    top: 0;
    left: 0;
    touch-action: none;
}

button {
    font: inherit;
    color: inherit;
    background: none;
    border: 0;
    cursor: pointer;
}

:focus-visible {
    outline: 2px solid var(--clay);
    outline-offset: 2px;
}

/* The hidden attribute must beat any author display value (e.g. the
   chip grid's display: grid), so make it explicit. */
[hidden] {
    display: none !important;
}

/* ------------------------------------------------------------------ */
/* Sidebar: floating porcelain card                                    */
/* ------------------------------------------------------------------ */

#sidebar {
    position: absolute;
    top: 16px;
    left: 16px;
    bottom: 16px;
    width: 304px;
    display: flex;
    flex-direction: column;
    background: var(--porcelain);
    border-radius: var(--radius);
    box-shadow: 0 12px 40px rgba(0, 0, 0, .45);
    overflow-y: auto;
    overscroll-behavior: contain;
    z-index: 10;
}

#sidebar section {
    padding: 18px 20px;
    border-top: 1px solid var(--line);
}

/* Brand header: kiln-stamp wordmark with a clay maker's mark */
#brand {
    padding: 22px 20px 16px;
}

#brand h1 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 19px;
    font-weight: 300;
    letter-spacing: .32em;
}

#brand .mark,
#loading-overlay .mark {
    width: 11px;
    height: 11px;
    background: var(--clay);
    flex: none;
}

#brand p {
    margin-top: 4px;
    padding-left: 21px;
    font-size: 12px;
    color: var(--ink-soft);
}

.eyebrow {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--ink-soft);
    margin-bottom: 12px;
}

/* ------------------------------------------------------------------ */
/* Suelos: the specimen board                                          */
/* ------------------------------------------------------------------ */

#floor-section {
    flex: 1;
}

.line + .line {
    border-top: 1px solid var(--line);
}

.line-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 9px 2px;
    text-align: left;
}

.line-header:hover .line-name {
    color: var(--clay-deep);
}

.line-name {
    font-weight: 600;
}

.line-count {
    font-size: 11px;
    color: var(--ink-soft);
    background: var(--bone);
    border-radius: 9px;
    padding: 1px 8px;
}

.line-header[aria-expanded="true"] .line-count {
    color: #fff;
    background: var(--clay);
}

.chip-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 4px 2px 14px;
}

/* A colorway chip: square photo like a physical tile sample */
.chip {
    position: relative;
    border-radius: 6px;
    padding: 0;
    text-align: center;
}

.chip img {
    display: block;
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    border-radius: 6px;
    border: 2px solid transparent;
    box-shadow: inset 0 0 0 1px rgba(51, 41, 31, .18), 0 1px 2px rgba(51, 41, 31, .25);
    transition: transform .15s ease;
}

.chip:hover img {
    transform: translateY(-2px);
}

.chip-name {
    display: block;
    font-size: 11px;
    color: var(--ink-soft);
    padding-top: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Selected chip: clay stamp in the corner */
.chip.active img {
    border-color: var(--clay);
}

.chip.active .chip-name {
    color: var(--clay-deep);
    font-weight: 600;
}

.chip.active::after {
    content: '';
    position: absolute;
    top: 5px;
    right: 5px;
    width: 10px;
    height: 10px;
    background: var(--clay);
    border-radius: 2px;
    box-shadow: 0 0 0 2px var(--porcelain);
}

/* Loading a colorway: soft pulse over the photo */
.chip.loading img {
    animation: chip-pulse 1s ease-in-out infinite;
}

@keyframes chip-pulse {
    50% { opacity: .45; }
}

.chip.failed .chip-name {
    color: var(--clay);
}

.chip.failed .chip-name::after {
    content: ' — error';
}

/* ------------------------------------------------------------------ */
/* Agua: glaze-drop presets + free picker                              */
/* ------------------------------------------------------------------ */

#water-presets {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.swatch {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid rgba(51, 41, 31, .2);
    /* glaze highlight */
    background-image: radial-gradient(circle at 32% 28%, rgba(255, 255, 255, .55), rgba(255, 255, 255, 0) 45%);
    transition: transform .15s ease;
}

.swatch:hover {
    transform: scale(1.12);
}

.swatch.active {
    border-color: var(--agua);
    box-shadow: 0 0 0 2px var(--porcelain), 0 0 0 4px var(--agua);
}

.custom-color {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
    font-size: 13px;
    color: var(--ink-soft);
    cursor: pointer;
}

#water-color-input {
    width: 44px;
    height: 30px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--bone);
    cursor: pointer;
}

/* ------------------------------------------------------------------ */
/* Estado del agua: segmented control (water domain -> agua accent)    */
/* ------------------------------------------------------------------ */

#agitation-buttons {
    display: flex;
    background: var(--bone);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 3px;
}

.segment {
    flex: 1;
    padding: 6px 0;
    font-size: 13px;
    border-radius: 6px;
    color: var(--ink-soft);
}

.segment.active {
    background: var(--agua);
    color: #fff;
    font-weight: 600;
}

/* ------------------------------------------------------------------ */
/* Extras                                                              */
/* ------------------------------------------------------------------ */

.toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
}

.toggle input {
    position: absolute;
    opacity: 0;
}

.toggle .track {
    width: 34px;
    height: 20px;
    border-radius: 10px;
    background: var(--line);
    position: relative;
    transition: background .15s ease;
    flex: none;
}

.toggle .track::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .3);
    transition: left .15s ease;
}

.toggle input:checked + .track {
    background: var(--clay);
}

.toggle input:checked + .track::after {
    left: 16px;
}

.toggle input:focus-visible + .track {
    outline: 2px solid var(--clay);
    outline-offset: 2px;
}

/* ------------------------------------------------------------------ */
/* Chrome: hint, loading, errors, mobile drawer                        */
/* ------------------------------------------------------------------ */

#hint {
    position: absolute;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(51, 41, 31, .82);
    color: #f7f3ec;
    font-size: 12px;
    padding: 8px 10px 8px 16px;
    border-radius: 20px;
    z-index: 10;
    white-space: nowrap;
}

#hint-close {
    font-size: 15px;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 50%;
    color: inherit;
}

#hint-close:hover {
    background: rgba(255, 255, 255, .15);
}

#loading-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: #0d0b09;
    color: #b9ac9b;
    z-index: 30;
    transition: opacity .4s ease;
}

#loading-overlay .mark {
    animation: mark-spin 1.2s ease-in-out infinite;
}

@keyframes mark-spin {
    50% { transform: rotate(135deg) scale(1.25); }
    100% { transform: rotate(270deg); }
}

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

#error-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(420px, calc(100vw - 40px));
    background: var(--porcelain);
    border-radius: var(--radius);
    padding: 26px 28px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
    z-index: 40;
}

#error-panel h2 {
    font-size: 17px;
    margin-bottom: 10px;
}

#error-panel p {
    margin-bottom: 10px;
    color: var(--ink-soft);
}

#error-panel .error-message {
    color: var(--clay-deep);
}

#error-panel .error-retry {
    margin-top: 4px;
    background: var(--clay);
    color: #fff;
    padding: 8px 18px;
    border-radius: 8px;
    font-weight: 600;
}

#error-panel .error-retry:hover {
    background: var(--clay-deep);
}

/* Hamburger: hidden on desktop */
#menu-toggle {
    display: none;
    position: absolute;
    top: 14px;
    left: 14px;
    z-index: 20;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    background: var(--porcelain);
    box-shadow: 0 4px 16px rgba(0, 0, 0, .4);
}

#menu-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--ink);
    margin: 3px auto;
    border-radius: 1px;
}

@media (max-width: 700px) {
    #menu-toggle {
        display: block;
    }

    #sidebar {
        top: 0;
        left: 0;
        bottom: 0;
        width: min(304px, 86vw);
        border-radius: 0 var(--radius) var(--radius) 0;
        transform: translateX(-105%);
        transition: transform .25s ease;
    }

    body.sidebar-open #sidebar {
        transform: translateX(0);
    }

    /* Clear the hamburger, which floats above the drawer's top-left corner */
    #brand {
        padding-left: 66px;
    }

    #brand p {
        padding-left: 0;
    }

    #hint {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
    }
}
