/* ==========================================================================
   Pardon Me build tracker
   1. Tokens   2. Base   3. Controls   4. Navigation   5. Shared UI
   6. Checklist   7. Decisions / stories / log   8. Technical spec
   ========================================================================== */

/* 1. Tokens ---------------------------------------------------------------- */
:root {
    --teal: #006b5e;
    --teal-dark: #004039;
    --blue: #3c6a99;
    --slate: #3a525a;
    --yellow: #fdcc2c;
    --text: #15262a;
    --bg-light: #f2f5f7;
    --white: #ffffff;
    --border: #c9d3d6;
    --danger: #b3452f;
    --amber: #c98a1f;
    --amber-bg: #fff3cf;
    --amber-bar: #fbe3a0;
    --amber-ink: #4a3200;
    --font-heading: 'Akatab', sans-serif;
    --font-body: 'Afacad', sans-serif;
    --font-accent: 'Overpass Mono', ui-monospace, 'SFMono-Regular', monospace;
    --not-started: #b7c2c4;
    --card-shadow: 0 1px 6px rgba(0, 0, 0, 0.04);
}

/* 2. Base ------------------------------------------------------------------ */
html { font-size: 19px; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
    margin: 0;
    background: var(--bg-light);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.6;
}
main { max-width: 780px; margin: 0 auto; padding: 32px 20px 90px; }

h1, h2, h3 { font-family: var(--font-heading); font-weight: 700; color: var(--teal-dark); }
h1 { font-size: 1.8rem; margin: 0 0 6px; }
h2 { font-size: 1.25rem; margin: 34px 0 10px; padding-bottom: 6px; border-bottom: 2px solid var(--border); }

a { color: var(--teal-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
.subtle { color: var(--slate); font-size: 0.85rem; }
.flash { background: var(--teal); color: #fff; padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; font-size: 0.9rem; }

.prose, .story-text, .criteria-list, .timeline-body, .question-card p:not(.subtle) { font-size: 1rem; line-height: 1.65; max-width: 62ch; }
.prose { white-space: pre-line; margin-bottom: 16px; }

/* 3. Controls -------------------------------------------------------------- */
/* Default submit button. :where() keeps its specificity at zero so any component class overrides it. */
:where(form button[type="submit"]) {
    background: var(--teal-dark); color: #fff; border: none; padding: 10px 20px;
    border-radius: 8px; cursor: pointer; font: inherit; font-weight: 600;
}
:where(form button[type="submit"]:hover) { background: var(--teal); }

/* Compact buttons inside the checklist and filter forms */
.filter-bar button, .item-edit-form button, .item-add-form button, .note-form button {
    padding: 7px 18px; border-radius: 6px; font-size: 0.9rem; font-weight: 400;
}
.note-form button { padding: 6px 16px; }

/* Text fields, all forms */
input[type="text"], input[type="email"], select, textarea {
    font: inherit; color: var(--text); background: var(--white);
    border: 1px solid var(--border); border-radius: 6px; padding: 7px 10px;
}
.login-box input[type="email"] { width: 100%; padding: 11px; margin: 12px 0; border-radius: 8px; }
.login-box button { background: var(--teal-dark); color: #fff; border: none; padding: 10px 20px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 600; }
.login-box button:hover { background: var(--teal); }
.login-box { max-width: 380px; margin: 15vh auto; }

/* 4. Navigation ------------------------------------------------------------ */
.topnav {
    display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap;
    gap: 12px 20px; padding: 14px 20px; background: var(--white);
    border-bottom: 1px solid var(--border); font-size: 0.85rem;
}
.topnav .brand { font-weight: 700; font-family: var(--font-heading); font-size: 1rem; color: var(--teal-dark); flex-basis: 100%; }
.topnav a { color: var(--text); white-space: nowrap; }
.topnav a:hover { color: var(--teal-dark); }
.nav-links { display: flex; flex-wrap: wrap; gap: 6px 16px; flex: 1; }
.nav-actions { display: flex; align-items: baseline; gap: 16px; }
.logout-form button { background: none; border: none; color: var(--slate); cursor: pointer; font: inherit; padding: 0; white-space: nowrap; }
.logout-form button:hover { color: var(--danger); background: none; }
.client-view-form button { background: none; border: 1px solid var(--teal); color: var(--teal-dark); border-radius: 6px; cursor: pointer; font: inherit; font-weight: 400; padding: 4px 10px; white-space: nowrap; }
.client-view-form button:hover { background: var(--teal); color: var(--white); }
.client-view-banner { display: flex; align-items: center; justify-content: center; gap: 16px; background: var(--yellow); color: var(--teal-dark); font-weight: 700; font-size: 0.85rem; padding: 8px 20px; text-align: center; }
.client-view-banner form { margin: 0; }
.client-view-banner button { background: var(--teal-dark); color: var(--white); border: none; border-radius: 6px; cursor: pointer; font: inherit; font-weight: 700; padding: 5px 12px; }

/* 5. Shared UI: alerts, badges, progress, cards ---------------------------- */
.alert-row { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.alert { padding: 8px 14px; border-radius: 8px; font-size: 0.85rem; font-weight: 600; text-decoration: none; }
.alert-warn { background: rgba(201, 138, 31, 0.12); color: var(--amber); }
.alert-conflict { background: rgba(179, 69, 47, 0.1); color: var(--danger); }
.alert-good { background: rgba(0, 107, 94, 0.1); color: var(--teal-dark); }

.badge { display: inline-block; background: var(--bg-light); color: var(--slate); font-size: 0.85rem; padding: 3px 9px; border-radius: 20px; font-family: var(--font-accent); }
.badge-off-track { background: rgba(179, 69, 47, 0.12); color: var(--danger); }
.badge-decision { background: #fdecc0; color: #5a3d00; font-weight: 700; }

.progress-panel { background: var(--white); border-radius: 10px; padding: 14px 16px; margin-bottom: 16px; box-shadow: var(--card-shadow); }
.progress-row { margin-bottom: 12px; }
.progress-label { display: flex; justify-content: space-between; gap: 12px; font-weight: 700; margin-bottom: 4px; }
.progress-row-main .progress-label { font-size: 1.1rem; }
.progress-track { height: 16px; background: #d5dee0; border-radius: 8px; overflow: hidden; }
.progress-row-main .progress-track { height: 22px; border-radius: 11px; }
.progress-track-sm { height: 10px; border-radius: 5px; margin: 2px 0 8px; }
.progress-fill { height: 100%; background: var(--teal); border-radius: inherit; }

.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 20px; padding: 12px 14px; background: var(--white); border-radius: 10px; box-shadow: var(--card-shadow); }
.filter-bar label { display: flex; flex-direction: column; gap: 2px; font-size: 0.85rem; color: var(--slate); font-weight: 600; }
.filter-bar a { font-size: 0.85rem; color: var(--slate); }

.question-card, .story-card, .feature-card, .timeline-entry {
    background: var(--white); border-left: 4px solid var(--not-started); border-radius: 8px;
    padding: 12px 14px; margin-bottom: 8px; box-shadow: var(--card-shadow);
}

/* 6. Checklist ------------------------------------------------------------- */
.milestone-heading-row {
    display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 6px;
    border-bottom: 3px solid var(--border); margin: 44px 0 10px; padding-bottom: 6px;
}
.milestone-heading-row h2 { font-size: 1.7rem; border: none; margin: 0; padding: 0; }
.milestone-badges { display: flex; gap: 6px; flex-wrap: wrap; }

/* Section header band + "done when" goal */
.section-heading {
    font-family: var(--font-heading); font-size: 1.2rem; font-weight: 700; line-height: 1.3;
    color: #fff; background: var(--teal-dark); margin: 28px 0 0; padding: 10px 14px; border-radius: 8px 8px 0 0;
}
.section-heading .subtle { color: #cfe5e1; margin-left: 8px; font-weight: 400; }
.section-goal { background: #e3f1ee; margin: 0 0 6px; padding: 8px 14px; border-radius: 0 0 8px 8px; font-size: 0.95rem; }

/* One row per task: [checkbox] [text + badges] [Notes] [Edit], then banner, then panels */
ul.checklist { list-style: none; padding: 0; }
.section-heading + ul.checklist { margin-top: 6px; }
ul.checklist li {
    position: relative; display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px;
    padding: 8px 10px; border-left: 5px solid transparent; border-bottom: 1px solid var(--border); border-radius: 8px;
}
.item-row { flex: 1; min-width: 0; }
.is-done .item-text { text-decoration: line-through; text-decoration-thickness: 2px; color: #7a8a8e; }
.is-done .badge { opacity: 0.55; }
.inline-form { display: flex; margin: 0; padding: 0; flex-shrink: 0; }

/* Checkbox: white square, dark outline, teal check when done; amber padlock when locked */
.checkbox-btn {
    -webkit-appearance: none; appearance: none;
    display: inline-flex; align-items: center; justify-content: center;
    flex: 0 0 24px; width: 24px; height: 24px; margin: 1px 0 0; padding: 0;
    background: #fff; border: 2px solid #2a3b3e; border-radius: 5px;
    color: var(--teal); font: 700 18px/1 sans-serif; cursor: pointer;
}
button.checkbox-btn:hover { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(0, 107, 94, 0.18); }
.checkbox-btn.checked { border-color: var(--teal); }
.checkbox-btn.checked::after { content: "\2713"; }
span.checkbox-btn:not(.locked) { cursor: default; }
.checkbox-btn.locked { background: #f0e3bd; border-color: var(--amber); cursor: not-allowed; }
.checkbox-btn.locked::after { content: "\1F512"; font-size: 12px; line-height: 1; }

/* Locked by an open decision */
ul.checklist li.is-locked { background: var(--amber-bg); border-left-color: var(--amber); margin-bottom: 6px; }
.locked-banner { order: 5; flex: 1 1 calc(100% - 32px); margin-left: 32px; background: var(--amber-bar); color: var(--amber-ink); border-radius: 6px; padding: 5px 12px; font-size: 0.9rem; }
.locked-banner a { color: var(--amber-ink); font-weight: 600; }
.locked-banner .locked-link { margin-left: 10px; font-weight: 400; }

/* Row buttons (Notes, Edit) */
.item-edit-btn {
    flex-shrink: 0; align-self: flex-start; margin-left: 8px;
    background: var(--white); color: var(--teal-dark); border: 1px solid var(--teal); border-radius: 6px;
    padding: 2px 12px; font: inherit; font-size: 0.85rem; font-weight: 600; cursor: pointer;
}
.item-edit-btn:hover { background: var(--teal); color: #fff; }
.item-notes-btn { margin-left: auto; }

/* Expandable panels under a row: edit form, notes */
.item-notes, .item-edit-form { order: 10; flex-basis: 100%; margin-left: 32px; font-size: 0.9rem; }
.item-edit-form { display: flex; flex-direction: column; gap: 8px; padding: 8px 0; }
.item-edit-form label { display: flex; align-items: center; gap: 8px; }
.item-edit-actions { display: flex; gap: 10px; align-items: center; }
.item-edit-form .btn-delete { background: var(--white); color: var(--danger); border: 1px solid var(--danger); }
.item-edit-form .btn-delete:hover { background: var(--danger); color: #fff; }
.item-edit-form button { align-self: flex-start; }

.item-add-form { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 14px 32px; }
.item-add-form input[type="text"] { flex: 1 1 260px; }

.item-notes { padding: 8px 12px; background: var(--bg-light); border-left: 4px solid var(--teal); border-radius: 6px; font-size: 0.95rem; }
.note { padding: 6px 0; border-bottom: 1px solid var(--border); }
.note-meta { display: flex; gap: 10px; align-items: center; }
.note-text { margin-top: 2px; }
.note-resolved .note-text { color: #7a8a8e; text-decoration: line-through; }
.note-delete button { background: none; border: none; color: var(--danger); padding: 0; border-radius: 0; font: inherit; font-size: 0.85rem; line-height: 1.4; cursor: pointer; }
.note-delete button:hover { background: none; text-decoration: underline; }
.note-resolve button { background: var(--white); border: 1px solid var(--teal); color: var(--teal-dark); padding: 3px 14px; border-radius: 6px; font: inherit; font-size: 0.85rem; font-weight: 600; line-height: 1.4; cursor: pointer; }
.note-resolve button:hover { background: var(--teal); color: #fff; }
.note-form { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.note-form button { align-self: flex-start; }

/* 7. Decisions, stories, log ----------------------------------------------- */
.question-card.category-exhibit_conflict, .story-card.status-failed { border-left-color: var(--danger); }
.question-card.category-client_decision, .story-card.status-in_progress { border-left-color: var(--amber); }
.question-card.category-spike { border-left-color: var(--blue); }
.question-card.resolved, .story-card.status-passed, .story-card.status-done { border-left-color: var(--teal); opacity: 0.7; }
.story-card.status-wont_do { opacity: 0.6; }
.question-detail p { margin: 0 0 8px; }
.question-impacts ul { margin: 4px 0 0; padding-left: 20px; }
.question-impacts li { margin-bottom: 2px; }
.resolve-form { display: flex; gap: 8px; margin-top: 8px; }
.resolve-form input[type="text"] { flex: 1; }

.log-form { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; padding: 16px; background: var(--white); border-radius: 12px; box-shadow: var(--card-shadow); }
.log-form textarea { flex: 1 0 100%; min-height: 50px; }
.timeline-date { font-family: var(--font-accent); font-size: 0.85rem; color: var(--slate); }
.timeline-tag { margin-left: 6px; }
.timeline-title { font-weight: 700; margin-top: 2px; }
.timeline-body { margin-top: 4px; }

.story-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.story-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.story-title { font-family: var(--font-heading); font-weight: 700; color: var(--teal-dark); }
.criteria-list { margin: 0 0 8px; padding-left: 18px; font-size: 0.92rem; }
.story-form { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.story-form input[type="text"] { flex: 1; min-width: 120px; }
.story-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.story-meta .badge, .feature-components .badge { margin-left: 0; }

/* 8. Technical spec -------------------------------------------------------- */
.feature-grid { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.feature-card { display: block; color: var(--text); text-decoration: none; transition: box-shadow 0.15s, transform 0.15s; }
.feature-card:hover { box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08); transform: translateY(-1px); text-decoration: none; }
.feature-title { font-family: var(--font-heading); font-weight: 700; color: var(--teal-dark); }
.feature-summary { font-size: 0.9rem; color: var(--slate); margin: 3px 0 6px; max-width: 55ch; }
.feature-components { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }

.flow-diagram { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin: 16px 0; }
.flow-step { display: flex; align-items: center; gap: 6px; }
.flow-diagram.vertical { flex-direction: column; align-items: flex-start; }
.flow-diagram.vertical .flow-step { flex-direction: column; align-items: flex-start; margin-bottom: 4px; }
.flow-box { background: var(--bg-light); border: 1px solid var(--teal); color: var(--teal-dark); border-radius: 20px; padding: 6px 12px; font-size: 0.85rem; font-weight: 600; font-family: var(--font-accent); }
.flow-arrow { color: var(--slate); font-size: 1rem; display: flex; align-items: center; gap: 4px; }
.flow-label { font-size: 0.85rem; font-weight: 400; background: var(--bg-light); padding: 1px 8px; border-radius: 10px; font-family: var(--font-accent); color: var(--slate); }

.spec-section { margin-bottom: 36px; }
.spec-section h3 { font-size: 1.1rem; margin: 0 0 4px; }
.spec-meta { font-size: 0.85rem; color: var(--slate); margin-bottom: 8px; }
.locked-banner > div + div { margin-top: 3px; }

/* Subtasks: indented under their parent task, no assignee badge because they inherit it. */
.subtasks { list-style: none; margin: .5rem 0 .25rem 2.25rem; padding: 0; display: grid; gap: .3rem; }
.subtasks li { display: flex; align-items: center; gap: .6rem; }
.subtasks li.is-done .item-text { text-decoration: line-through; color: var(--slate); }

/* Unlink buttons inside the locked banner (Maria only). */
.locked-banner .unlink-form { display: inline; margin: 0 2px 0 4px; }
.unlink-btn { background: none; border: 1px solid currentColor; border-radius: 4px; color: var(--amber-ink); cursor: pointer; font: inherit; font-size: 0.75rem; padding: 0 6px; }
.unlink-btn:hover { background: var(--amber-ink); color: var(--amber-bg); }
