/* =====================================================
   Rate My Crème Brûlée — Public Stylesheet
   ===================================================== */

/* -- Variables -- */
:root {
    --bg:           #FDF6EC;
    --surface:      #FFFFFF;
    --accent:       #C27A2B;
    --accent-light: #E8A94D;
    --text:         #2C1A0E;
    --text-muted:   #7A5C3A;
    --border:       #E8D5B0;
    --star-fill:    #D4A017;
    --star-empty:   #E8D5B0;
    --shadow:       rgba(194, 122, 43, 0.12);
    --shadow-hover: rgba(194, 122, 43, 0.22);
    --radius:       12px;
    --font-head:    'Playfair Display', Georgia, serif;
    --font-body:    'Lato', system-ui, sans-serif;
}

/* -- Reset -- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
img { display: block; max-width: 100%; }
a { color: inherit; }

/* -- Base -- */
html { font-size: 16px; scroll-behavior: smooth; }
body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* -- Header -- */
.site-header {
    background: linear-gradient(135deg, #B8621F 0%, #C27A2B 40%, #E8A94D 100%);
    padding: 2.5rem 1.5rem 2rem;
    text-align: center;
    color: #fff;
}
.header-inner { max-width: 900px; margin: 0 auto; }
.header-title {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
}
.header-icon { font-size: 2rem; }
.site-header h1 {
    font-family: var(--font-head);
    font-size: clamp(1.8rem, 5vw, 3rem);
    font-weight: 600;
    letter-spacing: -0.5px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.25);
}
.header-tagline {
    margin-top: 0.4rem;
    font-size: 1rem;
    color: rgba(255,255,255,0.88);
}

/* -- Main layout -- */
.main-content {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem 3rem;
    width: 100%;
}

/* -- Controls bar -- */
.controls-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.75rem;
    padding: 1rem 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 1px 4px var(--shadow);
}
.controls-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.controls-group label {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--text-muted);
    white-space: nowrap;
}
.controls-group select {
    font-family: var(--font-body);
    font-size: 0.875rem;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.35rem 0.6rem;
    cursor: pointer;
}
.controls-group select:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}
.entry-count {
    margin-left: auto;
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
}

/* -- Card grid -- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 1.5rem;
}

/* -- Card -- */
.brulee-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 2px 12px var(--shadow);
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
}
.brulee-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 20px var(--shadow-hover);
}

.card-photo-wrap {
    aspect-ratio: 4 / 3;
    overflow: hidden;
    background: var(--border);
}
.card-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}
.brulee-card:hover .card-photo {
    transform: scale(1.04);
}

.card-body {
    padding: 1rem 1.1rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    flex: 1;
}

/* -- Rating -- */
.card-rating {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.stars {
    display: inline-flex;
    gap: 2px;
}
.star-svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}
.rating-number {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--accent);
}

/* -- Card text -- */
.card-title {
    font-family: var(--font-head);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
}
.card-location,
.card-date {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.825rem;
    color: var(--text-muted);
}
.icon {
    width: 13px;
    height: 13px;
    fill: currentColor;
    flex-shrink: 0;
}
.card-notes {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    font-style: italic;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* -- Clickable card -- */
.brulee-card[role="button"] {
    cursor: pointer;
}
.brulee-card[role="button"]:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

/* -- Empty state -- */
.empty-state {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* -- History button (header) -- */
.history-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.75rem;
    padding: 0.35rem 1rem;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.4);
    border-radius: 20px;
    color: rgba(255,255,255,0.9);
    font-family: var(--font-head);
    font-size: 0.875rem;
    font-style: italic;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}
.history-btn:hover,
.history-btn:focus-visible {
    background: rgba(255,255,255,0.27);
    border-color: rgba(255,255,255,0.7);
    outline: none;
}

/* -- History modal -- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(28, 12, 3, 0.65);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.modal-overlay.is-open {
    opacity: 1;
    pointer-events: auto;
}
.modal-box {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 24px 64px rgba(28, 12, 3, 0.4);
    max-width: 560px;
    width: 100%;
    max-height: 88vh;
    overflow-y: auto;
    padding: 2rem 2rem 1.75rem;
    position: relative;
    transform: scale(0.94) translateY(10px);
    transition: transform 0.25s ease;
}
.modal-overlay.is-open .modal-box {
    transform: scale(1) translateY(0);
}
.modal-close {
    position: absolute;
    top: 0.9rem;
    right: 0.9rem;
    width: 2rem;
    height: 2rem;
    border: none;
    background: var(--border);
    border-radius: 50%;
    font-size: 1rem;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}
.modal-close:hover { background: var(--accent); color: #fff; }
.modal-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.modal-heading {
    font-family: var(--font-head);
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text);
    padding-right: 2rem;
}
.modal-divider {
    text-align: center;
    margin: 0.8rem 0 1.1rem;
    color: var(--accent-light);
    letter-spacing: 0.4rem;
    font-size: 1rem;
}
.modal-body p {
    font-size: 0.9rem;
    color: var(--text);
    line-height: 1.8;
    margin-bottom: 0.9rem;
}
.modal-body p:last-child { margin-bottom: 0; }
.modal-body em { color: var(--text-muted); }
.modal-source {
    margin-top: 1.25rem;
    padding-top: 0.9rem;
    border-top: 1px solid var(--border);
    font-size: 0.78rem;
    color: var(--text-muted);
    font-style: italic;
}

/* -- Header button row -- */
.header-btns {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.6rem;
    margin-top: 0.75rem;
}
.header-btns .history-btn { margin-top: 0; }

/* -- Wide modal variant (map) -- */
.modal-box--wide {
    max-width: 760px;
}
.map-intro {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}
#brulee-map {
    width: 100%;
    height: 440px;
    border-radius: calc(var(--radius) - 2px);
    border: 1px solid var(--border);
}
@media (max-width: 540px) {
    #brulee-map { height: 300px; }
}

/* -- Entry detail modal -- */
.modal-box--entry {
    max-width: 600px;
    padding: 0;
}
.entry-modal-photo {
    width: 100%;
    height: 260px;
    object-fit: cover;
    display: block;
    border-radius: var(--radius) var(--radius) 0 0;
}
.entry-modal-content {
    padding: 1.5rem 1.75rem 1.75rem;
}
.entry-modal-content .card-rating {
    margin-bottom: 0.5rem;
}
.entry-modal-content .modal-heading {
    margin-bottom: 0.5rem;
}
.entry-modal-meta {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}
.entry-modal-notes {
    margin-top: 0.9rem;
    font-size: 0.9rem;
    color: var(--text);
    line-height: 1.75;
    font-style: italic;
}
#entry-detail-map {
    margin-top: 1.25rem;
    width: 100%;
    height: 220px;
    border-radius: calc(var(--radius) - 2px);
    border: 1px solid var(--border);
}
@media (max-width: 540px) {
    .entry-modal-photo { height: 200px; }
    .entry-modal-content { padding: 1.1rem 1.25rem 1.25rem; }
    #entry-detail-map { height: 180px; }
}

/* Leaflet pin icon */
.brulee-pin {
    font-size: 1.6rem;
    line-height: 1;
    filter: drop-shadow(0 2px 3px rgba(28, 12, 3, 0.35));
    cursor: pointer;
}

/* Leaflet popup styling */
.leaflet-popup-content-wrapper {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(28, 12, 3, 0.18);
    padding: 0;
}
.leaflet-popup-content {
    margin: 0.5rem 0.75rem;
    font-family: var(--font-head);
    font-size: 0.875rem;
    color: var(--text);
}
.leaflet-popup-tip-container .leaflet-popup-tip {
    background: var(--bg);
}
.leaflet-popup-close-button {
    color: var(--text-muted) !important;
}
.leaflet-attribution-flag { display: none !important; }
.leaflet-control-attribution {
    font-size: 0.7rem;
    background: rgba(253, 246, 236, 0.85) !important;
}

/* -- Footer -- */
.site-footer {
    text-align: center;
    padding: 1.25rem 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}

/* -- Responsive -- */
@media (max-width: 480px) {
    .controls-bar { flex-direction: column; align-items: flex-start; }
    .entry-count { margin-left: 0; }
    .card-grid { grid-template-columns: 1fr; }
}
