/**
 * Gallery Wizard — wizard chrome.
 *
 * Styles the wizard UI only. The gallery preview is styled entirely by
 * the CSS that gwz-render.js generates from the template specification, so
 * nothing here may leak into it.
 */

.gwz-wizard {
    max-width: 1180px;
    margin: 0 auto;
    color: #1f2937;
}

.gwz-wizard-title {
    font-size: 1.7em;
    font-weight: 700;
    margin: 0 0 6px;
}

.gwz-intro {
    margin: 0 0 20px;
    color: #4b5563;
}

/* Content hidden visually but available to assistive technology. */
.gwz-sr-only {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* A visible focus indicator on every interactive element. */
.gwz-wizard a:focus,
.gwz-wizard button:focus,
.gwz-wizard input:focus,
.gwz-wizard select:focus,
.gwz-wizard textarea:focus {
    outline: 3px solid #1d4ed8;
    outline-offset: 2px;
}

.gwz-wizard a:focus:not(:focus-visible),
.gwz-wizard button:focus:not(:focus-visible),
.gwz-wizard input:focus:not(:focus-visible),
.gwz-wizard select:focus:not(:focus-visible),
.gwz-wizard textarea:focus:not(:focus-visible) {
    outline: none;
}

.gwz-wizard a:focus-visible,
.gwz-wizard button:focus-visible,
.gwz-wizard input:focus-visible,
.gwz-wizard select:focus-visible,
.gwz-wizard textarea:focus-visible {
    outline: 3px solid #1d4ed8;
    outline-offset: 2px;
}

/* ---------------------------------------------------------------------------
   Step progress
   --------------------------------------------------------------------------- */

.gwz-progress {
    margin-bottom: 24px;
}

.gwz-progress-list {
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    overflow: hidden;
}

.gwz-progress-step {
    flex: 1 1 200px;
    border-right: 1px solid #d1d5db;
}

.gwz-progress-step:last-child {
    border-right: 0;
}

.gwz-progress-step > a,
.gwz-progress-step > span {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #f3f4f6;
    color: #4b5563;
    text-decoration: none;
    height: 100%;
    box-sizing: border-box;
}

.gwz-progress-step > a:hover {
    background: #e5e7eb;
    text-decoration: none;
}

.gwz-progress-step.is-current > a,
.gwz-progress-step.is-current > span {
    background: #1d4ed8;
    color: #ffffff;
}

.gwz-progress-step.is-done > a,
.gwz-progress-step.is-done > span {
    background: #dcfce7;
    color: #14532d;
}

.gwz-progress-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    flex-shrink: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, .16);
    font-weight: 700;
}

.gwz-progress-step.is-current .gwz-progress-number {
    background: rgba(255, 255, 255, .28);
}

.gwz-progress-step.is-done .gwz-progress-number {
    background: #15803d;
    color: #ffffff;
}

.gwz-progress-title {
    display: block;
    font-weight: 600;
}

.gwz-progress-sub {
    display: block;
    font-size: .82em;
    opacity: .85;
}

/* ---------------------------------------------------------------------------
   Step 1 — template chooser
   --------------------------------------------------------------------------- */

.gwz-template-fieldset {
    border: 0;
    margin: 0;
    padding: 0;
}

.gwz-template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 18px;
    margin: 16px 0 28px;
}

.gwz-template-radio {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.gwz-template-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 6px;
    height: 100%;
    padding: 24px 18px;
    border: 3px solid #e5e7eb;
    border-radius: 8px;
    background: #f9fafb;
    cursor: pointer;
    box-sizing: border-box;
}

.gwz-template-card:hover {
    border-color: #93c5fd;
    background: #f0f7ff;
}

.gwz-template-radio:checked + .gwz-template-card {
    border-color: #1d4ed8;
    background: #eff6ff;
}

/* The selection is marked by more than colour (WCAG 1.4.1). */
.gwz-template-radio:checked + .gwz-template-card::after {
    content: "\2713";
    display: inline-block;
    margin-top: 4px;
    font-weight: 800;
    color: #1d4ed8;
}

.gwz-template-radio:focus-visible + .gwz-template-card,
.gwz-template-radio:focus + .gwz-template-card {
    outline: 3px solid #1d4ed8;
    outline-offset: 3px;
}

.gwz-template-radio:focus:not(:focus-visible) + .gwz-template-card {
    outline: none;
}

.gwz-template-icon {
    display: block;
    width: 72px;
    height: 54px;
}

.gwz-template-icon svg {
    width: 100%;
    height: 100%;
}

.gwz-template-name {
    font-weight: 700;
}

.gwz-template-desc {
    font-size: .84em;
    color: #4b5563;
    line-height: 1.4;
}

/* ---------------------------------------------------------------------------
   Step 2 — layout
   --------------------------------------------------------------------------- */

/* One full-width column. The live preview belongs to Step 3, where it gets the
   whole page instead of competing with the settings for room. */
.gwz-step2-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
}

.gwz-preview-box {
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 12px;
    background: #ffffff;
    overflow-x: auto;
    min-height: 180px;
}

.gwz-preview-error {
    color: #b91c1c;
    font-weight: 600;
}

/* ---------------------------------------------------------------------------
   Forms
   --------------------------------------------------------------------------- */

.gwz-section {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px 20px 20px;
    margin: 0 0 20px;
    background: #ffffff;
}

.gwz-section-title {
    font-size: 1.02em;
    font-weight: 700;
    margin: 0 0 12px;
    padding: 0;
    color: #111827;
    border: 0;
    width: auto;
}

.gwz-grid-2,
.gwz-grid-3 {
    display: grid;
    gap: 0 20px;
}

.gwz-grid-2 {
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.gwz-grid-3 {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.gwz-field {
    margin-bottom: 14px;
}

.gwz-field > label {
    display: block;
    font-size: .88em;
    font-weight: 600;
    margin-bottom: 4px;
    color: #374151;
}

.gwz-field-check {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 8px;
    align-items: center;
}

.gwz-field-check input[type="checkbox"] {
    margin: 0;
    width: 17px;
    height: 17px;
}

.gwz-field-check > label {
    margin: 0;
    grid-column: 2;
}

.gwz-field-check .gwz-help {
    grid-column: 2;
}

.gwz-help {
    display: block;
    font-size: .8em;
    color: #6b7280;
    line-height: 1.45;
    margin-top: 3px;
}

.gwz-help code {
    font-size: .95em;
    word-break: break-all;
}

.gwz-error {
    color: #b91c1c;
    font-size: .85em;
    font-weight: 600;
    margin: 4px 0 0;
}

.gwz-required {
    color: #b91c1c;
}

.gwz-color-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.gwz-color-row input[type="color"] {
    width: 44px;
    height: 34px;
    padding: 2px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    background: #ffffff;
    cursor: pointer;
    flex-shrink: 0;
}

.gwz-color-text {
    max-width: 100px;
}

.gwz-range-label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 10px;
}

.gwz-range-value {
    font-weight: 700;
    color: #1d4ed8;
    font-size: .88em;
}

input[type="range"].gwz-range {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: #d1d5db;
    border-radius: 3px;
    cursor: pointer;
    margin: 6px 0;
}

input[type="range"].gwz-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #1d4ed8;
    cursor: pointer;
}

input[type="range"].gwz-range::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border: 0;
    border-radius: 50%;
    background: #1d4ed8;
    cursor: pointer;
}

.gwz-csv {
    font-family: "Courier New", monospace;
    font-size: .86em;
    white-space: pre;
    overflow-wrap: normal;
    overflow-x: auto;
}

/* Disabled dependent controls stay legible. */
.gwz-section input:disabled,
.gwz-section select:disabled {
    background: #f3f4f6;
    color: #6b7280;
}

/* ---------------------------------------------------------------------------
   Colour presets
   --------------------------------------------------------------------------- */

.gwz-palette-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.gwz-palette-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #ffffff;
    color: #374151;
    font-size: .86em;
    font-weight: 600;
    cursor: pointer;
}

.gwz-palette-btn:hover {
    border-color: #1d4ed8;
    background: #f0f7ff;
}

.gwz-palette-swatches {
    display: inline-flex;
    border-radius: 3px;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, .18);
}

.gwz-palette-swatches span {
    display: block;
    width: 14px;
    height: 14px;
}

.gwz-reset-btn {
    margin-inline-start: auto;
}

/* ---------------------------------------------------------------------------
   Data editor
   --------------------------------------------------------------------------- */

.gwz-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
}

.gwz-tab {
    padding: 7px 16px;
    border: 1px solid #d1d5db;
    border-radius: 6px 6px 0 0;
    background: #f3f4f6;
    color: #374151;
    font-size: .88em;
    font-weight: 600;
    cursor: pointer;
}

.gwz-tab[aria-selected="true"] {
    background: #1d4ed8;
    border-color: #1d4ed8;
    color: #ffffff;
}

.gwz-grid-scroll {
    overflow-x: auto;
    margin-bottom: 12px;
}

.gwz-data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .84em;
}

.gwz-data-table th,
.gwz-data-table td {
    border: 1px solid #d1d5db;
    padding: 6px 8px;
    text-align: left;
    vertical-align: middle;
}

.gwz-data-table thead th {
    background: #f3f4f6;
    font-weight: 700;
    white-space: nowrap;
}

.gwz-grid-input {
    width: 100%;
    min-width: 110px;
    font-size: 1em;
    padding: 4px 6px;
    box-sizing: border-box;
}

/* Fully self-styled: these sit inside the site's own page, so they must not
   depend on — or inherit — the template's .btn rules. */
.gwz-grid-remove {
    display: inline-block;
    width: auto;
    margin: 0;
    color: #b91c1c;
    font: inherit;
    font-weight: 800;
    background: none;
    background-image: none;
    box-shadow: none;
    text-transform: none;
    text-shadow: none;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    padding: 2px 9px;
    cursor: pointer;
    line-height: 1.4;
}

.gwz-grid-remove:hover {
    background: #fee2e2;
    border-color: #b91c1c;
}

/* ---------------------------------------------------------------------------
   Step 3
   --------------------------------------------------------------------------- */

.gwz-csv-strip {
    background: #1f2937;
    color: #e5e7eb;
    border-radius: 6px;
    padding: 8px 12px;
    margin-bottom: 12px;
    font-size: .84em;
    overflow-x: auto;
}

.gwz-csv-strip-label {
    display: block;
    font-size: .82em;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #9ca3af;
    margin-bottom: 3px;
}

.gwz-csv-strip code {
    color: #86efac;
    background: none;
    padding: 0;
    white-space: nowrap;
}

.gwz-annotations {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 10px;
    margin: 0 0 24px;
}

.gwz-annotation {
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 10px 12px;
    background: #f9fafb;
}

.gwz-annotation dt {
    display: flex;
    align-items: center;
    gap: 7px;
    font-weight: 700;
    margin-bottom: 3px;
}

.gwz-annotation dd {
    margin: 0;
    font-size: .84em;
    color: #4b5563;
    line-height: 1.45;
}

.gwz-annotation-swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, .18);
}

/* ---------------------------------------------------------------------------
   Actions
   --------------------------------------------------------------------------- */

.gwz-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px;
    padding-top: 20px;
    margin-top: 8px;
    border-top: 1px solid #e5e7eb;
}

/* Respect a reduced-motion preference throughout the wizard. */
@media (prefers-reduced-motion: reduce) {
    .gwz-wizard *,
    .gwz-wizard *::before,
    .gwz-wizard *::after {
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
    }
}

/* Next comes first in the DOM (so Enter submits it); show Previous first. */
.gwz-actions-reorder {
    flex-direction: row-reverse;
}

.gwz-actions-reorder .gwz-action-prev {
    margin-inline-end: auto;
}

/* ---------------------------------------------------------------------------
   Image grid extras
   --------------------------------------------------------------------------- */

/* min-width and max-width are both pinned: a template rule as ordinary as
   `img { max-width: 100% }` combined with a squeezed column collapsed this to
   zero width once the grid grew to eight columns. */
.gwz-row-thumb {
    display: block;
    width: 56px;
    min-width: 56px;
    max-width: none;
    height: 40px;
    object-fit: cover;
    border-radius: 3px;
    background: #e5e7eb;
}

/* Reserve room for the thumbnail and the remove button, so the six editable
   columns cannot squeeze them out. */
.gwz-data-table th:first-child,
.gwz-data-table td:first-child {
    width: 72px;
}

.gwz-data-table th:last-child,
.gwz-data-table td:last-child {
    width: 52px;
    text-align: center;
}

.gwz-image-cell {
    display: flex;
    gap: 6px;
    align-items: center;
}

.gwz-image-cell .gwz-grid-input {
    min-width: 180px;
}

.gwz-browse {
    flex: 0 0 auto;
    width: auto;
    margin: 0;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    background: #f3f4f6;
    background-image: none;
    box-shadow: none;
    color: #1f2937;
    font: inherit;
    text-transform: none;
    text-shadow: none;
    padding: 4px 10px;
    cursor: pointer;
    line-height: 1.4;
}

.gwz-browse:hover {
    background: #e5e7eb;
}

.gwz-media-modal .modal-body {
    padding: 0;
    max-height: 60vh;
    overflow: auto;
}

.gwz-media-frame {
    display: block;
    width: 100%;
    border: 0;
}

/* The hidden attribute must win. A template rule as ordinary as
   `.btn { display: inline-block }` out-specifies the browser default of
   `[hidden] { display: none }`, which leaves controls the wizard has
   deliberately hidden visible on the page and inert when clicked. */
.gwz-wizard [hidden],
.gwz-wizard[hidden] {
    display: none !important;
}
