/* ==========================================================================
   Base: design tokens, reset, typography, buttons, forms, dialogs, utilities.
   Shared by the website, the admin panel and the legal pages.
   ========================================================================== */

:root {
  --primary: #7ab51d;
  --primary-dark: #5f8814;
  --primary-soft: rgba(122, 181, 29, 0.08);
  --accent: #e63946;
  --warning: #f39c12;
  --warning-dark: #b8720b;
  --success: #2ecc71;
  --dark: #1a1a1a;
  --text: #333333;
  --muted: #777777;
  --light: #f8f9fa;
  --border: #e0e0e0;
  --white: #ffffff;

  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-serif: 'Playfair Display', Georgia, serif;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 2px 12px rgba(0, 0, 0, 0.06);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.3);
  --gradient: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);

  --header-height: 80px; /* updated by JS from the real header height */
  --container: 1400px;
}

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

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

body {
  font-family: var(--font-sans);
  background: var(--white);
  color: var(--text);
  line-height: 1.6;
}

body:has(dialog[open]) {
  overflow: hidden;
}

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

a {
  color: var(--primary-dark);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--primary-dark);
  outline-offset: 2px;
}

.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 2rem;
}

.section-title {
  font-family: var(--font-serif);
  font-size: 2.4rem;
  text-align: center;
  margin-bottom: 1.1rem;
  color: var(--dark);
}

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

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: none;
  border-radius: var(--radius);
  padding: 0.8rem 1.4rem;
  font-weight: 700;
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--gradient);
  color: var(--white);
  box-shadow: 0 4px 12px rgba(122, 181, 29, 0.3);
}

.btn-primary:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(122, 181, 29, 0.4);
}

.btn-dark {
  background: var(--dark);
  color: var(--white);
}

.btn-dark:not(:disabled):hover {
  background: var(--primary);
}

.btn-outline {
  background: var(--white);
  border: 2px solid var(--border);
  color: var(--text);
}

.btn-outline:not(:disabled):hover {
  border-color: var(--primary);
  color: var(--primary-dark);
}

.btn-danger {
  background: var(--white);
  border: 2px solid var(--accent);
  color: var(--accent);
}

.btn-danger:not(:disabled):hover {
  background: var(--accent);
  color: var(--white);
}

.btn-block {
  width: 100%;
}

.btn-lg {
  padding: 1.1rem 2rem;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-link {
  background: none;
  border: none;
  color: var(--primary-dark);
  font-weight: 700;
  text-decoration: underline;
  padding: 0;
}

.icon-btn {
  background: none;
  border: none;
  font-size: 1.8rem;
  line-height: 1;
  color: inherit;
  padding: 0.2rem 0.4rem;
}

/* ── Forms ───────────────────────────────────────────────────────────────── */

fieldset {
  border: none;
  min-width: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.8rem;
}

.field label,
.field-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #555;
}

.input {
  width: 100%;
  padding: 0.7rem 0.8rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--white);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s;
}

.input:focus {
  border-color: var(--primary);
}

.input[aria-invalid='true'] {
  border-color: var(--accent);
}

textarea.input {
  resize: vertical;
  min-height: 80px;
}

.field-msg {
  font-size: 0.8rem;
  min-height: 0;
}

.field-msg.is-error {
  color: var(--accent);
}

.field-msg.is-ok {
  color: var(--primary-dark);
}

.field-msg.is-info {
  color: var(--muted);
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1rem;
}

.form-section-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: #555;
  margin: 1.1rem 0 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.alert {
  border-radius: var(--radius);
  padding: 0.8rem 1rem;
  font-size: 0.88rem;
  font-weight: 600;
}

.alert-error {
  background: #fdecea;
  border: 2px solid var(--accent);
  color: #c0293a;
}

.alert-info {
  background: #fff7ed;
  color: #9a3412;
}

/* ── Summary rows (cart, checkout, admin) ─────────────────────────────── */

.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 0.4rem;
}

.summary-row.is-warning {
  color: var(--warning);
}

.summary-total {
  display: flex;
  justify-content: space-between;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--primary);
  padding-top: 0.7rem;
  margin-top: 0.4rem;
  border-top: 2px solid var(--border);
}

.summary-row.is-info {
  font-size: 0.8rem;
  color: #999;
}

/* ── Choice cards (order type, payment, tip) ─────────────────────────────── */

.choice-group {
  display: grid;
  gap: 0.6rem;
  grid-template-columns: repeat(var(--cols, 2), 1fr);
}

.choice {
  border: 2px solid var(--border);
  background: var(--white);
  border-radius: 12px;
  padding: 0.9rem 0.6rem;
  font-weight: 700;
  color: var(--dark);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  text-align: center;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.choice:hover {
  border-color: var(--primary);
}

.choice[aria-pressed='true'] {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 2px 8px rgba(122, 181, 29, 0.2);
}

.choice-icon {
  font-size: 1.6rem;
}

.choice-hint {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
}

.choice-hint.is-warning {
  color: var(--warning);
}

.choice-badge {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--white);
  background: var(--primary);
  padding: 0.15rem 0.6rem;
  border-radius: 6px;
}

/* ── Dialogs ─────────────────────────────────────────────────────────────── */

dialog.modal {
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 0;
  width: min(94vw, 520px);
  max-height: calc(100dvh - 3rem);
  margin: auto;
  overflow: hidden;
  color: var(--text);
}

dialog.modal[open] {
  display: flex;
  flex-direction: column;
}

dialog.modal.modal-wide {
  width: min(94vw, 700px);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

.modal-header {
  background: var(--gradient);
  color: var(--white);
  padding: 1.1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}

.modal-header.is-warning {
  background: linear-gradient(135deg, #f59e0b, #d97706);
}

.modal-header.is-plain {
  background: var(--white);
  color: var(--dark);
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-subtitle {
  font-size: 0.82rem;
  opacity: 0.95;
}

.modal-body {
  padding: 1.4rem;
  overflow-y: auto;
  flex: 1;
}

.modal-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: 1.2rem;
}

.modal-actions > * {
  flex: 1;
}

/* ── Toast ───────────────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 9999;
  background: var(--dark);
  color: var(--white);
  padding: 0.9rem 1.4rem;
  border-radius: 12px;
  font-weight: 600;
  box-shadow: var(--shadow);
  transform: translateY(120px);
  opacity: 0;
  transition: transform 0.35s ease, opacity 0.35s ease;
  max-width: calc(100vw - 2rem);
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

.toast.is-error {
  background: var(--accent);
}

/* ── Small screens ───────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .container {
    padding: 0 1rem;
  }

  .section-title {
    font-size: 1.9rem;
  }

  .toast {
    left: 1rem;
    right: 1rem;
    bottom: 6rem;
  }
}

@media (max-width: 640px) {
  /* 16px inputs: no automatic zoom on iOS */
  .input {
    font-size: 16px;
    padding: 0.85rem;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  dialog.modal {
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
