/* Meetings — single hand-written stylesheet.
   Palette: off-white bg, ink text, terracotta accent, deep teal, warm yellow. */

:root {
    --bg:        #FAF9F6;
    --surface:   #FFFFFF;
    --ink:       #1F2328;
    --muted:     #6B7280;
    --line:      #E5E2DB;
    --terracotta:#C4552D;
    --terracotta-tint: #F6E6DE;
    --teal:      #1F6F6B;
    --teal-tint: #E1F0EE;
    --yellow:    #E9B44C;
    --yellow-tint:#FBF0D8;
    --danger:    #B23B2E;
    --radius:    10px;
    --shadow:    0 1px 2px rgba(31,35,40,.04), 0 4px 14px rgba(31,35,40,.06);
    --wrap:      920px;
    --sans:      "Public Sans", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    --serif:     "Newsreader", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    background: var(--bg);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 16px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

.wrap {
    width: 100%;
    max-width: var(--wrap);
    margin: 0 auto;
    padding: 0 20px;
}

/* ---- Typography ---- */
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0; }
.display { font-size: 1.9rem; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.sub { margin-top: 4px; }
a { color: var(--terracotta); text-decoration: none; }
a:hover { text-decoration: underline; }
.plain { list-style: none; margin: 0; padding: 0; }

/* ---- Header / footer ---- */
.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 62px; }
.brand { font-family: var(--serif); font-weight: 600; font-size: 1.3rem; color: var(--ink); }
.brand:hover { text-decoration: none; }
.site-nav { display: flex; align-items: center; gap: 14px; }
.site-nav a { color: var(--ink); font-weight: 500; }
.inline { display: inline; margin: 0; }
.site-footer { margin-top: 56px; padding: 24px 0; color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); }

main.wrap { padding-top: 32px; padding-bottom: 24px; }

/* ---- Cards ---- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
    margin-bottom: 20px;
}
.center { text-align: center; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    font-family: var(--sans); font-size: .95rem; font-weight: 600;
    padding: 9px 16px; border-radius: 8px; border: 1px solid transparent;
    cursor: pointer; background: none; transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-lg { padding: 12px 22px; font-size: 1rem; }
.btn-primary { background: var(--terracotta); color: #fff; }
.btn-primary:hover { background: #a8461f; }
.btn-ghost { border-color: var(--line); color: var(--ink); background: var(--surface); }
.btn-ghost:hover { background: #f3f1ec; }
.btn-link { border: none; color: var(--terracotta); padding: 9px 6px; }
.btn-link:hover { text-decoration: underline; }
.btn-danger { color: var(--danger); }

/* ---- Forms ---- */
.stack > * + * { margin-top: 16px; }
.stack-lg > * + * { margin-top: 20px; }
.field { display: block; }
.field > span { display: block; font-weight: 600; margin-bottom: 6px; font-size: .92rem; }
.field .req { color: var(--terracotta); font-style: normal; }
input[type=text], input[type=password], textarea {
    width: 100%; font-family: var(--sans); font-size: 1rem; color: var(--ink);
    padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
    background: #fff; transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus {
    outline: none; border-color: var(--terracotta);
    box-shadow: 0 0 0 3px rgba(196,85,45,.14);
}
textarea { resize: vertical; }
.form-actions { display: flex; justify-content: flex-end; }
.field + .field { margin-top: 16px; }

.auth-card { max-width: 380px; margin: 40px auto; }

/* ---- Alerts ---- */
.alert { border-radius: 8px; padding: 14px 16px; margin-bottom: 18px; position: relative; }
.alert-error { background: #FBE9E7; border: 1px solid #F1C7C0; color: #7a2b20; }
.alert-success { background: var(--teal-tint); border: 1px solid #B9DCD8; color: #14524f; }
.alert-close { position: absolute; top: 8px; right: 10px; border: none; background: none; font-size: 1.3rem; line-height: 1; cursor: pointer; color: inherit; opacity: .6; }
.alert-close:hover { opacity: 1; }

/* ---- Pills / chips ---- */
.pill { display: inline-block; font-size: .78rem; font-weight: 600; padding: 2px 10px; border-radius: 999px; }
.pill-open { background: var(--teal-tint); color: var(--teal); }
.pill-closed { background: #EEE; color: var(--muted); }

/* ---- Tables ---- */
.table-card { padding: 0; overflow: hidden; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 13px 18px; border-bottom: 1px solid var(--line); }
.table thead th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #FBFAF7; }
.table .num { text-align: right; }
.row-link { font-weight: 600; color: var(--ink); }
.row-link:hover { color: var(--terracotta); }

/* ---- Empty state ---- */
.empty { text-align: center; padding: 40px 22px; }
.empty-title { font-family: var(--serif); font-size: 1.25rem; margin-bottom: 4px; }
.empty .btn { margin-top: 14px; }

/* ---- Week selector ---- */
.week-selector { display: flex; align-items: center; justify-content: center; gap: 14px; margin-bottom: 18px; }
.week-nav { font-size: 1.3rem; line-height: 1; padding: 6px 14px; }
.week-label { font-family: var(--serif); font-weight: 600; font-size: 1.1rem; min-width: 250px; text-align: center; }

.grid-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.counter-chip { font-size: .82rem; font-weight: 600; background: var(--terracotta-tint); color: var(--terracotta); padding: 4px 12px; border-radius: 999px; white-space: nowrap; }
.counter-chip.shake { animation: shake .18s linear; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-3px)} 75%{transform:translateX(3px)} }

/* ---- Slot grid (admin picker) ---- */
.slot-grid {
    display: grid;
    grid-template-columns: 56px repeat(7, 1fr);
    gap: 4px;
    user-select: none;
}
.grid-corner { }
.grid-dayhead { text-align: center; font-size: .8rem; font-weight: 600; padding: 4px 0; display: flex; flex-direction: column; }
.dh-date { font-size: .72rem; color: var(--muted); font-weight: 500; }
.grid-timelabel { font-size: .72rem; color: var(--muted); display: flex; align-items: center; justify-content: flex-end; padding-right: 6px; }
.grid-cell {
    height: 34px; border: 1px solid var(--line); border-radius: 6px; background: #fff;
    cursor: pointer; padding: 0; transition: background .15s, border-color .15s;
}
.grid-cell:hover { border-color: var(--terracotta); background: #FBF3EF; }
.grid-cell.is-selected {
    background: var(--terracotta); border-color: var(--terracotta);
    animation: cell-pop .15s ease-out;
}
@keyframes cell-pop { 0% { transform: scale(.92); } 100% { transform: scale(1); } }

/* ---- Vote page ---- */
.vote-head { margin-bottom: 20px; }
.vote-head .display { margin-bottom: 4px; }
.poll-desc { color: var(--ink); background: #fff; }
.vote-hint { margin-top: 0; margin-bottom: 16px; }
.day-group + .day-group { margin-top: 22px; }
.day-title { font-size: 1.05rem; padding-bottom: 6px; border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.slot-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 8px 0; flex-wrap: wrap; }
.slot-time-label { font-weight: 600; font-variant-numeric: tabular-nums; }

.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; width: 0; height: 0; }
.seg > span { display: inline-block; padding: 8px 14px; font-size: .88rem; font-weight: 600; color: var(--muted); border-right: 1px solid var(--line); transition: background .15s, color .15s, transform .12s; }
.seg:last-child > span { border-right: none; }
.seg.is-active > span { transform: scale(1); }
.seg-yes.is-active > span { background: var(--teal); color: #fff; }
.seg-ifneedbe.is-active > span { background: var(--yellow); color: #4a3407; }
.seg-no.is-active > span { background: #ECEAE4; color: var(--ink); }
.seg > span:active { transform: scale(.94); }

/* ---- Results matrix ---- */
.results { padding: 0; }
.table-scroll { overflow-x: auto; }
.matrix { border-collapse: collapse; width: 100%; }
.matrix th, .matrix td { border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); padding: 10px 12px; text-align: center; }
.matrix th:last-child, .matrix td:last-child { border-right: none; }
.matrix thead th { font-size: .78rem; vertical-align: bottom; position: relative; }
.slot-col { min-width: 78px; }
.slot-day { display: block; font-weight: 600; }
.slot-time { display: block; color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.slot-col.is-best { background: var(--terracotta-tint); }
.best-chip { display: inline-block; margin-top: 4px; font-size: .68rem; font-weight: 700; background: var(--terracotta); color: #fff; padding: 1px 7px; border-radius: 999px; }
.voter-col { text-align: left !important; min-width: 150px; position: sticky; left: 0; background: var(--surface); }
.voter-name { display: block; font-weight: 600; }
.voter-time { display: block; font-size: .78rem; }
.cell { font-size: 1.1rem; font-weight: 700; }
.cell-yes { color: var(--teal); }
.cell-ifneedbe { color: var(--yellow); }
.cell-no { color: #C7C3BA; }
.cell.is-best { background: rgba(196,85,45,.05); }
.del-col { text-align: right !important; }

.score-row th, .score-row td { border-bottom: none; background: #FBFAF7; }
.score-cell.is-best { background: var(--terracotta-tint); }
.score-num { display: block; font-weight: 700; font-family: var(--serif); }
.score-bar { display: block; height: 6px; background: var(--line); border-radius: 999px; margin-top: 5px; overflow: hidden; }
.score-fill {
    display: block; height: 100%; width: var(--pct); background: var(--terracotta);
    border-radius: 999px;
    animation: bar-grow .4s ease-out both;
    animation-delay: calc(var(--i) * 40ms);
}
@keyframes bar-grow { from { width: 0; } to { width: var(--pct); } }

.legend { padding: 12px 18px; display: flex; gap: 18px; flex-wrap: wrap; font-size: .85rem; }
.lg-yes { color: var(--teal); font-weight: 600; }
.lg-if { color: #b78219; font-weight: 600; }
.lg-note { margin-left: auto; }

/* ---- Copy link block ---- */
.copy-row { display: flex; gap: 8px; margin-top: 6px; }
.copy-input { flex: 1; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9rem; }
.copy-btn.copied { background: var(--teal); border-color: var(--teal); color: #fff; }
.field-inline > span { display: block; font-weight: 600; margin-bottom: 4px; font-size: .85rem; }
.link-block { padding: 18px 22px; }

.poll-admin-row { display: flex; align-items: center; gap: 16px; }

/* ---- Success check draw ---- */
.done-card { padding: 44px 22px; }
.check-draw { margin-bottom: 8px; }
.check-circle { stroke: var(--teal); stroke-width: 2.5; stroke-dasharray: 151; stroke-dashoffset: 151; animation: draw .5s ease-out forwards; }
.check-mark { stroke: var(--teal); stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 44; stroke-dashoffset: 44; animation: draw .4s .35s ease-out forwards; }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001ms !important; animation-delay: 0ms !important; transition-duration: .001ms !important; }
    .score-fill { width: var(--pct); }
    .check-circle, .check-mark { stroke-dashoffset: 0; }
}

/* ---- Responsive ---- */
@media (max-width: 640px) {
    .display { font-size: 1.55rem; }
    .page-head { flex-direction: column; align-items: stretch; }
    .slot-grid { grid-template-columns: 44px repeat(7, 1fr); gap: 3px; }
    .grid-cell { height: 30px; }
    .grid-dayhead { font-size: .7rem; }
    .week-label { min-width: 0; font-size: 1rem; }
    .slot-row { flex-direction: column; align-items: stretch; }
    .segmented { width: 100%; }
    .seg { flex: 1; text-align: center; }
    .seg > span { display: block; padding: 10px 4px; }
    .site-footer { margin-top: 32px; }
}
