/*
 * Shall We Dance? — Cells v2 type and components, with its own accent: the jade green of the
 * painting IMG_6692 instead of the portfolio's blue. Rectangular controls.
 * Spec: docs/design-exploration-2/cells-v2/DESIGN.md. Light theme only.
 * Controls are at least 44px high. Contrast (computed): white on action 5.96:1, action on paper 5.66:1,
 * action on soft 5.09:1, ink on soft 13.5:1. Change the tokens below to retune; keep text pairs >= 4.5:1.
 */

/* Self-hosted fonts (latin subset). The system stack is the fallback if the files fail to load. */
@font-face {
    font-family: 'Red Hat Display';
    src: url('fonts/red-hat-display-latin-wght-normal.woff2') format('woff2');
    font-weight: 300 900;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Red Hat Text';
    src: url('fonts/red-hat-text-latin-wght-normal.woff2') format('woff2');
    font-weight: 300 900;
    font-style: normal;
    font-display: swap;
}

:root {
    --paper: #f8f9fb;
    --surface: #ffffff;
    --ink: #1d2233;
    --muted: #4a5168;
    --action: #177060; /* deep jade from the painting (the exact pigment #1a7d6b is only 4.3:1 on the soft fill) */
    --action-hover: #0f5246;
    --on-action: #ffffff;
    --pigment: #348674; /* painting jade, decorative only (not for text) */
    --soft: #e3f0ec;
    --rule: #cde1d9;
    --danger: #b3261e;
    --radius-control: 4px;
    --radius-panel: 8px;
    --font-heading: 'Red Hat Display', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-body: 'Red Hat Text', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --touch: 44px;
}

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

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font: 400 16px/1.6 var(--font-body);
    background: var(--paper);
    color: var(--ink);
    min-height: 100vh;
}

a {
    color: inherit;
}

:focus-visible {
    outline: 3px solid var(--action);
    outline-offset: 3px;
}

::selection {
    background: var(--action);
    color: var(--on-action);
}

.skip-link {
    position: absolute;
    top: -48px;
    left: 0;
    background: var(--ink);
    color: var(--paper);
    padding: 12px 16px;
    text-decoration: none;
    z-index: 100;
}
.skip-link:focus {
    top: 0;
}

#app {
    max-width: 720px;
    margin: 0 auto;
    padding: 0 16px 48px;
}

/* Header */
header {
    padding: 16px 0 8px;
}
header h1 {
    font: 700 31px/1.1 var(--font-heading);
    letter-spacing: -0.02em;
}
header .subtitle,
.subtitle {
    margin-top: 2px;
    font-size: 16px;
    color: var(--muted);
}

/* Scope note under the title: the app covers Paris only for now */
.scope-note {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    font-weight: 600;
    color: var(--ink);
}
.scope-note svg {
    flex: none;
    color: var(--action);
}

/* Install guide: a compact card under the header; steps open for first-time visitors */
.install-guide {
    margin: 12px 0 4px;
    background: var(--soft);
    border: 2px solid var(--action);
    border-radius: var(--radius-panel);
}
.install-guide summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: var(--touch);
    padding: 0 16px;
    font: 600 16px/1.2 var(--font-body);
    color: var(--ink);
    cursor: pointer;
    list-style: none;
}
.install-guide summary::-webkit-details-marker {
    display: none;
}
.install-guide summary::after {
    content: '';
    flex: none;
    width: 10px;
    height: 10px;
    margin-right: 4px;
    border-right: 2px solid var(--action);
    border-bottom: 2px solid var(--action);
    transform: translateY(-2px) rotate(45deg);
}
.install-guide[open] summary::after {
    transform: translateY(2px) rotate(-135deg);
}
.guide-body {
    display: grid;
    gap: 12px;
    padding: 0 16px 16px;
}
.guide-platform-title {
    font-weight: 700;
}
.guide-steps {
    display: grid;
    gap: 8px;
    margin-top: 4px;
    padding-left: 24px;
}
.guide-steps svg {
    vertical-align: -3px;
    color: var(--action);
}
.guide-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.app-footer {
    display: flex;
    justify-content: center;
    padding-top: 24px;
}

/* Screen-reader-only text */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* Period bar scrolls away; the toolbar below it (filters + view) is sticky */
.period-bar {
    padding: 8px 0;
}
.toolbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: grid;
    gap: 8px;
    padding: 4px 0;
    background: var(--paper);
    border-bottom: 1px solid var(--rule);
}
.toolbar-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.date-picker-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}
#datePicker {
    min-height: var(--touch);
    padding: 0 12px;
    font: 400 16px var(--font-body);
    color: var(--ink);
    background: var(--surface);
    border: 2px solid var(--muted);
    border-radius: var(--radius-control);
}
#datePicker:hover {
    border-color: var(--ink);
}
#datePicker:focus-visible {
    border-color: var(--action);
}

/* Segmented control: one pill outline, the active segment is filled */
.segmented {
    display: inline-flex;
    border: 2px solid var(--action);
    border-radius: var(--radius-control);
    overflow: hidden;
    background: var(--surface);
}
.seg,
.seg-label span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--touch);
    padding: 0 16px;
    font: 600 16px/1 var(--font-body);
    color: var(--action);
    background: transparent;
    border: 0;
    cursor: pointer;
    transition:
        background-color 140ms ease,
        color 140ms ease;
}
.seg + .seg,
.seg-label + .seg-label {
    border-left: 2px solid var(--action);
}
.seg:hover,
.seg-label:hover span {
    background: var(--soft);
}
.seg.active,
.seg-label input:checked + span {
    background: var(--action);
    color: var(--on-action);
}
.seg.active:hover,
.seg-label input:checked:hover + span {
    background: var(--action-hover);
}
.seg:focus-visible {
    outline: 3px solid var(--action);
    outline-offset: 2px;
}
.seg-label {
    display: inline-flex;
}
.seg-label input,
.chip input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}
.seg-label input:focus-visible + span,
.chip input:focus-visible + span {
    outline: 3px solid var(--action);
    outline-offset: 2px;
}

/* Ghost button (Filters) and link-style button */
.ghost-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: var(--touch);
    padding: 0 16px;
    font: 600 16px/1 var(--font-body);
    color: var(--action);
    background: transparent;
    border: 2px solid var(--action);
    border-radius: var(--radius-control);
    cursor: pointer;
}
.ghost-btn:hover,
.ghost-btn[aria-expanded='true'] {
    background: var(--soft);
}
.badge {
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    background: var(--action);
    color: var(--on-action);
    border-radius: var(--radius-control);
}
.link-btn {
    min-height: var(--touch);
    padding: 0 8px;
    font: 600 16px/1 var(--font-body);
    color: var(--action);
    background: transparent;
    border: 0;
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 4px;
    cursor: pointer;
}
.link-btn:hover {
    color: var(--action-hover);
}

/* Filters panel */
.filters-panel {
    display: grid;
    gap: 16px;
    margin-top: 8px;
    padding: 16px;
    background: var(--soft);
    border-radius: var(--radius-panel);
    justify-items: start;
}
.filters-panel[hidden] {
    display: none;
}
.filter-group {
    border: 0;
    display: grid;
    gap: 8px;
    min-width: 0;
}
.filter-group legend {
    padding: 0;
    margin-bottom: 8px;
    font-weight: 600;
}
.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.chip {
    display: inline-flex;
    position: relative;
}
.chip span {
    display: inline-flex;
    align-items: center;
    min-height: var(--touch);
    padding: 0 16px;
    font: 600 16px/1 var(--font-body);
    color: var(--action);
    background: var(--surface);
    border: 2px solid var(--action);
    border-radius: var(--radius-control);
    cursor: pointer;
    transition:
        background-color 140ms ease,
        color 140ms ease;
}
.chip:hover span {
    background: var(--paper);
}
.chip input:checked + span {
    background: var(--action);
    color: var(--on-action);
}

/* Results bar: count and removable active filters */
.results-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    padding: 12px 0 4px;
}
.event-count {
    font-weight: 600;
    color: var(--ink);
}
.active-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.active-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: var(--touch);
    padding: 0 14px;
    font: 600 14px/1 var(--font-body);
    color: var(--ink);
    background: var(--soft);
    border: 0;
    border-radius: var(--radius-control);
    cursor: pointer;
}
.active-chip:hover {
    background: var(--rule);
}

/* Map */
.map-container {
    width: 100%;
    height: calc(100vh - 420px);
    min-height: 360px;
    border: 1px solid var(--rule);
    border-radius: var(--radius-panel);
    overflow: hidden;
    margin-bottom: 16px;
}
#map {
    width: 100%;
    height: 100%;
}
.swd-pin {
    background: none;
    border: 0;
}
.leaflet-container a.leaflet-popup-close-button {
    min-width: 32px;
    min-height: 32px;
}
.marker-popup h3 {
    font: 600 16px/1.25 var(--font-heading);
    margin: 0 0 8px;
}
.marker-popup p {
    margin: 4px 0;
    font-size: 14px;
}
.marker-popup .tag {
    margin-top: 4px;
}

/* States */
.loading {
    text-align: center;
    padding: 48px 16px;
    color: var(--muted);
}
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--rule);
    border-top-color: var(--pigment);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}
.error {
    padding: 16px;
    border: 2px solid var(--danger);
    border-radius: var(--radius-panel);
    background: var(--surface);
    display: grid;
    gap: 12px;
    justify-items: start;
}
.error-message {
    color: var(--danger);
    font-weight: 600;
}
.empty-state {
    display: grid;
    justify-items: center;
    gap: 8px;
    text-align: center;
    padding: 48px 16px;
    font-size: 18px;
    color: var(--muted);
}

/* Event list: one block per day, with a sticky day heading */
.events-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
}
.day-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.day-heading {
    position: sticky;
    top: var(--toolbar-h, 0px);
    z-index: 5;
    display: flex;
    align-items: center;
    min-height: var(--touch);
    padding: 0 16px;
    font: 700 16px/1.2 var(--font-heading);
    color: var(--ink);
    background: var(--soft);
    border-radius: var(--radius-panel);
}

.event-card {
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--radius-panel);
    padding: 16px;
    transition: border-color 140ms ease;
}
.event-card:hover,
.event-card.expanded {
    border-color: var(--action);
}
.event-header {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}
.event-content {
    flex: 1;
    min-width: 0;
}
.event-title {
    font: 600 20px/1.2 var(--font-heading);
    margin-bottom: 8px;
    overflow-wrap: anywhere;
}
.event-info-compact {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
}
.event-time {
    font-weight: 600;
}
.price-badge {
    display: inline-block;
    padding: 2px 12px;
    background: var(--soft);
    border-radius: var(--radius-control);
    font-size: 14px;
    font-weight: 600;
}
.event-location a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: var(--touch);
    color: var(--action);
    font-weight: 500;
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 4px;
    overflow-wrap: anywhere;
}
.event-location a:hover {
    color: var(--action-hover);
}
.event-location svg {
    flex: none;
}
.event-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}
.tag {
    display: inline-block;
    padding: 4px 12px;
    background: var(--soft);
    color: var(--ink);
    border-radius: var(--radius-control);
    font-size: 14px;
    font-weight: 500;
}
.tag.event-type {
    background: var(--action);
    color: var(--on-action);
}

/* Expand button: the chevron is drawn in CSS (the glyph text from app.js is hidden) */
.expand-btn {
    flex: none;
    width: var(--touch);
    height: var(--touch);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--action);
    background: transparent;
    border: 2px solid var(--action);
    border-radius: var(--radius-control);
    cursor: pointer;
    transition: background-color 140ms ease;
}
.expand-btn:hover {
    background: var(--soft);
}
.chevron {
    display: block;
    width: 10px;
    height: 10px;
    font-size: 0;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
    transition: transform 180ms ease;
}
.event-card.expanded .chevron {
    transform: translateY(2px) rotate(225deg);
}
.event-description {
    display: none;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--rule);
}
.event-card.expanded .event-description {
    display: block;
    animation: fadeIn 180ms ease;
}
.event-description h3 {
    font: 600 16px/1.2 var(--font-heading);
    margin-bottom: 8px;
}
.event-description p {
    color: var(--ink);
    white-space: pre-line;
    overflow-wrap: anywhere;
}
.event-description a {
    color: var(--action);
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}

.hidden {
    display: none !important;
}

/* Buttons (install guide, error retry): filled by default, .btn-alt is outlined */
.btn,
.error button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--touch);
    padding: 0 20px;
    font: 600 16px/1 var(--font-body);
    color: var(--on-action);
    background: var(--action);
    border: 2px solid var(--action);
    border-radius: var(--radius-control);
    cursor: pointer;
    transition:
        background-color 140ms ease,
        border-color 140ms ease,
        color 140ms ease;
}
.btn:hover,
.error button:hover {
    background: var(--action-hover);
    border-color: var(--action-hover);
}
.btn-alt {
    color: var(--action);
    background: transparent;
}
.btn-alt:hover {
    color: var(--action-hover);
    background: var(--soft);
    border-color: var(--action-hover);
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}
@keyframes slideUp {
    from {
        transform: translateY(16px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@media (min-width: 640px) {
    header h1 {
        font-size: 39px;
    }
}

@media (prefers-contrast: high) {
    .event-card,
    .tag,
    .price-badge {
        border: 2px solid var(--ink);
    }
}

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

@media print {
    header,
    nav,
    .install-guide,
    .app-footer,
    .toolbar,
    .filters-panel {
        display: none;
    }
    .event-card {
        break-inside: avoid;
        border: 1px solid #000;
    }
}
