/**
 * Calendar & Timeline Wizard — wizard chrome.
 *
 * Styles the wizard UI only. The calendar preview itself is styled by the
 * shared runtime stylesheet (cw-calendar.css) that Tabulizer's front-end
 * renderer also loads, so nothing here may leak into it.
 */

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

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

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

/* Content hidden visually but available to assistive technology. */
.cwz-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. */
.cwz-wizard a:focus,
.cwz-wizard button:focus,
.cwz-wizard input:focus,
.cwz-wizard select:focus,
.cwz-wizard textarea:focus {
    outline: 3px solid #1d4ed8;
    outline-offset: 2px;
}

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

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

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

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

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

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

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

.cwz-progress-step > a,
.cwz-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;
}

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

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

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

.cwz-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;
}

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

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

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

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

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

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

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

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

.cwz-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;
}

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

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

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

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

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

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

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

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

.cwz-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. */
.cwz-step2-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

.cwz-required {
    color: #b91c1c;
}

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

.cwz-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;
}

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

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

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

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

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

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

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

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

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

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

.cwz-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;
}

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

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

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

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

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

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

.cwz-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;
}

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

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

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

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

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

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

.cwz-grid-remove {
    color: #b91c1c;
    font-weight: 800;
    background: none;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    padding: 2px 9px;
    cursor: pointer;
    line-height: 1.4;
}

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

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

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

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

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

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

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

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

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

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

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

.cwz-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) {
    .cwz-wizard *,
    .cwz-wizard *::before,
    .cwz-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. */
.cwz-actions-reorder {
    flex-direction: row-reverse;
}

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

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

.cwz-row-thumb {
    display: block;
    width: 56px;
    height: 40px;
    object-fit: cover;
    border-radius: 3px;
    background: #e5e7eb;
}

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

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

.cwz-browse {
    flex: 0 0 auto;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    background: #f3f4f6;
    padding: 4px 10px;
    cursor: pointer;
    line-height: 1.4;
}

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

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

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

/* ---------------------------------------------------------------------------
   Calendar-specific wizard chrome
   --------------------------------------------------------------------------- */

/* Step 1 — family filter (progressive enhancement, hidden without script) */

.cwz-family-filter {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 16px 0 0;
}

.cwz-family-label {
    font-weight: 600;
    color: #4b5563;
}

.cwz-family-btn {
    border: 2px solid #d1d5db;
    border-radius: 999px;
    background: #ffffff;
    color: #1f2937;
    padding: 5px 16px;
    cursor: pointer;
    font: inherit;
    margin-right: 4px;
}

.cwz-family-btn:hover {
    border-color: #93c5fd;
}

.cwz-family-btn[aria-pressed="true"] {
    background: #1d4ed8;
    border-color: #1d4ed8;
    color: #ffffff;
}

.cwz-family-btn:focus-visible {
    outline: 3px solid #1d4ed8;
    outline-offset: 2px;
}

/* Step 1 — the family label on each card */

.cwz-template-family {
    display: inline-block;
    margin-top: 2px;
    padding: 1px 10px;
    border-radius: 999px;
    background: #e5e7eb;
    color: #374151;
    font-size: 0.75em;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Step 2 — contrast report */

.cwz-contrast-report {
    margin-top: 10px;
}

.cwz-contrast-line {
    margin: 2px 0;
    padding-left: 22px;
    position: relative;
    font-size: 0.9em;
}

.cwz-contrast-line::before {
    position: absolute;
    left: 0;
    top: 0;
    font-weight: 800;
}

.cwz-contrast-line.is-ok {
    color: #15803d;
}

.cwz-contrast-line.is-ok::before {
    content: "\2713";
}

.cwz-contrast-line.is-low {
    color: #b45309;
}

.cwz-contrast-line.is-low::before {
    content: "\26A0";
}

/* Step 2 — inline action row under a fieldset */

.cwz-actions-inline {
    margin-top: 10px;
}

/* Step 2 — monospaced data entry */

.cwz-code {
    font-family: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
    font-size: 0.88em;
    line-height: 1.5;
    white-space: pre;
    overflow-wrap: normal;
    overflow-x: auto;
}

/* The preview pane holds a live calendar, which needs room and can scroll. */

.cwz-preview-pane .cwz-preview-box {
    min-height: 320px;
}

.cwz-preview-box .cw-root {
    display: block;
}

/* 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. */
.cwz-wizard [hidden],
.cwz-wizard[hidden] {
    display: none !important;
}
