/* ==========================================================================
   Cupping — app styles. Mobile-first; columns from 992px up.
   ========================================================================== */

:root {
    --coffee: #3b2a20;
    --coffee-2: #6b4a35;
    --crema: #c8a27a;
    --paper: #faf7f3;
    --line: #e4dcd3;
    --ok: #2f7d4f;
    --bad: #b3261e;
    --tap: 44px;          /* minimum touch target size */
    --bar-h: 64px;
}

body { background: var(--paper); }

.app-nav { background: var(--coffee); }
.app-nav .navbar-brand { color: #fff; font-weight: 600; }
.app-nav .navbar-brand:hover { color: var(--crema); }
.app-nav .small { color: #f3e9df; }

.btn-coffee { background: var(--coffee); color: #fff; min-height: var(--tap); padding-inline: 1.25rem; }
.btn-coffee:hover, .btn-coffee:focus { background: var(--coffee-2); color: #fff; }

/* ---- Cupping page --------------------------------------------------------- */

.page-cupping main { padding-bottom: calc(var(--bar-h) + env(safe-area-inset-bottom) + 1rem); }
.cupping-container { padding-inline: .75rem; max-width: 1400px; }
.session-head { margin: .25rem 0 .75rem; }

/* Company logo next to session headings */
.head-with-logo { display: flex; align-items: center; gap: .75rem; }
.company-logo { display: block; object-fit: contain; flex: none; }
.company-logo-sm { max-height: 44px; max-width: 140px; }
.company-logo-lg { max-height: 120px; max-width: 100%; }
.company-logo-preview { padding: .5rem; background: #fff; border: 1px solid var(--line); border-radius: .5rem; display: inline-block; }

/* Sample tabs (mobile) */
.sample-tabs {
    position: sticky; top: 0; z-index: 10;
    display: flex; gap: .5rem;
    margin: 0 -.75rem .75rem; padding: .5rem .75rem;
    background: var(--paper); border-bottom: 1px solid var(--line);
}
.sample-tab {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: .5rem;
    min-height: var(--tap); border-radius: .75rem;
    background: #fff; border: 1px solid var(--line);
    color: var(--coffee); text-decoration: none; font-weight: 600;
}
.sample-tab .tab-n {
    display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem;
    border-radius: 50%; background: var(--line); font-size: .85rem;
}
.sample-tab .tab-score { font-variant-numeric: tabular-nums; font-size: .95rem; }
.sample-tab.active { background: var(--coffee); color: #fff; border-color: var(--coffee); }
.sample-tab.active .tab-n { background: var(--crema); color: var(--coffee); }

/* Sheets: only the active one on mobile */
.sheets { display: block; }
.sheet { display: none; }
.sheet.active { display: block; }

@media (min-width: 992px) {
    .sample-tabs { display: none; }
    .sheets { display: grid; grid-template-columns: repeat(var(--samples, 3), minmax(0, 1fr)); gap: 1rem; align-items: start; }
    .sheet { display: block; }
}

.sheet {
    background: #fff; border: 1px solid var(--line); border-radius: 1rem;
    padding: .75rem;
}
.sheet-head { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .75rem; margin-bottom: .5rem; }
.sheet-head h2 { flex: 1; }
.sample-code { font-family: ui-monospace, monospace; background: var(--paper); border: 1px solid var(--line); border-radius: .4rem; padding: 0 .4rem; margin-left: .25rem; }
.sheet-status { font-weight: 500; }
.status-draft { background: #e9ecef; color: #495057; }
.status-submitted { background: #cfe2ff; color: #084298; }
.status-returned { background: #fff3cd; color: #664d03; }
.status-approved { background: #d1e7dd; color: #0f5132; }

/* Groups and attributes */
.group { border-top: 1px solid var(--line); padding-top: .75rem; margin-top: .75rem; }
.group-hint { font-size: .8rem; color: #6c757d; margin: 0 0 .25rem; }
.attr { margin: 0 0 .5rem; border: 0; padding: 0; }
.attr-head { display: flex; align-items: center; gap: .5rem; min-height: var(--tap); }
.attr-label { font-weight: 600; color: var(--coffee); margin: 0; flex: 1; font-size: 1rem; float: none; width: auto; padding: 0; }
.attr-quality { font-size: .75rem; color: var(--coffee-2); }
.attr-value {
    width: 4.75rem; height: var(--tap); text-align: center;
    font-size: 1.15rem; font-weight: 700; font-variant-numeric: tabular-nums;
    border: 1px solid var(--line); border-radius: .6rem; background: var(--paper); color: var(--coffee);
}
.attr-value:focus { outline: 2px solid var(--crema); }
.attr-value-static { display: grid; place-items: center; }
.attr-value::-webkit-inner-spin-button { display: none; }
.attr-value { -moz-appearance: textfield; appearance: textfield; }
.attr-error { color: var(--bad); font-size: .8rem; min-height: 0; }
.is-invalid .attr-value { border-color: var(--bad); }
.is-invalid .seg-btn { border-color: var(--bad); }

/* Slider */
.attr-slider { display: flex; align-items: center; gap: .5rem; }
.btn-step {
    flex: 0 0 var(--tap); height: var(--tap); border-radius: 50%;
    border: 1px solid var(--line); background: #fff; color: var(--coffee);
    font-size: 1.4rem; line-height: 1; touch-action: manipulation;
}
.btn-step:active { background: var(--line); }
.slider-track { flex: 1; }
.slider-track input[type=range] { width: 100%; height: var(--tap); accent-color: var(--coffee); margin: 0; touch-action: pan-y; }
.attr-score.unset input[type=range] { opacity: .45; }
.slider-ticks { display: flex; justify-content: space-between; font-size: .7rem; color: #8a7a6d; margin-top: -.6rem; padding: 0 .35rem; }

/* Segmented buttons (intensities, defects) */
.attr-sub { margin: .25rem 0 .5rem; border: 0; padding: 0; }
.sub-label { font-size: .85rem; color: #6c757d; margin-bottom: .25rem; float: none; width: auto; padding: 0; }
.sub-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.seg { display: flex; gap: .25rem; }
.seg-btn {
    flex: 1; display: grid; place-items: center; min-height: var(--tap); padding: 0 .25rem;
    border: 1px solid var(--line); border-radius: .6rem; background: #fff; color: var(--coffee);
    font-weight: 600; cursor: pointer; user-select: none; touch-action: manipulation; font-size: .9rem;
}
.seg-btn-sm { min-height: 40px; font-size: .85rem; }
.btn-check:checked + .seg-btn { background: var(--coffee); color: #fff; border-color: var(--coffee); }
.btn-check:focus-visible + .seg-btn,
.btn-check:focus-visible + .cup,
.btn-check:focus-visible + .roast-tile { outline: 2px solid var(--crema); outline-offset: 2px; }
.btn-check:disabled + label { opacity: .6; cursor: default; }
.seg-scale { display: flex; justify-content: space-between; font-size: .7rem; color: #8a7a6d; }

/* Roast */
.roast { display: flex; gap: .5rem; }
.roast-tile {
    flex: 1; height: var(--tap); border-radius: .6rem; cursor: pointer;
    border: 3px solid transparent; box-shadow: inset 0 0 0 1px rgba(0,0,0,.1);
}
.roast-1 { background: #a8744f; }
.roast-2 { background: #85563a; }
.roast-3 { background: #5f3b27; }
.roast-4 { background: #3a2318; }
.btn-check:checked + .roast-tile { border-color: var(--crema); box-shadow: 0 0 0 2px var(--coffee); }

/* Cups */
.cups { display: flex; gap: .4rem; }
.cup {
    flex: 1; height: var(--tap); border-radius: 0 0 1rem 1rem;
    display: grid; place-items: center; cursor: pointer; user-select: none; touch-action: manipulation;
    background: #edf6f0; border: 2px solid #b9dcc6; color: var(--ok); font-weight: 700;
}
.btn-check:checked + .cup { background: #fbe9e7; border-color: #f0b4ad; color: var(--bad); }
.btn-check:checked + .cup .cup-n::after { content: ' ✕'; }

/* Sheet score summary */
.sheet-score {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; text-align: center;
    margin-top: 1rem; padding: .75rem; border-radius: .75rem; background: var(--paper);
}
.sheet-score span { display: block; font-size: .75rem; color: #6c757d; }
.sheet-score strong { font-size: 1.2rem; font-variant-numeric: tabular-nums; color: var(--coffee); }
.sheet-score .final strong { font-size: 1.5rem; }

/* Fixed bottom bar */
.cupping-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between; gap: .75rem;
    min-height: var(--bar-h); padding: .5rem 1rem calc(.5rem + env(safe-area-inset-bottom));
    background: #fff; border-top: 1px solid var(--line); box-shadow: 0 -4px 12px rgba(0,0,0,.05);
}
.bar-status { font-size: .85rem; color: #6c757d; }
.bar-status.saving { color: var(--coffee-2); }
.bar-status.error { color: var(--bad); }

/* ---- Section navigation ------------------------------------------------- */
.app-subnav {
    display: flex; gap: .25rem; overflow-x: auto; padding: 0 .75rem;
    background: var(--coffee-2); scrollbar-width: none;
}
.app-subnav a {
    flex: 0 0 auto; padding: .6rem .9rem; color: #f3e9df; text-decoration: none;
    font-size: .95rem; border-bottom: 3px solid transparent;
}
.app-subnav a.active { color: #fff; border-bottom-color: var(--crema); font-weight: 600; }

/* ---- Management screens (supervisor) ----------------------------------- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin: .5rem 0 1rem; flex-wrap: wrap; }
.form-card { background: #fff; border: 1px solid var(--line); border-radius: 1rem; padding: 1rem; max-width: 720px; }
.form-card .form-control, .form-card .form-select { min-height: var(--tap); }
.form-section { border-top: 1px solid var(--line); margin-top: 1rem; padding-top: 1rem; }
.form-section > h2 { font-size: 1rem; font-weight: 600; color: var(--coffee); }

.list-cards { display: grid; gap: .5rem; }
@media (min-width: 768px) { .list-cards { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); } }
.list-card {
    display: block; background: #fff; border: 1px solid var(--line); border-radius: .9rem;
    padding: .75rem 1rem; color: inherit; text-decoration: none;
}
.list-card:hover { border-color: var(--crema); }
.list-card.inactive { opacity: .6; }
.list-card-main { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.list-card-sub { color: #6c757d; font-size: .85rem; margin-top: .15rem; }
.user-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-top: .5rem; }
.user-actions form { margin: 0; }

/* Banner while acting as another account (switch_user) */
.impersonation-bar { background: #fff3cd; border-bottom: 1px solid #ffe69c; color: #664d03; padding: .4rem 0; font-size: .9rem; }
.impersonation-bar .container-fluid { display: flex; align-items: center; justify-content: space-between; gap: .75rem; flex-wrap: wrap; }

.list-title { font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; color: #6c757d; margin: 1rem 0 .5rem; display: flex; align-items: center; gap: .75rem; }
.list-title > span { background: var(--line); border-radius: 1rem; padding: 0 .5rem; color: var(--coffee); }
.list-title .progress-line { flex: 1; max-width: 260px; margin: 0; text-transform: none; letter-spacing: 0; }

.session-status { font-weight: 500; }
.session-draft { background: #e9ecef; color: #495057; }
.session-open { background: #d1e7dd; color: #0f5132; }
.session-closed { background: #3b2a20; color: #fff; }

.progress-line { display: flex; align-items: center; gap: .5rem; margin-top: .5rem; font-size: .8rem; color: #6c757d; }
.progress-line .progress { flex: 1; height: .45rem; background: var(--line); }
.progress-line .progress-bar { background: var(--ok); }

.action-bar { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1rem; }
.action-bar .btn { min-height: var(--tap); }
.action-bar form { margin: 0; }

/* Chips (cupper selection, progress) */
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip {
    display: inline-flex; align-items: center; gap: .35rem; min-height: 40px; padding: 0 .9rem;
    border: 1px solid var(--line); border-radius: 2rem; background: #fff; color: var(--coffee);
    cursor: pointer; user-select: none; font-size: .9rem;
}
.btn-check:checked + .chip { background: var(--coffee); border-color: var(--coffee); color: #fff; }
.btn-check:checked + .chip::before { content: '✓'; }
.chip-static { cursor: default; }
.chip-static small { color: #6c757d; }
.chip-done { background: #d1e7dd; border-color: #a3cfbb; }

/* Session form */
.form-wide { max-width: 960px; }
.sample-entry { border: 1px solid var(--line); border-radius: .9rem; padding: .75rem; margin-bottom: .75rem; background: var(--paper); }
.sample-entry-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
details.lab > summary { cursor: pointer; color: var(--coffee-2); font-size: .9rem; padding: .35rem 0; }
details.lab .form-label { font-size: .85rem; }

/* Results */
.results { display: grid; gap: .75rem; }
@media (min-width: 992px) { .results { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); } }
.result-card { background: #fff; border: 1px solid var(--line); border-radius: 1rem; padding: .75rem 1rem; }
.result-card > header { display: flex; justify-content: space-between; gap: .75rem; align-items: flex-start; }
.result-avg { text-align: right; line-height: 1.1; }
.result-avg strong { display: block; font-size: 1.6rem; color: var(--coffee); font-variant-numeric: tabular-nums; }
.result-avg span { font-size: .75rem; color: #6c757d; }
.result-range { margin-top: .15rem; }
.result-sheets { list-style: none; padding: 0; margin: .5rem 0 0; }
.result-sheets li {
    display: grid; grid-template-columns: 1fr auto 3.5rem 4.5rem; align-items: center; gap: .5rem;
    min-height: var(--tap); border-top: 1px solid var(--line);
}
.result-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-score { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.result-score.outlier { color: var(--bad); }
.result-score.outlier::after { content: ' ⚠'; font-size: .8em; }
.result-link { text-align: right; font-size: .9rem; }
.lab-line { margin-top: .5rem; font-size: .8rem; color: #6c757d; }

/* Sheet review */
.review-layout { display: grid; gap: 1rem; align-items: start; }
@media (min-width: 768px) { .review-layout { grid-template-columns: minmax(0, 1fr) 320px; } }
.review-layout aside { position: sticky; top: .75rem; }
.sheet-summary { margin: 0; }
.sheet-summary > div { display: grid; grid-template-columns: 9rem 1fr; gap: .5rem; padding: .45rem 0; border-top: 1px solid var(--line); }
.sheet-summary dt { font-weight: 500; color: #6c757d; }
.sheet-summary dd { margin: 0; }
.sheet-summary dd b { font-variant-numeric: tabular-nums; margin-right: .35rem; }
.sheet-summary dd small { color: #6c757d; }
.sheet-summary .total, .sheet-summary .final { background: var(--paper); padding-inline: .5rem; border-radius: .5rem; }
.sheet-summary .final dd b { font-size: 1.3rem; color: var(--coffee); }
.cups-mini { display: inline-flex; gap: 2px; vertical-align: middle; }
.cups-mini span { width: 1.3rem; height: 1.3rem; display: grid; place-items: center; font-size: .7rem; border-radius: 0 0 .4rem .4rem; }
.cups-mini .ok { background: #edf6f0; color: var(--ok); }
.cups-mini .bad { background: #fbe9e7; color: var(--bad); font-weight: 700; }
.roast-dot { display: inline-block; width: 1rem; height: 1rem; border-radius: 50%; vertical-align: -2px; }
.roast-dot.roast-1 { background: #a8744f; } .roast-dot.roast-2 { background: #85563a; }
.roast-dot.roast-3 { background: #5f3b27; } .roast-dot.roast-4 { background: #3a2318; }
.sheet-notes { margin-top: .75rem; padding: .75rem; background: var(--paper); border-radius: .75rem; font-size: .9rem; }

/* ---- Language menu (<details>, no JS) ---------------------------------- */
.lang-menu { position: relative; }
.lang-menu summary {
    list-style: none; cursor: pointer; color: #fff; font-weight: 600;
    min-height: 32px; min-width: 40px; display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid rgba(255, 255, 255, .5); border-radius: .375rem; padding: 0 .5rem;
}
.lang-menu summary::-webkit-details-marker { display: none; }
.lang-menu ul {
    position: absolute; right: 0; top: calc(100% + .35rem); z-index: 1050; min-width: 10rem;
    margin: 0; padding: .35rem 0; list-style: none; background: #fff;
    border: 1px solid var(--line); border-radius: .5rem; box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .15);
}
.lang-menu a { display: block; padding: .55rem 1rem; color: var(--coffee); text-decoration: none; }
.lang-menu a:hover, .lang-menu a:focus { background: var(--paper); }
.lang-menu a[aria-current] { font-weight: 600; }
.login-lang .lang-menu summary { color: var(--coffee); border-color: var(--line); }

/* ---- Blog, site pages ------------------------------------------------------ */

.app-nav .nav-link-light { color: #f3e9df; text-decoration: none; }
.app-nav .nav-link-light:hover { color: var(--crema); }

.site-footer { border-top: 1px solid var(--line); margin-top: 2rem; padding: 1rem 0 calc(1rem + env(safe-area-inset-bottom)); font-size: .875rem; }
.site-footer .container { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; }
.site-footer a { color: var(--coffee-2); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

.home-hero { background: #fff; border: 1px solid var(--line); border-radius: 1rem; padding: 1.5rem; margin-bottom: 1.5rem; }
.home-hero .post-content { font-size: 1.1rem; }

.post-grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.post-card { background: #fff; border: 1px solid var(--line); border-radius: 1rem; overflow: hidden; }
.post-card-link { display: flex; flex-direction: column; height: 100%; color: inherit; text-decoration: none; }
.post-card-link:hover h2 { color: var(--coffee-2); text-decoration: underline; }
.post-card-image { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--paper); }
.post-card-body { padding: 1rem; }
.post-meta { color: #6c757d; font-size: .875rem; }

/* A readable column for posts and pages. */
.post { max-width: 42rem; margin-inline: auto; }
.post-title { font-size: clamp(1.6rem, 4vw, 2.25rem); color: var(--coffee); margin-bottom: .25rem; }
.post-breadcrumb a { color: var(--coffee-2); }
.post-content { font-size: 1.0625rem; line-height: 1.65; overflow-wrap: anywhere; }
.post-content h2, .post-content h3, .post-content h4 { color: var(--coffee); margin-top: 1.75rem; }
.post-content a { color: var(--coffee-2); }
.post-content mark { background: #f6e3b4; }
.post-quote { border-left: 4px solid var(--crema); padding: .25rem 0 .25rem 1rem; margin: 1.5rem 0; font-style: italic; }
.post-quote footer { font-style: normal; font-size: .9rem; color: #6c757d; }
.post-quote footer::before { content: "— "; }
.post-delimiter { border: 0; text-align: center; margin: 2rem 0; opacity: 1; }
.post-delimiter::before { content: "* * *"; color: var(--crema); letter-spacing: .5em; }
.post-checklist { list-style: none; padding-left: .5rem; }
.post-image { margin: 1.5rem 0; }
.post-image img { display: block; max-width: 100%; height: auto; margin-inline: auto; border-radius: .5rem; }
.post-image.with-border img { border: 1px solid var(--line); }
.post-image.with-background { background: #fff; padding: 1rem; border-radius: .75rem; }
.post-image.with-background img { max-width: 60%; }
.post-image figcaption { text-align: center; font-size: .875rem; color: #6c757d; margin-top: .4rem; }
@media (min-width: 992px) {
    .post-image.is-stretched { margin-inline: -6rem; }
}

/* Block editor */
.editor-container { max-width: 56rem; }
.block-editor-holder { min-height: 14rem; padding: .75rem 1rem; height: auto; }
.block-editor-holder .ce-block__content, .block-editor-holder .ce-toolbar__content { max-width: none; }
.block-editor-holder .codex-editor__redactor { padding-bottom: 4rem !important; }
@media (max-width: 650px) {
    /* Editor.js puts its toolbar on the left margin; make room on narrow screens. */
    .block-editor-holder { padding-left: 2.25rem; }
}
.form-section summary { cursor: pointer; font-weight: 600; color: var(--coffee); min-height: var(--tap); display: flex; align-items: center; }
