/* ==========================================================================
   Kitchen — the pantry, and the shopping list beside it.

   Requires css/design-tokens.css.

   This is the input the whole product runs on: nothing gets generated from an
   empty kitchen. So the page optimises for editing a long list quickly rather
   than for looking at it — dense rows, inline edit, and the filters that make
   170 items reachable.
   ========================================================================== */

body.kitchen-page {
    background-color: var(--paper);
    color: var(--ink);
    font-family: var(--font-ui);
    -webkit-font-smoothing: antialiased;
}

.kitchen-header {
    padding: 40px 0 24px;
    background: linear-gradient(180deg, var(--tile-green) 0%, var(--paper) 100%);
    border-bottom: 1px solid var(--divider);
}

.kitchen-header__inner,
.kitchen-shell {
    max-width: 860px;
    margin: 0 auto;
    padding: 0 20px;
}

.kitchen-shell { padding-bottom: 80px; }

.kitchen-header__kicker {
    display: block;
    margin-bottom: 4px;
    font-family: var(--font-display);
    font-style: italic;
    font-size: 1rem;
    color: var(--turmeric-text);
}

.kitchen-header__title {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(1.8rem, 1.4rem + 1.6vw, 2.4rem);
    line-height: 1.14;
    color: var(--ink);
}

.kitchen-header__lead {
    max-width: 60ch;
    margin: 10px 0 0;
    font-size: 0.98rem;
    line-height: 1.6;
    color: var(--dark-grey);
}

/* --------------------------------------------------------------------------
   Kitchen / Shopping switch
   -------------------------------------------------------------------------- */

.kt-tabs {
    display: flex;
    gap: 4px;
    margin: 22px 0 0;
    border-bottom: 1px solid var(--divider);
}

.kt-tab {
    padding: 11px 16px;
    border: 0;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--cement-grey);
    font-family: var(--font-ui);
    font-size: 0.98rem;
    font-weight: 600;
    cursor: pointer;
}

.kt-tab:hover { color: var(--cardamom); }

.kt-tab[aria-selected="true"] {
    border-bottom-color: var(--cardamom);
    color: var(--cardamom);
}

.kt-tab__count {
    margin-left: 6px;
    font-family: var(--font-data);
    font-variant-numeric: tabular-nums;
    font-size: 0.8rem;
    opacity: 0.75;
}

.kt-tab:focus-visible,
.kt-chip:focus-visible,
.kt-btn:focus-visible,
.kt-icon-btn:focus-visible,
.kt-search input:focus-visible {
    outline: 3px solid var(--turmeric);
    outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Toolbar: search, filters, add
   -------------------------------------------------------------------------- */

.kt-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 20px 0 14px;
    flex-wrap: wrap;
}

.kt-search {
    position: relative;
    flex: 1 1 240px;
    min-width: 0;
}

.kt-search input {
    width: 100%;
    min-height: 44px;
    padding: 10px 14px 10px 38px;
    border: 1px solid var(--divider);
    border-radius: var(--r-sm);
    background: #fff;
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 0.95rem;
}

.kt-search input:focus { border-color: var(--cardamom); }

.kt-search svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--arrow-grey);
    pointer-events: none;
}

.kt-filters {
    display: flex;
    gap: 8px;
    margin: 0 0 18px;
    padding: 2px 0 6px;
    list-style: none;
    overflow-x: auto;
    scrollbar-width: thin;
}

.kt-chip {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    border: 1px solid var(--divider);
    border-radius: 999px;
    background: #fff;
    color: var(--cardamom);
    font-family: var(--font-ui);
    font-size: 0.88rem;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
}

.kt-chip:hover { background: var(--tile-green); }

.kt-chip[aria-pressed="true"] {
    background: var(--cardamom);
    border-color: var(--cardamom);
    color: var(--paper);
}

/* The expired chip is the one filter that carries a count, because it is the
   only one whose size is a problem worth surfacing. */
.kt-chip--expired {
    border-color: rgba(178, 59, 44, 0.4);
    color: var(--chili);
}

.kt-chip--expired:hover { background: #FCF3F1; }

.kt-chip--expired[aria-pressed="true"] {
    background: var(--chili);
    border-color: var(--chili);
    color: #fff;
}

.kt-chip__count {
    font-family: var(--font-data);
    font-variant-numeric: tabular-nums;
    font-size: 0.78rem;
    font-weight: 700;
}

/* --------------------------------------------------------------------------
   Items
   -------------------------------------------------------------------------- */

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

.kt-group {
    margin: 0 0 8px;
    padding-top: 14px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--cement-grey);
}

.kt-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    margin-bottom: 8px;
    border: 1px solid var(--divider);
    border-radius: var(--r-md);
    background: #fff;
}

.kt-item__main { flex: 1 1 auto; min-width: 0; }

.kt-item__name {
    display: block;
    font-size: 0.98rem;
    font-weight: 600;
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
}

.kt-item__meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 3px;
    font-size: 0.84rem;
    color: var(--cement-grey);
}

.kt-item__amount {
    font-family: var(--font-data);
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    color: var(--cardamom);
}

.kt-flag {
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
}

/* Expired means the generator is already ignoring it, which is worth saying
   plainly rather than as a date the reader has to work out. */
.kt-flag--expired { background: #FCF3F1; color: var(--chili); }
.kt-flag--soon    { background: var(--turmeric-bg); color: var(--turmeric-text); }

.kt-item__actions { display: flex; gap: 4px; flex-shrink: 0; }

.kt-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--cement-grey);
    cursor: pointer;
}

.kt-icon-btn:hover { background: var(--tile-green); color: var(--cardamom); }
.kt-icon-btn--danger:hover { background: #FCF3F1; color: var(--chili); }

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.kt-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 18px;
    border: 0;
    border-radius: var(--r-sm);
    background: var(--cardamom);
    color: var(--paper);
    font-family: var(--font-ui);
    font-size: 0.94rem;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.kt-btn:hover { background: var(--cardamom-strong); color: var(--paper); }
.kt-btn:disabled { opacity: 0.55; cursor: default; }

.kt-btn--ghost {
    background: transparent;
    color: var(--cardamom-strong);
    box-shadow: inset 0 0 0 1.4px rgba(11, 68, 51, 0.4);
}

.kt-btn--ghost:hover { background: rgba(11, 68, 51, 0.07); color: var(--cardamom-strong); }

/* --------------------------------------------------------------------------
   Editor
   -------------------------------------------------------------------------- */

.kt-editor {
    position: fixed;
    inset: 0;
    z-index: 1500;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background: rgba(20, 32, 25, 0.45);
}

.kt-editor[hidden] { display: none; }

.kt-editor__panel {
    width: 100%;
    max-width: 520px;
    max-height: 92vh;
    overflow-y: auto;
    padding: 24px;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    background: var(--paper);
}

@media (min-width: 640px) {
    .kt-editor { align-items: center; }
    .kt-editor__panel { border-radius: var(--r-lg); }
}

.kt-editor__title {
    margin: 0 0 18px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.3rem;
    color: var(--ink);
}

.kt-field { margin-bottom: 16px; }

.kt-field__label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.76rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--cement-grey);
}

.kt-field input,
.kt-field select {
    width: 100%;
    min-height: 46px;
    padding: 10px 14px;
    border: 1px solid var(--divider);
    border-radius: var(--r-sm);
    background: #fff;
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 0.96rem;
}

.kt-field input:focus,
.kt-field select:focus {
    border-color: var(--cardamom);
    outline: 2px solid rgba(11, 68, 51, 0.22);
    outline-offset: 1px;
}

.kt-field__hint {
    margin: 5px 0 0;
    font-size: 0.8rem;
    line-height: 1.45;
    color: var(--cement-grey);
}

.kt-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.kt-editor__actions {
    display: flex;
    gap: 10px;
    margin-top: 22px;
}

.kt-editor__actions .kt-btn { flex: 1 1 auto; }

/* --------------------------------------------------------------------------
   States
   -------------------------------------------------------------------------- */

.kt-state {
    padding: 44px 20px;
    text-align: center;
}

.kt-state__title {
    margin: 0 0 6px;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.2rem;
    color: var(--ink);
}

.kt-state__body {
    max-width: 44ch;
    margin: 0 auto 20px;
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--cement-grey);
}

.kt-skeleton {
    height: 62px;
    margin-bottom: 8px;
    border-radius: var(--r-md);
    background: linear-gradient(90deg, var(--tile-green) 25%, #eef3ef 37%, var(--tile-green) 63%);
    background-size: 400% 100%;
    animation: kt-shimmer 1.4s ease infinite;
}

@keyframes kt-shimmer {
    0%   { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

@media (prefers-reduced-motion: reduce) { .kt-skeleton { animation: none; } }

/* A save that lost a race needs saying out loud, because the fix is to reload
   and the user would otherwise retype into a document that will reject it. */
.kt-conflict {
    margin: 0 0 16px;
    padding: 14px 16px;
    border: 1px solid rgba(201, 138, 34, 0.4);
    border-left: 4px solid var(--turmeric);
    border-radius: var(--r-sm);
    background: var(--turmeric-bg);
    font-size: 0.92rem;
    line-height: 1.55;
    color: #6B4A0F;
}

.kt-conflict[hidden] { display: none; }
.kt-conflict button { margin-left: 8px; }

.is-hidden { display: none !important; }

@media (max-width: 640px) {
    .kitchen-header { padding: 28px 0 18px; }
    .kitchen-header__inner, .kitchen-shell { padding-left: 16px; padding-right: 16px; }
    .kt-toolbar { gap: 8px; }
    .kt-row { grid-template-columns: 1fr; gap: 0; }
    .kt-item__actions { flex-direction: column; }
}
