/* UI/UX pass: additive layer loaded after styles.css. Brand colours/fonts unchanged. */

/* Contrast: light-theme muted text was #888 (3.5:1); #666 gives >=5:1 on white. */
[data-theme="light"] {
    --color-text-muted: #666666;
    --ux-ring: #8B7209;
}
:root { --ux-ring: #D4AF37; --ux-error: #f87171; }
[data-theme="light"] { --ux-error: #b91c1c; }

/* Focus: one consistent, visible ring for keyboard users. */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 2px solid var(--ux-ring);
    outline-offset: 2px;
}
.gf-input:focus-visible, .form-group input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline-offset: 0;
}

.skip-link {
    position: fixed; top: 0.5rem; left: 0.5rem; z-index: 10000;
    padding: 0.6rem 1rem; border-radius: var(--radius-md);
    background: var(--color-primary); color: var(--color-text-inverse);
    font-weight: 600; text-decoration: none;
    transform: translateY(-200%);
}
.skip-link:focus { transform: none; }

/* Buttons: clear hover/active/disabled/busy states. */
.btn { transition: transform .15s ease, box-shadow .15s ease, background-color .15s ease, border-color .15s ease, opacity .15s ease; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled, .btn[aria-busy="true"] { opacity: .6; cursor: not-allowed; }
.btn[aria-busy="true"] { cursor: progress; }

/* Forms: inline validation. */
.field-error {
    display: block; margin-top: .35rem;
    color: var(--ux-error); font-size: .85rem; line-height: 1.35;
}
.field-error:empty { display: none; }
html [aria-invalid="true"][aria-invalid="true"] { border-color: var(--ux-error) !important; box-shadow: 0 0 0 1px var(--ux-error); }
[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--ux-error) 25%, transparent) !important; }
.form-group label, .gf-field label { font-weight: 500; }

/* Empty / loading states: visible block instead of bare grey text. */
.empty-state {
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-bg-card);
    font-size: .95rem;
}
td.empty-state { border: 0; background: transparent; }
@keyframes ux-pulse { 50% { opacity: .55; } }
.empty-state[data-i18n="loading"], .empty-state[aria-busy="true"] { animation: ux-pulse 1.4s ease-in-out infinite; }

/* Toasts: readable and not clipped on phones. */
.toast-container { max-width: min(100vw - 2rem, 380px); }
@media (max-width: 480px) { .toast-container { left: 1rem; right: 1rem; max-width: none; } }

/* Touch targets and mobile navigation. */
@media (max-width: 768px) {
    .menu-toggle, .sidebar-close, .landing-menu-btn { min-width: 44px; min-height: 44px; }
    .sidebar-nav a, .sidebar-nav button, .landing-links a { min-height: 44px; }
    input, select, textarea { font-size: 16px; } /* stops iOS zoom on focus */
}
.landing-links.open a { padding-block: .75rem; }

/* Landing hierarchy: consistent section rhythm. */
.landing-section h2 { text-wrap: balance; letter-spacing: -.01em; }
.landing-section > .landing-container > p, .landing-section-sub { max-width: 60ch; margin-inline: auto; }

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


/* ============ Organizer screens ============ */
.form-hint { color: var(--color-text-muted); font-size: .85rem; margin: 0 0 .75rem; }
small.form-hint { display: block; margin: .35rem 0 0; }

/* Guests: count + readable table; cards on phones (labels come from data-label). */
.guests-count { margin: 0 0 .5rem; color: var(--color-text-secondary); font-size: .9rem; }
.guests-count:empty { display: none; }
.guest-tags-cell { max-width: 160px; font-size: .8rem; }
td.empty-state span { font-size: .875rem; }
.status-badge { white-space: nowrap; }
.data-table thead th { position: sticky; top: 0; z-index: 1; background: var(--color-bg-medium); }

@media (max-width: 640px) {
    #guests-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    #guests-table, #guests-table tbody { display: block; }
    #guests-table tr {
        display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem .75rem;
        padding: .85rem 1rem; margin-bottom: .75rem;
        border: 1px solid var(--color-border); border-radius: var(--radius-lg);
        background: var(--color-bg-card);
    }
    #guests-table td { display: block; padding: 0; border: 0; font-size: .9rem; }
    #guests-table td::before {
        content: attr(data-label); display: block;
        color: var(--color-text-muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em;
    }
    #guests-table td.guest-name-cell, #guests-table td.actions-cell, #guests-table td.guest-tags-cell { grid-column: 1 / -1; }
    #guests-table td:nth-child(6) { grid-column: 1 / -1; }
    #guests-table td.guest-name-cell { font-size: 1.05rem; }
    #guests-table td.guest-name-cell::before, #guests-table td.actions-cell::before { display: none; }
    #guests-table td.guest-tags-cell:empty, #guests-table td.guest-tags-cell { max-width: none; }
    #guests-table td.actions-cell { display: flex; gap: .25rem; justify-content: flex-end; border-top: 1px solid var(--color-border); padding-top: .5rem; }
    #guests-table td.actions-cell .btn { min-width: 44px; min-height: 44px; }
    #guests-table tr:has(> td.empty-state) { display: block; text-align: center; }
    #guests-table td.empty-state::before { display: none; }
}

/* Check-in: big, clear tap targets; status shown as text, not colour alone. */
.checkin-progress { margin: 0 0 1rem; }
.checkin-progress[hidden] { display: none; }
.checkin-progress-bar { height: 8px; border-radius: 999px; background: var(--color-bg-light); overflow: hidden; }
.checkin-progress-bar span { display: block; height: 100%; width: 0; background: var(--color-success); transition: width .4s ease; }
.checkin-progress p { margin: .35rem 0 0; font-size: .85rem; color: var(--color-text-secondary); }
.checkin-search input { min-height: 52px; font-size: 1.05rem; }
.guest-result { min-height: 72px; gap: .75rem; flex-wrap: wrap; }
.guest-result-info { flex: 1 1 0; min-width: 0; }
.guest-result-table { align-self: center; }
.guest-result:focus-visible { outline: 2px solid var(--ux-ring); outline-offset: 2px; }
.guest-result-status { margin-left: auto; font-size: .85rem; font-weight: 600; white-space: nowrap; }
.guest-result-status.is-tap { color: var(--color-text-muted); font-weight: 500; }
.guest-result-status.is-done { color: var(--color-success); }
.guest-result.checked-in { opacity: .85; }
.checkin-hint { text-align: center; padding: 2rem 1rem; color: var(--color-text-secondary); }
.checkin-hint.is-loading { animation: ux-pulse 1.4s ease-in-out infinite; }
@media (max-width: 480px) {
    .guest-result { flex-direction: row; align-items: center; gap: .5rem .75rem; }
    .guest-result-status { flex-basis: 100%; margin-left: 0; text-align: right; }
    .guest-result-name { font-size: 1.05rem; }
}
@media (hover: none) { .guest-result:hover { transform: none; } }


/* ============ Dashboard ============ */
.stat-card { flex-wrap: wrap; }
.stat-card-progress { flex-basis: 100%; height: 6px; border-radius: 999px; background: var(--color-bg-light); overflow: hidden; margin-top: .25rem; }
.stat-card-progress span { display: block; height: 100%; width: 0; background: var(--color-success); transition: width .5s ease; }
.stat-card-value { font-variant-numeric: tabular-nums; }
.dashboard-section h3 { text-transform: uppercase; letter-spacing: .05em; font-size: .8rem; }
.recent-checkins .checkin-item { gap: .75rem; }
@media (hover: none) { .stat-card:hover { transform: none; } }


/* ============ Accessibility / mobile / performance pass ============ */
/* Never let a view be wider than the screen (logs, settings, site, messages, plans overflowed at 360px). */
.main-content, .view, .view-header, .settings-grid { min-width: 0; max-width: 100%; }
.view-header h1 { overflow-wrap: anywhere; }
.settings-grid { padding-inline: 0; }
.table-container { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Touch targets: inline links ignore min-height, so make them boxes. */
.landing-links a { display: inline-flex; align-items: center; min-height: 44px; }
.landing-brand, .theme-switch { min-height: 44px; display: inline-flex; align-items: center; }
.rsvp-foot a, .k-foot a, .landing-footer a { display: inline-block; padding: .75rem .5rem; }
@media (max-width: 768px) {
    .filter-input, .filter-select, .gf-input, .gf-select, .btn-small, .guests-search-input { min-height: 44px; }
    .btn-small { min-width: 44px; }
    .seating-toolbar .btn, #seating-zoom-in, #seating-zoom-out { min-width: 44px; min-height: 44px; }
}

/* Performance: skip rendering of below-the-fold landing sections until needed. */
@supports (content-visibility: auto) {
    .landing-section:not(#features):not(.landing-hero) { content-visibility: auto; contain-intrinsic-size: auto 700px; }
}

/* width/height attributes reserve space (no layout shift); CSS sets the display height. */
:where(.gf-deco) { width: auto; } /* zero specificity: landing-deco.css width rules still win */
.landing-empty { grid-column: 1 / -1; text-align: center; padding: 2rem 1rem; }
