/* ==========================================================================
   Greendale Cooking — calm, editorial, low-ornament
   ========================================================================== */

:root {
    --paper:      #f6efe2;
    --paper-2:    #fdf8ec;
    --ink:        #1a120b;
    --ink-mute:   #6b5f50;
    --ink-faint:  #a09281;
    --rule:       #dcd0b8;
    --paprika:    #bf4b1f;
    --paprika-2:  #97361a;
    --danger:     #8a2318;

    --radius:     4px;
    --shadow:     0 10px 30px -18px rgba(26, 18, 11, 0.35);

    --font-ui:    'IBM Plex Sans', system-ui, sans-serif;
    --font-serif: 'Fraunces', 'Times New Roman', serif;

    --ease:       cubic-bezier(0.2, 0.7, 0.15, 1);
}

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

html, body {
    margin: 0;
    padding: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 16px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body { display: flex; flex-direction: column; min-height: 100vh; }

img { max-width: 100%; display: block; }

button {
    font: inherit;
    color: inherit;
    background: none;
    border: 0;
    cursor: pointer;
    padding: 0;
}

a { color: inherit; text-decoration: none; transition: color .2s var(--ease); }

::selection { background: rgba(191, 75, 31, 0.2); }

.container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 clamp(1rem, 4vw, 2rem);
}

.container--narrow { max-width: 760px; }

.main { flex: 1; padding: 2rem 0 5rem; }

/* Masthead */

.masthead {
    border-bottom: 1px solid var(--rule);
    background: rgba(246, 239, 226, 0.92);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 30;
}

.masthead-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 0;
}

.masthead-brand {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    font-weight: 500;
    color: var(--ink);
    letter-spacing: -0.01em;
}

.masthead-brand:hover { color: var(--paprika); }

.masthead-nav {
    display: flex;
    align-items: center;
    gap: clamp(0.75rem, 3vw, 1.25rem);
    flex-wrap: wrap;
}

.masthead-nav a,
.masthead-nav .linkish {
    font-size: 0.92rem;
    color: var(--ink-mute);
    font-weight: 500;
}

.masthead-nav a:hover,
.masthead-nav .linkish:hover { color: var(--paprika); }

.masthead-nav form { margin: 0; }

@media (max-width: 380px) {
    .masthead-inner { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
}

/* Typography */

h1, h2, h3 {
    font-family: var(--font-serif);
    font-weight: 500;
    line-height: 1.1;
    letter-spacing: -0.015em;
    margin: 0;
}

h1 { font-size: clamp(1.8rem, 3.8vw, 2.6rem); }
h2 { font-size: clamp(1.15rem, 2vw, 1.3rem); font-weight: 600; }

p { margin: 0 0 1rem; }

.page-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 2rem;
}

/* Buttons */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.1rem;
    font-size: 0.92rem;
    font-weight: 500;
    color: var(--paper);
    background: var(--ink);
    border-radius: 999px;
    transition: background .2s var(--ease);
}

.btn:hover { background: var(--paprika); }
.btn--primary { background: var(--paprika); }
.btn--primary:hover { background: var(--paprika-2); }

.link {
    color: var(--paprika);
    font-weight: 500;
    border-bottom: 1px solid currentColor;
    padding-bottom: 1px;
}

.link:hover { color: var(--paprika-2); }

.back-link {
    display: inline-block;
    color: var(--ink-mute);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    transition: color .2s var(--ease), transform .2s var(--ease);
}

.back-link:hover { color: var(--paprika); transform: translateX(-2px); }

.btn-subtle-danger {
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 0.9rem;
    font-size: 0.85rem;
    color: var(--ink-faint);
    border: 1px solid var(--rule);
    border-radius: 999px;
    background: transparent;
    transition: color .2s var(--ease), border-color .2s var(--ease), background .2s var(--ease);
}

.btn-subtle-danger:hover {
    color: var(--paper);
    background: var(--danger);
    border-color: var(--danger);
}

.linkish { color: inherit; }

/* Recipe list */

.recipe-list {
    list-style: none;
    padding: 0;
    margin: 0;
    border-top: 1px solid var(--rule);
}

.recipe-list li { border-bottom: 1px solid var(--rule); }

.recipe-row {
    display: grid;
    grid-template-columns: 3.2rem minmax(0, 1fr);
    gap: 1rem;
    align-items: center;
    padding: 0.9rem 0;
    transition: padding .25s var(--ease);
}

.recipe-row:hover { padding-left: 0.5rem; }

.recipe-row__thumb {
    width: 3.2rem;
    height: 3.2rem;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--paper-2), #e9dec6) center/cover;
    box-shadow: inset 0 0 0 1px var(--rule);
    flex-shrink: 0;
    transition: transform .3s var(--ease);
}

.recipe-row:hover .recipe-row__thumb { transform: scale(1.05); }

.recipe-row__body { min-width: 0; display: flex; flex-direction: column; gap: 0.15rem; }

.recipe-row__title {
    font-family: var(--font-serif);
    font-size: 1.15rem;
    font-weight: 500;
    color: var(--ink);
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color .2s var(--ease);
}

.recipe-row:hover .recipe-row__title { color: var(--paprika); }

.recipe-row__meta {
    font-size: 0.82rem;
    color: var(--ink-mute);
    display: inline-flex;
    gap: 0.7rem;
    flex-wrap: wrap;
    align-items: center;
}

.tag-thermomix {
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--paper);
    background: var(--ink);
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
}

.empty-state {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--ink-mute);
}

.empty-state p { font-family: var(--font-serif); font-size: 1.3rem; font-style: italic; }

.danger-zone {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px dotted var(--rule);
    display: flex;
    justify-content: center;
}

/* Compose (AI page) */

.compose { display: flex; flex-direction: column; gap: 1.75rem; }

.field { display: flex; flex-direction: column; gap: 0.4rem; }

.field label { font-size: 0.85rem; font-weight: 500; color: var(--ink-mute); }

.field-hint, .field-hint-inline { font-size: 0.8rem; color: var(--ink-faint); }

.field-hint-inline { font-weight: 400; margin-left: 0.4rem; }
.field-hint { margin: 0.2rem 0 0; }

.field textarea,
.field input[type="text"],
.field input[type="password"] {
    width: 100%;
    background: var(--paper-2);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: 0.8rem 0.9rem;
    font: inherit;
    font-size: 1rem;
    color: var(--ink);
    resize: vertical;
    transition: border-color .2s var(--ease), background .2s var(--ease);
}

.field textarea:focus,
.field input:focus {
    outline: none;
    border-color: var(--paprika);
    background: #fffaf0;
}

.upload {
    display: block;
    position: relative;
    border: 1.5px dashed var(--rule);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
    color: var(--ink-mute);
    background: var(--paper-2);
    cursor: pointer;
    overflow: hidden;
    transition: border-color .2s var(--ease), color .2s var(--ease);
    min-height: 3rem;
}

.upload:hover { border-color: var(--paprika); color: var(--paprika); }
.upload:focus-within { border-color: var(--paprika); color: var(--paprika); }

.upload input[type="file"] {
    position: absolute;
    width: 1px; height: 1px;
    inset: 0 auto auto 0;
    opacity: 0;
    pointer-events: none;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
    overflow: hidden;
}

.upload__text { font-size: 0.92rem; }

.upload__preview {
    display: none;
    position: relative;
    margin-top: 0.75rem;
    width: fit-content;
    max-width: 100%;
}

.upload__preview img {
    width: 100%;
    max-width: 280px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.upload__preview button {
    position: absolute;
    top: 0.4rem;
    right: 0.4rem;
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 999px;
    background: rgba(26, 18, 11, 0.75);
    color: var(--paper);
    font-size: 1.1rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.compose__actions { display: flex; justify-content: flex-end; }

.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    border-left: 3px solid var(--danger);
    background: rgba(138, 35, 24, 0.08);
    color: var(--danger);
    font-size: 0.9rem;
}

/* Article (detail) */

.article { display: flex; flex-direction: column; gap: 2rem; }

.article__head { display: flex; flex-direction: column; gap: 0.5rem; }

.article__kicker {
    font-size: 0.78rem;
    color: var(--paprika);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-weight: 500;
}

.article__title {
    font-family: var(--font-serif);
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 420;
    line-height: 1.05;
    color: var(--ink);
    text-wrap: balance;
    margin-top: 0.25rem;
}

.article__title--pending {
    color: var(--ink-mute);
    font-style: italic;
    font-weight: 360;
    position: relative;
}

.article__title--pending::after {
    content: "";
    display: inline-block;
    width: 0.5em;
    height: 0.08em;
    background: var(--paprika);
    margin-left: 0.3em;
    transform: translateY(-0.3em);
    animation: blink 1.2s infinite var(--ease);
}

@keyframes blink {
    0%, 40% { opacity: 1; }
    50%, 100% { opacity: 0.2; }
}

.article__lede {
    color: var(--ink-mute);
    font-size: 1.05rem;
    max-width: 55ch;
    margin-top: 0.25rem;
}

.article__credits {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem 1.5rem;
    margin: 0.75rem 0 0;
    padding: 0.75rem 0 0;
    border-top: 1px solid var(--rule);
    font-size: 0.85rem;
}

.article__credits > div { min-width: 0; }

.article__credits dt {
    color: var(--ink-faint);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.15rem;
}

.article__credits dd { margin: 0; color: var(--ink); font-weight: 500; }

@media (max-width: 560px) {
    .article__credits { grid-template-columns: repeat(2, 1fr); }
}

.article__hero img {
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.article__hero--pending .skeleton--hero {
    width: 100%;
    aspect-ratio: 16 / 10;
    border-radius: var(--radius);
    background: linear-gradient(90deg, var(--paper-2), #ebe1c9, var(--paper-2));
    background-size: 200% 100%;
    animation: shimmer 1.8s infinite linear;
    display: grid;
    place-items: center;
    color: var(--ink-faint);
    font-size: 0.9rem;
    font-family: var(--font-serif);
    font-style: italic;
}

@keyframes shimmer {
    from { background-position: 200% 0; }
    to   { background-position: -100% 0; }
}

.article__body {
    display: grid;
    grid-template-columns: minmax(0, 4fr) minmax(0, 7fr);
    gap: 3rem;
    align-items: start;
}

@media (max-width: 760px) {
    .article__body { grid-template-columns: 1fr; gap: 2rem; }
}

.section-label {
    font-size: 0.8rem;
    color: var(--ink-faint);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 500;
    border-bottom: 1px solid var(--ink);
    padding-bottom: 0.3rem;
    margin: 0 0 0.75rem;
}

/* Ingredients */

.ingredient-list { list-style: none; padding: 0; margin: 0; }

.ingredient-list li {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.3rem 0.9rem;
    padding: 0.5rem 0;
    border-bottom: 1px dotted var(--rule);
    align-items: baseline;
}

.ingredient-list li:last-child { border-bottom: 0; }

.ingredient-qty {
    color: var(--paprika);
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.ingredient-qty .unit { color: var(--ink-mute); font-weight: 400; margin-left: 0.2rem; }

.ingredient-name { color: var(--ink); }

.ingredient-note {
    grid-column: 2 / -1;
    color: var(--ink-mute);
    font-size: 0.85rem;
    font-style: italic;
    margin-top: 0.1rem;
}

/* Steps */

.steps {
    list-style: none;
    padding: 0;
    margin: 0;
    counter-reset: step;
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
}

.step {
    display: grid;
    grid-template-columns: 2.2rem minmax(0, 1fr);
    gap: 1rem;
    counter-increment: step;
    align-items: start;
}

.step__num {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    font-weight: 420;
    font-style: italic;
    color: var(--paprika);
    line-height: 1;
    font-variant-numeric: lining-nums;
    padding-top: 0.15rem;
}

.step__num::before { content: counter(step, decimal-leading-zero); }

.step__body > p { margin: 0 0 0.5rem; line-height: 1.6; }

.step__meta {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    font-size: 0.78rem;
    color: var(--ink-mute);
}

.step__meta span {
    background: var(--paper-2);
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    border: 1px solid var(--rule);
    font-variant-numeric: tabular-nums;
}

/* Skeletons */

.skeleton-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.skeleton-list li {
    height: 1.1rem;
    background: linear-gradient(90deg, var(--paper-2), #ebe1c9, var(--paper-2));
    background-size: 200% 100%;
    animation: shimmer 1.8s infinite linear;
    border-radius: 4px;
}

.skeleton-list li:nth-child(2) { width: 85%; }
.skeleton-list li:nth-child(3) { width: 70%; }
.skeleton-list li:nth-child(4) { width: 90%; }
.skeleton-list li:nth-child(5) { width: 60%; }

/* Suggestions */

.suggestions {
    background: var(--paper-2);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: 1.25rem 1.25rem 0.5rem;
}

.suggestions__intro { color: var(--ink-mute); font-size: 0.95rem; margin-bottom: 0.75rem; }

.suggestions__list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; }

.suggestions__list li { border-top: 1px solid var(--rule); }
.suggestions__list li:first-child { border-top: 0; }

.suggestions__list form { margin: 0; }

.suggestion {
    display: grid;
    grid-template-columns: 1.8rem minmax(0, 1fr) 1.2rem;
    gap: 0.9rem;
    align-items: center;
    width: 100%;
    text-align: left;
    padding: 1rem 0;
    transition: padding .25s var(--ease), color .2s var(--ease);
}

.suggestion:hover { padding-left: 0.5rem; }
.suggestion:hover .suggestion__title { color: var(--paprika); }
.suggestion:hover .suggestion__arrow { transform: translateX(2px); color: var(--paprika); }

.suggestion__num {
    font-family: var(--font-serif);
    font-style: italic;
    color: var(--ink-faint);
    font-size: 1.1rem;
    font-variant-numeric: lining-nums;
}

.suggestion__body { display: flex; flex-direction: column; gap: 0.2rem; min-width: 0; }

.suggestion__title {
    font-family: var(--font-serif);
    font-size: 1.2rem;
    font-weight: 500;
    color: var(--ink);
    transition: color .2s var(--ease);
}

.suggestion__desc { color: var(--ink-mute); font-size: 0.9rem; line-height: 1.4; }

.suggestion__arrow {
    color: var(--ink-faint);
    transition: transform .25s var(--ease), color .2s var(--ease);
}

.article__footer {
    display: flex;
    justify-content: center;
    padding-top: 1rem;
    border-top: 1px dotted var(--rule);
}

.failed-block {
    background: rgba(138, 35, 24, 0.06);
    border: 1px solid rgba(138, 35, 24, 0.2);
    border-left: 3px solid var(--danger);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    color: var(--ink-mute);
}

.failed-block__actions {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 0.75rem;
}

.failed-block__actions form { margin: 0; }

/* Login */

.login {
    min-height: 60vh;
    display: grid;
    place-items: center;
    padding: 3rem 0;
}

.login__card {
    width: 100%;
    max-width: 420px;
    background: var(--paper-2);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
}

.login__title {
    font-family: var(--font-serif);
    font-size: 1.8rem;
    font-weight: 500;
    margin: 0 0 0.25rem;
}

.login__subtitle { color: var(--ink-mute); font-size: 0.95rem; margin-bottom: 1.5rem; }

.login__form { display: flex; flex-direction: column; gap: 1rem; }
.login__form .btn { justify-content: center; margin-top: 0.5rem; }

/* Debug panel (admin only) */

.debug-panel {
    margin-top: 1rem;
    padding: 0.9rem 1.1rem;
    background: rgba(26, 18, 11, 0.03);
    border: 1px dashed var(--rule);
    border-radius: var(--radius);
    font-family: ui-monospace, 'SF Mono', Consolas, monospace;
    font-size: 0.8rem;
    color: var(--ink-mute);
}

.debug-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.8rem;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink);
    background: var(--paper-2);
    border: 1px solid var(--rule);
    border-radius: 999px;
    cursor: pointer;
    transition: background .2s var(--ease), border-color .2s var(--ease);
}

.debug-toggle:hover {
    background: var(--paper);
    border-color: var(--ink-faint);
}

.debug-toggle__chevron {
    color: var(--ink-faint);
    transition: transform .2s var(--ease);
    display: inline-block;
}

.debug-toggle--open .debug-toggle__chevron { transform: rotate(90deg); color: var(--paprika); }

.debug-body { margin-top: 0.75rem; }

.debug-image {
    margin: 0.75rem 0;
    max-width: 320px;
}

.debug-image img {
    width: 100%;
    border-radius: var(--radius);
    border: 1px solid var(--rule);
}

.debug-grid {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: 0.25rem 1rem;
    margin: 0.75rem 0;
}

.debug-grid dt {
    color: var(--ink-faint);
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.05em;
}
.debug-grid dd { margin: 0; color: var(--ink); word-break: break-word; }

.debug-heading {
    font-family: var(--font-ui);
    font-size: 0.72rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-faint);
    margin: 1rem 0 0.4rem;
}

.debug-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
}

.debug-table th, .debug-table td {
    padding: 0.3rem 0.5rem;
    text-align: left;
    border-bottom: 1px dotted var(--rule);
    vertical-align: top;
}

.debug-table th {
    color: var(--ink-faint);
    font-weight: 500;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    background: rgba(26, 18, 11, 0.04);
}

.debug-table td:nth-child(1) { color: var(--ink-faint); width: 2rem; }
.debug-table td:nth-child(2),
.debug-table td:nth-child(3),
.debug-table td:nth-child(4) { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Colophon */

.colophon {
    padding: 1.25rem 0;
    border-top: 1px solid var(--rule);
    color: var(--ink-faint);
    font-size: 0.82rem;
    text-align: center;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
