﻿/* =====================================================================
   aks-dialog.css (2026-10-04)
   One dialog for the whole app, on the native <dialog> element: always centered,
   above everything (the browser's top layer), Escape closes it, focus stays inside.
   Opened with [data-dialog-open="id"], closed with [data-dialog-close] (aks-dialog.js).
   Its own class names (aks-dlg-*) so the older .aks-modal styles in recipes.css,
   recipe-index-modal.css and modal-system.css can't reach it.
   Navy / white / gold, like the Recipes page.
   ===================================================================== */

dialog.aks-dlg {
    --dlg-bg: #ffffff;
    --dlg-fg: #172f49;
    --dlg-muted: #64717d;
    --dlg-line: #e0e5e9;
    --dlg-line-strong: #cbd4dc;
    --dlg-primary: #173f66;
    --dlg-primary-hover: #0d3050;
    --dlg-danger: #b91c1c;
    --dlg-danger-hover: #991b1b;
    --dlg-warn-soft: #fdf6e2;
    --dlg-err-soft: #fdeceb;
    --dlg-gold: #c7932b;
    --dlg-focus: rgba(199, 99, 43, .35);
    box-sizing: border-box;
    width: min(460px, calc(100vw - 32px));
    max-height: calc(100dvh - 48px);
    margin: auto;            /* centered on every screen size */
    padding: 0;
    border: 0;
    border-radius: 14px;
    background: var(--dlg-bg);
    color: var(--dlg-fg);
    box-shadow: 0 24px 64px rgba(16, 32, 52, .28), 0 2px 6px rgba(16, 32, 52, .08);
    font-family: var(--aks-font-body, "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
    font-size: .9375rem;
    line-height: 1.5;
    overflow: hidden;
}

dialog.aks-dlg--wide { width: min(560px, calc(100vw - 32px)); }

dialog.aks-dlg[open] {
    display: flex;
    flex-direction: column;
}

dialog.aks-dlg *,
dialog.aks-dlg *::before,
dialog.aks-dlg *::after { box-sizing: border-box; }

dialog.aks-dlg [hidden] { display: none !important; }

dialog.aks-dlg::backdrop {
    background: rgba(16, 28, 42, .48);
    backdrop-filter: blur(2px);
}

/* The page behind doesn't scroll while a dialog is open */
html:has(dialog.aks-dlg[open]) { overflow: hidden; }

@media (prefers-reduced-motion: no-preference) {
    dialog.aks-dlg[open] { animation: aks-dlg-in .16s ease-out; }
    dialog.aks-dlg[open]::backdrop { animation: aks-dlg-fade .16s ease-out; }
}
@keyframes aks-dlg-in { from { opacity: 0; transform: translateY(6px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes aks-dlg-fade { from { opacity: 0; } to { opacity: 1; } }

/* A form inside fills the dialog so the footer stays at the bottom */
dialog.aks-dlg > form {
    display: flex;
    flex-direction: column;
    min-height: 0;
    margin: 0;
}

.aks-dlg-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 20px 22px 0;
}

.aks-dlg-eyebrow {
    display: block;
    margin-bottom: 2px;
    color: var(--dlg-muted);
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.aks-dlg-title {
    margin: 0;
    color: var(--dlg-fg);
    font-family: inherit;
    font-size: 1.125rem;
    font-weight: 650;
    line-height: 1.35;
    text-wrap: balance;
    overflow-wrap: anywhere;
}

.aks-dlg-x {
    display: grid;
    flex: none;
    place-items: center;
    width: 32px;
    height: 32px;
    margin: -4px -8px 0 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--dlg-muted);
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
}
.aks-dlg-x:hover { background: #f1f3f5; color: var(--dlg-fg); }

.aks-dlg-body {
    display: grid;
    gap: 12px;
    padding: 12px 22px 18px;
    overflow-y: auto;
    min-height: 0;
}
.aks-dlg-body p { margin: 0; }
.aks-dlg-muted { color: var(--dlg-muted); font-size: .875rem; }

.aks-dlg-note {
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--dlg-warn-soft);
    color: var(--dlg-fg);
    font-size: .9rem;
}
.aks-dlg-note--error { background: var(--dlg-err-soft); color: #7f1d1d; }

.aks-dlg-field { display: grid; gap: 5px; }
.aks-dlg-field label { font-size: .85rem; font-weight: 600; color: var(--dlg-fg); }
.aks-dlg-field label span { font-weight: 400; color: var(--dlg-muted); }
.aks-dlg-field input,
.aks-dlg-field textarea {
    width: 100%;
    min-height: 42px;
    padding: 9px 12px;
    border: 1px solid var(--dlg-line-strong);
    border-radius: 10px;
    background: #fff;
    color: var(--dlg-fg);
    font: inherit;
}
.aks-dlg-field textarea { resize: vertical; min-height: 84px; }
.aks-dlg-field input:focus,
.aks-dlg-field textarea:focus { outline: 2px solid var(--dlg-primary); outline-offset: 1px; border-color: var(--dlg-primary); }

.aks-dlg-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 22px 18px;
    border-top: 1px solid var(--dlg-line);
    background: #fafbfc;
}
.aks-dlg-foot-note { flex: 1 1 200px; margin: 0; color: var(--dlg-muted); font-size: .8rem; line-height: 1.4; }

.aks-dlg-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: 10px;
    font: inherit;
    font-size: .9rem;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    text-decoration: none;
}
.aks-dlg-btn:focus-visible { outline: 3px solid var(--dlg-focus); outline-offset: 2px; }
.aks-dlg-btn:disabled { opacity: .65; cursor: progress; }
.aks-dlg-btn--secondary { background: #fff; border-color: var(--dlg-line-strong); color: var(--dlg-fg); }
.aks-dlg-btn--secondary:hover { background: #f5f7f9; }
.aks-dlg-btn--primary { background: var(--dlg-primary); color: #fff; }
.aks-dlg-btn--primary:hover { background: var(--dlg-primary-hover); }
.aks-dlg-btn--danger { background: var(--dlg-danger); color: #fff; }
.aks-dlg-btn--danger:hover { background: var(--dlg-danger-hover); }

/* Phone: buttons share the row and stay easy to hit */
@media (max-width: 480px) {
    .aks-dlg-head { padding: 18px 18px 0; }
    .aks-dlg-body { padding: 10px 18px 16px; }
    .aks-dlg-foot { padding: 12px 18px 16px; }
    .aks-dlg-foot .aks-dlg-btn { flex: 1 1 0; }
    .aks-dlg-foot-note { flex-basis: 100%; }
}
