/* Recipe Bindery - base styles (Phase 0: sign-in; v3: Phase 1 site shell; v4: recipe editor; v5: editor clarity; v6: collapsible editor sections; v7: clearer section bars)
   Colours checked against WCAG AA:
   text #1d1d1b on #fff 16.9:1 · muted #5a5a55 on #fff 6.9:1
   button #fff on #1f4e3d 9.5:1 · error #8a1c1c on #fdecec 8.1:1
   success #1f4e3d on #e8f2ed 8.3:1 · input border #767670 4.6:1 · focus #b5651d 4.3:1 */

:root {
    --bg: #faf7f2;
    --card: #ffffff;
    --text: #1d1d1b;
    --muted: #5a5a55;
    --brand: #1f4e3d;
    --brand-dark: #163a2d;
    --border: #767670;
    --focus: #b5651d;
    --error-text: #8a1c1c;
    --error-bg: #fdecec;
    --ok-text: #1f4e3d;
    --ok-bg: #e8f2ed;
    --radius: 8px;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
    font-size: 18px;
    line-height: 1.5;
}

a {
    color: var(--brand);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
textarea:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

.site-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.25rem 1rem;
    max-width: 60rem;
    margin: 0 auto;
    padding: 1rem 1.25rem;
}

.site-header .brand {
    color: var(--text);
    text-decoration: none;
    font-size: 1.5rem;
    font-weight: bold;
    letter-spacing: 0.02em;
}

main {
    max-width: 28rem;
    margin: 0 auto;
    padding: 0 1rem 3rem;
}

.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    padding: 1.5rem 1.25rem;
}

h1 {
    font-size: 1.6rem;
    line-height: 1.25;
    margin: 0 0 0.75rem;
}

p {
    margin: 0 0 1rem;
}

.muted {
    color: var(--muted);
    font-size: 0.95rem;
}

label {
    display: block;
    font-weight: bold;
    margin-bottom: 0.35rem;
}

input[type="email"],
input[type="text"],
input[type="search"],
input[type="url"],
input[type="number"],
select,
textarea {
    display: block;
    width: 100%;
    font: inherit;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    padding: 0.7rem 0.8rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: var(--card);
    color: var(--text);
    margin-bottom: 1rem;
}

input.code-input {
    font-size: 1.75rem;
    letter-spacing: 0.4em;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

button {
    font: inherit;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    cursor: pointer;
    border-radius: var(--radius);
    padding: 0.75rem 1.1rem;
    min-height: 48px;
}

.btn-primary {
    display: block;
    width: 100%;
    background: var(--brand);
    color: #ffffff;
    border: 2px solid var(--brand);
    font-weight: 600;
}

.btn-primary:hover {
    background: var(--brand-dark);
    border-color: var(--brand-dark);
}

.btn-primary[disabled] {
    opacity: 0.6;
    cursor: wait;
}

.btn-link {
    background: none;
    border: none;
    color: var(--brand);
    text-decoration: underline;
    padding: 0.5rem 0;
    min-height: 44px;
}

.actions-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.turnstile-box {
    min-height: 65px;
    margin-bottom: 1rem;
}

.message {
    border-radius: var(--radius);
    padding: 0.75rem 0.9rem;
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.message:empty {
    display: none;
}

.message.error {
    background: var(--error-bg);
    color: var(--error-text);
}

.message.ok {
    background: var(--ok-bg);
    color: var(--ok-text);
}

.help {
    margin-top: 1.5rem;
}

[hidden] {
    display: none !important;
}

/* ---- Google sign-in button and divider (v2) ----
   text #1d1d1b on #fff 16.9:1 · border #767670 4.6:1 · divider text #5a5a55 6.9:1 */
.btn-google {
    display: block;
    width: 100%;
    background: var(--card);
    color: var(--text);
    border: 2px solid var(--border);
    font-weight: 600;
}

.btn-google:hover {
    background: var(--bg);
}

.btn-google[disabled] {
    opacity: 0.6;
    cursor: wait;
}

.divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 1.25rem 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.divider::before,
.divider::after {
    content: "";
    flex: 1;
    border-top: 1px solid var(--border);
}

/* ---- v3: site navigation, wide pages, recipe cards, settings ----
   nav links #1f4e3d on #faf7f2 8.9:1 · "coming soon" #5a5a55 on #faf7f2 6.5:1
   badge #5a5a55 on #fff 6.9:1 · draft badge #6b4a00 on #fff4e0 7.4:1
   card meta #5a5a55 on #fff 6.9:1 */
.site-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0 1.1rem;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 1rem;
}

.site-nav a,
.site-nav .btn-link {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0;
    color: var(--brand);
}

.site-nav a[aria-current="page"] {
    font-weight: 600;
    text-decoration: none;
}

.site-nav .nav-soon {
    color: var(--muted);
}

main.wide {
    max-width: 60rem;
}

.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 0.5rem 0 1rem;
}

.page-head h1 {
    margin: 0;
}

.btn-primary.inline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    min-height: 48px;
    padding: 0.75rem 1.1rem;
    border-radius: var(--radius);
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    text-decoration: none;
}

.btn-primary.soon[disabled] {
    cursor: not-allowed;
}

h2 {
    font-size: 1.25rem;
    line-height: 1.3;
    margin: 0 0 0.5rem;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.search-row input {
    margin-bottom: 0.4rem;
}

.recipe-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
}

.recipe-card > a,
.recipe-card > div {
    display: block;
    height: 100%;
    background: var(--card);
    color: var(--text);
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    overflow: hidden;
    text-decoration: none;
}

.recipe-card > a:hover h2 {
    text-decoration: underline;
}

.recipe-card img,
.recipe-card .thumb-blank {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    background: #efe9df;
}

.recipe-card .thumb-blank {
    aspect-ratio: auto;
    height: 0.5rem;
    background: var(--brand);
}

.recipe-card .body {
    padding: 0.75rem 1rem 1rem;
}

.recipe-card h2 {
    font-size: 1.15rem;
    margin-bottom: 0.4rem;
}

.recipe-card .meta {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.badges {
    margin: 0 0 0.35rem;
}

.badge {
    display: inline-block;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 0.8rem;
    line-height: 1.4;
    padding: 0.1rem 0.55rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
    background: var(--card);
}

.badge.draft {
    color: #6b4a00;
    background: #fff4e0;
    border-color: #6b4a00;
}

.hint {
    margin: -0.15rem 0 0.4rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.optional {
    font-weight: normal;
    color: var(--muted);
}

textarea {
    resize: vertical;
    min-height: 5rem;
}

fieldset.choice {
    border: none;
    margin: 0 0 1rem;
    padding: 0;
}

fieldset.choice legend {
    font-weight: bold;
    margin-bottom: 0.25rem;
    padding: 0;
}

fieldset.choice label {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-height: 44px;
    margin: 0;
    font-weight: normal;
}

fieldset.choice input[type="radio"] {
    width: 1.25rem;
    height: 1.25rem;
    margin: 0;
    accent-color: var(--brand);
}

/* ---- v4: recipe editor ----
   secondary button #1f4e3d on #fff 9.5:1 · danger #8a1c1c on #fff 9.3:1
   invalid border #8a1c1c · unlinked catalog text #5a5a55 6.9:1
   save bar text #1d1d1b on #fff 16.9:1 · unsaved #6b4a00 on #fff 8.1:1 */
.back {
    margin: 0 0 0.25rem;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 0.95rem;
}

.editor .ed-section {
    margin-bottom: 1.25rem;
}

.editor h2 {
    font-size: 1.35rem;
    margin-bottom: 0.75rem;
}

.ed-grid {
    display: grid;
    gap: 0 1rem;
    grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
}

.ed-grid.four {
    grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr));
}

select {
    padding: 0.6rem 0.5rem;
}

input.invalid,
textarea.invalid {
    border-color: var(--error-text);
    background: var(--error-bg);
}

.btn-secondary {
    background: var(--card);
    color: var(--brand);
    border: 2px solid var(--brand);
    font-weight: 600;
}

.btn-secondary:hover {
    background: var(--ok-bg);
}

.btn-danger {
    background: var(--card);
    color: var(--error-text);
    border: 2px solid var(--error-text);
    font-weight: 600;
}

.btn-danger:hover {
    background: var(--error-bg);
}

.btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.ed-list {
    list-style: none;
    margin: 0 0 0.5rem;
    padding: 0;
}

.ed-row {
    border-top: 1px solid #e3ddd3;
    padding: 0.75rem 0;
}

.ed-row:first-child {
    border-top: none;
}

.ed-row input,
.ed-row select,
.ed-row textarea {
    margin-bottom: 0.4rem;
}

/* phones: amount + unit on one line, then the name, then the prep note */
.ed-ing {
    display: grid;
    gap: 0 0.5rem;
    grid-template-columns: 6rem 1fr;
}

.ed-ing .item,
.ed-ing .note {
    grid-column: 1 / -1;
}

@media (min-width: 46rem) {
    .ed-ing {
        grid-template-columns: 5.5rem 7rem 1.4fr 1fr;
    }
    .ed-ing .item,
    .ed-ing .note {
        grid-column: auto;
    }
}

.ed-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.75rem;
    background: var(--ok-bg);
    border-left: 5px solid var(--brand);
    padding: 0.6rem 0.75rem;
    border-radius: var(--radius);
    border-top: none;
    margin: 0.75rem 0 0.25rem;
}

.ed-heading input {
    flex: 1 1 12rem;
    font-weight: bold;
    margin: 0;
}

.ed-heading label {
    margin: 0;
}

.ed-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 1rem;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

.ed-foot select,
.ed-foot input {
    margin: 0;
}

label.small {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 0.9rem;
    font-weight: normal;
    min-height: 44px;
}

label.small select {
    width: auto;
    max-width: 11rem;
    padding: 0.35rem 0.4rem;
    font-size: 0.9rem;
}

label.small.cat.unlinked {
    color: var(--muted);
}

input.tiny {
    width: 5rem;
    padding: 0.4rem 0.5rem;
}

.ed-foot > select {
    width: auto;
    padding: 0.4rem;
}

.row-tools {
    margin-left: auto;
    display: inline-flex;
    gap: 0.25rem;
}

.icon-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    background: var(--card);
    color: var(--brand);
    border: 1px solid var(--border);
    font-size: 1.1rem;
    line-height: 1;
}

.icon-btn:hover {
    background: var(--ok-bg);
}

.paste {
    margin: 0 0 1rem;
    padding: 0.5rem 0.75rem;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}

.paste summary {
    cursor: pointer;
    color: var(--brand);
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    font-weight: 600;
    min-height: 44px;
    display: flex;
    align-items: center;
}

.paste textarea {
    margin-top: 0.5rem;
    font-size: 1rem;
}

.paste-list {
    margin: 0.25rem 0 0.75rem;
    padding-left: 1.5rem;
    font-size: 0.95rem;
}

.paste-list li {
    margin-bottom: 0.2rem;
}

.paste-sec {
    display: inline-block;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 0.8rem;
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0 0.45rem;
}

.paste-cat {
    color: var(--brand);
    font-size: 0.9rem;
}

fieldset.checks {
    border: none;
    margin: 0 0 1rem;
    padding: 0;
}

fieldset.checks legend {
    font-weight: bold;
    margin-bottom: 0.25rem;
    padding: 0;
}

.check-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
    gap: 0 0.75rem;
}

.check-grid label,
.check-inline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 44px;
    margin: 0;
    font-weight: normal;
}

.check-grid input,
.check-inline input {
    width: 1.2rem;
    height: 1.2rem;
    margin: 0;
    accent-color: var(--brand);
}

.inline-pair {
    display: flex;
    gap: 0.5rem;
}

.inline-pair select {
    width: 5.5rem;
}

.ed-danger {
    margin: 2rem 0 1rem;
    text-align: right;
}

body.has-savebar {
    padding-bottom: 5rem;
}

.savebar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--card);
    box-shadow: 0 -1px 6px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

.savebar-inner {
    max-width: 60rem;
    margin: 0 auto;
    padding: 0.6rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.save-status {
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 0.95rem;
}

.save-status.unsaved {
    color: #6b4a00;
    font-weight: 600;
}

.savebar .btn-primary.inline {
    min-width: 8rem;
}

/* ---- v5: editor clarity ----
   "Section" tag #1f4e3d on #e8f2ed 8.3:1 · link buttons #1f4e3d on #fff 9.5:1
   "Not added yet" #6b4a00 on #fff4e0 7.4:1 · preview numbers #5a5a55 on #fff 6.9:1 */
.sec-tag {
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--brand);
}

.link-btn {
    background: none;
    border: none;
    color: var(--brand);
    text-decoration: underline;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 0.9rem;
    min-height: 44px;
    padding: 0 0.35rem;
}

.ed-foot .link-btn:first-child {
    padding-left: 0;
}

.ed-extras {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0 1rem;
}

.ed-extras select {
    width: auto;
    padding: 0.4rem;
    margin: 0;
}

.ed-extras input {
    margin: 0;
}

.row-tools {
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
}

.paste .hint {
    margin-top: 0.25rem;
}

.paste.compact {
    border: none;
    padding: 0;
    margin: 0.5rem 0 0;
}

.paste.compact summary {
    font-weight: normal;
    text-decoration: underline;
}

.paste.compact[open] {
    border: 1px dashed var(--border);
    padding: 0.5rem 0.75rem;
}

.paste-preview {
    margin-top: 0.75rem;
}

.preview-head {
    margin: 0 0 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    background: #fff4e0;
    color: #6b4a00;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    font-weight: 600;
    font-size: 0.95rem;
}

.paste-list {
    list-style: none;
    padding-left: 0;
}

.paste-list .pv-sec {
    margin: 0.5rem 0 0.25rem;
    padding: 0.25rem 0.5rem;
    background: var(--ok-bg);
    border-left: 4px solid var(--brand);
    font-weight: bold;
}

.pv-n {
    display: inline-block;
    min-width: 1.6rem;
    color: var(--muted);
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 0.85rem;
}

/* ---- v6: collapsible editor sections ----
   summary text #5a5a55 on #fff 6.9:1 · "edited" tag #6b4a00 on #fff4e0 7.4:1 */
.ed-toggle-all {
    display: flex;
    gap: 0.5rem;
    margin: 0 0 0.5rem;
}

.ed-toggle-all .link-btn:first-child {
    padding-left: 0;
}

details.ed-section {
    padding-top: 0.25rem;
    padding-bottom: 0.25rem;
}

details.ed-section[open] {
    padding-bottom: 1.25rem;
}

/* Section bar: [chevron] [title] [edited] [Open/Close]
                          [summary line          ]
   chevron and pill #1f4e3d on #fff 9.5:1 and on hover #e8f2ed 8.3:1 */
details.ed-section > summary {
    list-style: none;
    cursor: pointer;
    display: grid;
    grid-template-columns: 1.5rem 1fr auto auto;
    grid-template-areas:
        "chev title edit pill"
        ".    sum   sum  sum";
    align-items: center;
    column-gap: 0.6rem;
    min-height: 48px;
    margin: 0 -0.6rem;
    padding: 0.45rem 0.6rem;
    border-radius: var(--radius);
}

details.ed-section > summary:hover,
details.ed-section > summary:active {
    background: var(--ok-bg);
}

details.ed-section > summary::-webkit-details-marker {
    display: none;
}

/* bold chevron: points right when closed, down when open */
details.ed-section > summary::before {
    content: "";
    grid-area: chev;
    justify-self: center;
    width: 0.65rem;
    height: 0.65rem;
    border-right: 3px solid var(--brand);
    border-bottom: 3px solid var(--brand);
    transform: rotate(-45deg);
    transition: transform 0.15s;
}

details.ed-section[open] > summary::before {
    transform: rotate(45deg);
    margin-top: -0.3rem;
}

/* says plainly what a tap does */
details.ed-section > summary::after {
    content: "Open";
    grid-area: pill;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--brand);
    border: 2px solid var(--brand);
    border-radius: 999px;
    padding: 0.15rem 0.75rem;
    background: var(--card);
}

details.ed-section[open] > summary::after {
    content: "Close";
}

.editor details.ed-section > summary h2 {
    grid-area: title;
    margin: 0;
    font-size: 1.3rem;
}

.ed-sum-text {
    grid-area: sum;
    color: var(--muted);
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 0.95rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

details.ed-section[open] > summary .ed-sum-text {
    display: none;
}

.ed-edited {
    grid-area: edit;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    color: #6b4a00;
    background: #fff4e0;
    border: 1px solid #6b4a00;
    border-radius: 999px;
    padding: 0 0.5rem;
}

details.ed-section[open] > summary .ed-edited {
    display: none;
}

.ed-body {
    margin-top: 0.5rem;
}
