/* Wave Maker - workspace left, controls right (Pattern Maker layout) */

/* Landing page: dress the start card with a wave band along its bottom
   edge (the intro card only - not the related-tools cards, which live in
   .tool-content wrappers) */
.app-intro:not(.tool-content) > .gn-card {
    position: relative;
    overflow: hidden;
}

.app-intro:not(.tool-content) > .gn-card .card-body {
    position: relative;
    z-index: 1;
    padding-bottom: 7rem !important;
}

.app-intro:not(.tool-content) > .gn-card::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 90px;
    pointer-events: none;
    background-size: 100% 100%;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1440 320' preserveAspectRatio='none'%3E%3Cpath d='M0 150 C 180 110 360 210 560 185 C 780 158 960 90 1170 120 C 1300 139 1390 170 1440 150 L 1440 320 L 0 320 Z' fill='%2323a6ed' opacity='0.55'/%3E%3Cpath d='M0 205 C 200 170 400 245 640 225 C 880 205 1040 150 1240 175 C 1340 187 1410 205 1440 195 L 1440 320 L 0 320 Z' fill='%232485ec' opacity='0.75'/%3E%3Cpath d='M0 260 C 220 235 420 290 660 272 C 900 254 1080 225 1260 245 C 1350 255 1415 268 1440 262 L 1440 320 L 0 320 Z' fill='%232563eb'/%3E%3C/svg%3E");
}

.wm-app {
    position: relative;
    display: flex;
    height: 100%;
    overflow: hidden;
}

/* Stage (left): the composed wave preview fills the whole workspace */
.wm-stage {
    position: relative;
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    background-color: var(--gn-card-bg);
}

.wm-frame {
    position: relative;
    width: 100%;
    height: 100%;
}

.wm-frame-boxed {
    border: 1px solid var(--gn-card-border);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

/* Pixel-size chip shown in exact-size preview */
.wm-frame-size {
    position: absolute;
    left: 50%;
    bottom: 0.5rem;
    transform: translateX(-50%);
    padding: 0.125rem 0.5rem;
    border-radius: 1rem;
    background-color: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-size: 0.7rem;
    white-space: nowrap;
    pointer-events: none;
}

.wm-svg {
    display: block;
    width: 100%;
    height: 100%;
}

/* Transparent mode: classic checkerboard behind the waves */
.wm-frame.wm-transparent {
    background-color: #fff;
    background-image: repeating-conic-gradient(#dfdfdf 0% 25%, #ffffff 0% 50%);
    background-size: 20px 20px;
}

/* Controls panel (right); header/body/footer layout comes from the shared
   .app-side-* classes in css/common.css */
.wm-panel {
    flex: 0 0 300px;
    border-left: 1px solid var(--gn-card-border);
}

.wm-label {
    font-size: 0.8rem;
    color: var(--gn-muted);
    margin-bottom: 0;
    margin-top: 0.5rem;
    display: block;
}

/* Tuck the slider closer to its label + value row */
.wm-app .form-range {
    margin-top: -2px;
}

/* Previous/next style buttons share the select's border color */
.wm-style-nav {
    border: 1px solid var(--bs-border-color);
    color: var(--gn-muted);
    background: none;
}

.wm-style-nav:hover {
    border-color: var(--bs-border-color);
    background-color: var(--gn-sidebar-hover-bg);
    color: var(--gn-accent);
}

.wm-val {
    float: right;
    color: var(--gn-accent);
    font-size: 0.75rem;
}

.wm-sep {
    margin: 0.75rem 0;
    border-color: var(--gn-card-border);
    opacity: 1;
}

/* Colors row, palette picker and background picker styles come from the
   shared components (apps/_lib/components.js + .gn-* in css/common.css) */

.wm-check {
    padding-top: 0.25rem;
}

/* Extra breathing room above a checkbox that follows a segmented control
   (the Stacked toggle under Direction) */
.wm-check-roomy {
    margin-top: 0.5rem;
}

/* Segmented controls (color direction + direction): a pill thumb that
   glides to the checked option. The thumb is one option wide; --seg-index
   (set by the app) translates it in whole option-widths. */
.wm-seg {
    position: relative;
    display: grid;
    grid-template-columns: repeat(var(--seg-count, 4), 1fr);
    padding: 3px;
    margin-top: 0.25rem;
    background-color: var(--gn-sidebar-hover-bg);
    border: 1px solid var(--gn-card-border);
    border-radius: 0.5rem;
}

/* The real radios stay for keyboard and screen-reader use */
.wm-seg-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.wm-seg > label {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 0.35rem 0.25rem;
    border-radius: 0.4rem;
    cursor: pointer;
    color: var(--gn-muted);
    font-size: 0.65rem;
    line-height: 1;
    text-align: center;
}

.wm-seg > label .bi {
    font-size: 1rem;
    line-height: 1;
}

/* Text-only segments (Layer fill) get a slightly larger, vertically
   centered label */
.wm-seg-text-lg {
    font-size: 0.75rem;
    padding: 0.35rem 0;
}

.wm-seg-input:checked + label {
    color: var(--gn-accent);
}

.wm-seg-input:focus-visible + label {
    outline: 2px solid var(--gn-accent);
    outline-offset: -2px;
}

.wm-seg-thumb {
    position: absolute;
    top: 3px;
    bottom: 3px;
    left: 3px;
    width: calc((100% - 6px) / var(--seg-count, 4));
    transform: translateX(calc(var(--seg-index, 0) * 100%));
    background-color: var(--gn-card-bg);
    border: 1px solid var(--gn-card-border);
    border-radius: 0.4rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
    transition: transform 0.18s ease;
}

/* Live two-color swatch inside the color-direction options */
.wm-swatch {
    display: block;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.2);
}

/* Floating round save button on the stage (Pattern Maker style) */
.wm-fab-wrap {
    position: absolute;
    right: 1rem;
    bottom: 1rem;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

.wm-fab {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.2);
    background-color: #fff;
    color: #2b2d42;
    font-size: 1.125rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
    transition: transform 0.1s, border-color 0.15s, color 0.15s;
}

.wm-fab:hover {
    border-color: var(--gn-accent);
    color: var(--gn-accent);
}

.wm-fab:active {
    transform: scale(0.95);
}

/* The aspect fab sits top-right; its menu opens below the button. The wrap
   is capped to the stage height so the menu can never overflow it: the
   aspect list scrolls while the exact-size toggle stays pinned below it */
.wm-aspect-wrap {
    bottom: auto;
    top: 1rem;
    max-height: calc(100% - 2rem);
}

.wm-fab-menu {
    display: flex;
    flex-direction: column;
    min-width: 170px;
    min-height: 0;
    padding: 0.25rem;
    background-color: var(--gn-card-bg);
    border: 1px solid var(--gn-card-border);
    border-radius: 0.5rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.wm-menu-scroll {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow-y: auto;
}

.wm-fab-menu.d-none {
    display: none;
}

.wm-fab-menu button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.75rem;
    background: none;
    border: 0;
    border-radius: 0.375rem;
    color: var(--gn-body-color);
    font-size: 0.875rem;
    text-align: left;
    white-space: nowrap;
}

.wm-fab-menu button:hover {
    background-color: var(--gn-sidebar-hover-bg);
}

/* Check mark only on the selected entry */
.wm-fab-menu button .bi {
    color: var(--gn-accent);
    visibility: hidden;
}

.wm-fab-menu button.active .bi {
    visibility: visible;
}

.wm-fab-menu button:disabled {
    color: var(--gn-muted);
    opacity: 0.55;
}

.wm-menu-sep {
    margin: 0.25rem 0.5rem;
    border-color: var(--gn-card-border);
    opacity: 1;
}

/* Save modal: centered card over a dimmed backdrop, inside the app area so
   it works in fullscreen too */
.wm-modal {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background-color: rgba(0, 0, 0, 0.45);
}

.wm-modal.d-none {
    display: none;
}

.wm-modal-card {
    display: flex;
    flex-direction: column;
    width: min(440px, 100%);
    max-height: 100%;
    background-color: var(--gn-card-bg);
    border: 1px solid var(--gn-card-border);
    border-radius: 0.75rem;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.wm-modal-header {
    display: flex;
    align-items: center;
    padding: 0.625rem 1rem;
    border-bottom: 1px solid var(--gn-card-border);
}

.wm-modal-title {
    font-weight: 600;
}

/* On short screens the body scrolls; header and footer stay in view */
.wm-modal-body {
    padding: 0.5rem 1rem 0.75rem;
    min-height: 0;
    overflow-y: auto;
}

.wm-modal-footer {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--gn-card-border);
}

/* Rows that do not apply to the current format keep their space (the modal
   never jumps in size); visibility also removes them from the tab order */
.wm-invisible {
    visibility: hidden;
}

/* All note variants are stacked in the same grid cell: the container is
   always as tall as the longest one, so the modal never jumps in size */
.wm-modal-note-stack {
    display: grid;
}

.wm-modal-note-stack > .wm-modal-note {
    grid-area: 1 / 1;
}

.wm-note-sizer {
    visibility: hidden;
}

.wm-modal-note {
    font-size: 0.75rem;
    color: var(--gn-muted);
    margin: 0.625rem 0 0;
}

.wm-size-input {
    max-width: 110px;
}

.wm-size-x {
    color: var(--gn-muted);
}

/* Small screens: stack, with the preview pinned at the top so the waves
   stay visible while dragging sliders in the controls below */
@media (max-width: 767px) {
    .wm-app {
        flex-direction: column;
        overflow-y: auto;
    }

    .wm-stage {
        position: sticky;
        top: 0;
        z-index: 4;
        flex: 0 0 auto;
        height: 40vh;
    }

    .wm-panel {
        flex: 0 0 auto;
        border-left: 0;
        border-top: 1px solid var(--gn-card-border);
    }

    /* The whole app container scrolls instead of the panel body; the
       style header sticks right below the preview and the action
       footer sticks to the bottom edge */
    .wm-panel .app-side-body {
        overflow-y: visible;
    }

    .wm-panel .app-side-header {
        position: sticky;
        top: 40vh;
        z-index: 3;
        background-color: var(--gn-card-bg);
    }

    .wm-panel .app-side-footer {
        position: sticky;
        bottom: 0;
        z-index: 3;
        background-color: var(--gn-card-bg);
    }
}
