/* ==========================================================================
   Tabla Public Site — Design System
   Implements UI-SPEC tokens: spacing, typography, color, layout, components.
   Per-restaurant theming via CSS custom properties on :root (inline <style>).
   ========================================================================== */

/* --- 1. Reset (minimal) --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
img, picture, svg { display: block; max-width: 100%; }

/* --- 2. Typography --- */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  font-weight: 400;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
}

/* Label / Small scale */
.label, small,
.menu-card-tags span,
.dietary-tag,
.status-tag,
.hours-closed,
.site-footer p {
  font-size: clamp(0.8125rem, 0.78rem + 0.15vw, 0.875rem);
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: 0.02em;
}

/* Section headings */
h2 {
  font-size: clamp(1.5rem, 1.2rem + 1.5vw, 2.25rem);
  font-weight: 300;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin-bottom: var(--space-lg);
}

/* Display / Hero title */
.hero-title {
  font-size: clamp(2rem, 1.5rem + 2.5vw, 3.5rem);
  font-weight: 300;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

/* --- 3. Layout --- */
.section-content {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Section vertical rhythm — mobile default */
.site-section {
  padding: var(--space-xl) 0;
}

/* Alternating section backgrounds */
#menu    { background: var(--color-bg); }
#about   { background: var(--color-surface); }
#hours   { background: var(--color-bg); }
#booking { background: var(--color-surface); }
#social  { background: var(--color-bg); }
#contact { background: var(--color-surface); }

/* --- 4. Hero Section --- */
#hero {
  position: relative;
  height: 100vh;
  min-height: 500px;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}

.hero-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-overlay {
  position: relative;
  z-index: 1;
  text-align: center;
  color: #ffffff;
  padding: var(--space-2xl) var(--space-lg);
  padding-bottom: var(--space-3xl);
  width: 100%;
  background: linear-gradient(to top, rgba(0,0,0,0.55) 0%, transparent 100%);
}

.hero-tagline {
  font-size: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  font-weight: 400;
  margin-top: var(--space-sm);
  opacity: 0.9;
}

/* --- 5. Sticky CTA Button --- */
.cta-button {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 100;
  background: var(--accent-color);
  color: #ffffff;
  border: none;
  height: 44px;
  padding: 0 24px;
  border-radius: 22px;
  font-family: inherit;
  font-size: clamp(0.8125rem, 0.78rem + 0.15vw, 0.875rem);
  font-weight: 400;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  transition: background 200ms ease, opacity 200ms ease;
}

.cta-button:hover {
  background: var(--accent-dark);
}

.cta-button.hidden {
  opacity: 0;
  pointer-events: none;
}

/* --- 6. Menu Section --- */

/* Category tabs */
.menu-tabs {
  overflow-x: auto;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--color-bg);
  padding: var(--space-sm) 0;
  margin-bottom: var(--space-lg);
}

.menu-tab {
  display: inline-block;
  padding: var(--space-sm) var(--space-md);
  min-height: 44px;
  border: none;
  background: none;
  color: var(--color-text-muted);
  cursor: pointer;
  font-family: inherit;
  font-size: clamp(0.8125rem, 0.78rem + 0.15vw, 0.875rem);
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: 0.02em;
  border-bottom: 2px solid transparent;
  transition: color 200ms ease;
}

.menu-tab.active {
  color: var(--accent-color);
  border-bottom: 2px solid var(--accent-color);
}

.menu-tab:hover {
  color: var(--color-text);
}

/* Menu card grid */
.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-lg);
}

/* Individual card */
.menu-card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: var(--space-lg);
  overflow: hidden;
}

.menu-card[hidden] {
  display: none;
}

.menu-card-photo {
  aspect-ratio: 4/3;
  border-radius: 8px;
  object-fit: cover;
  margin-bottom: var(--space-sm);
  width: 100%;
}

.menu-card-name {
  font-size: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  font-weight: 300;
  margin-bottom: var(--space-xs);
}

.menu-card-desc {
  color: var(--color-text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.menu-card-price {
  font-weight: 400;
  margin-top: var(--space-sm);
}

.menu-card-tags {
  margin-top: var(--space-sm);
}

.dietary-tag {
  display: inline-block;
  padding: 2px var(--space-sm);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 99px;
  margin-right: var(--space-xs);
  margin-top: var(--space-xs);
}

.status-tag {
  display: inline-block;
  padding: 2px var(--space-sm);
  background: var(--accent-light);
  color: var(--accent-dark);
  border-radius: 99px;
  margin-right: var(--space-xs);
  margin-top: var(--space-xs);
}

/* --- 7. Hours Table --- */
.hours-table {
  width: 100%;
  border-collapse: collapse;
}

.hours-table tr {
  border-bottom: 1px solid var(--color-border);
}

.hours-table td {
  padding: var(--space-sm) var(--space-md);
}

.hours-day {
  font-weight: 400;
}

.hours-closed {
  color: var(--color-text-faint);
}

.hours-table tr.today {
  border-left: 3px solid var(--accent-color);
  background: color-mix(in srgb, var(--accent-light) 10%, transparent);
}

/* --- 8. Booking Widget --- */
.booking-widget {
  max-width: 480px;
  margin: 0 auto;
  background: var(--color-card);
  border-radius: 12px;
  padding: var(--space-lg);
}

.booking-step {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 300ms ease, opacity 300ms ease;
}

.booking-step.active {
  max-height: 600px;
  opacity: 1;
}

/* Form inputs */
.booking-widget input[type="text"],
.booking-widget input[type="tel"],
.booking-widget input[type="email"],
.booking-widget input[type="date"],
.booking-widget select,
.booking-widget textarea {
  width: 100%;
  height: 44px;
  padding: 0 var(--space-md);
  font-size: 16px;
  font-family: inherit;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg);
  margin-bottom: var(--space-sm);
}

.booking-widget textarea {
  height: auto;
  min-height: 66px;
  padding: var(--space-sm) var(--space-md);
  resize: vertical;
}

.booking-widget label {
  display: block;
  margin-bottom: var(--space-xs);
  font-weight: 400;
}

/* Action / submit buttons */
.booking-btn {
  width: 100%;
  height: 44px;
  background: var(--accent-color);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-weight: 400;
  font-size: clamp(0.8125rem, 0.78rem + 0.15vw, 0.875rem);
  cursor: pointer;
  transition: background 200ms ease;
  margin-top: var(--space-sm);
}

.booking-btn:hover {
  background: var(--accent-dark);
}

.booking-btn-cancel {
  background: var(--color-destructive);
}

.booking-btn-cancel:hover {
  background: #b91c1c;
}

/* Time slot grid */
.booking-slots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: var(--space-sm);
}

.booking-period-label {
  font-size: clamp(0.8125rem, 0.78rem + 0.15vw, 0.875rem);
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: 0.02em;
  color: var(--color-text-muted);
  margin-top: var(--space-md);
  margin-bottom: var(--space-sm);
}
.booking-period-label:first-of-type {
  margin-top: 0;
}

.booking-slot-btn {
  height: 44px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg);
  cursor: pointer;
  font-family: inherit;
  font-size: clamp(0.8125rem, 0.78rem + 0.15vw, 0.875rem);
  transition: background 200ms ease, color 200ms ease, border-color 200ms ease;
}

.booking-slot-btn:hover {
  border-color: var(--accent-color);
}

.booking-slot-btn.selected {
  background: var(--accent-color);
  color: #fff;
  border-color: var(--accent-color);
}

/* Confirmation */
.booking-confirmed {
  text-align: center;
  padding: var(--space-xl);
}

.confirmed-icon {
  color: var(--color-success);
}

.booking-error {
  color: var(--color-destructive);
  font-size: clamp(0.8125rem, 0.78rem + 0.15vw, 0.875rem);
  margin-top: var(--space-sm);
}

.booking-loading {
  text-align: center;
  padding: var(--space-lg);
  color: var(--color-text-muted);
}

/* GDPR Consent Checkbox (Phase 16) */
.booking-consent {
  margin-top: var(--space-sm);
  margin-bottom: var(--space-sm);
}
.booking-consent-label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
}
.booking-consent-input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  cursor: pointer;
  flex-shrink: 0;
}
.booking-consent-text {
  font-size: clamp(0.8125rem, 0.78rem + 0.15vw, 0.875rem);
  font-weight: 400;
  line-height: 1.4;
  color: var(--color-text-muted);
}

/* --- 9. Social Section --- */
.social-links {
  display: flex;
  gap: var(--space-lg);
  justify-content: center;
}

.social-icon-link {
  color: var(--color-text-muted);
  transition: color 200ms ease;
}

.social-icon-link:hover {
  color: var(--accent-color);
}

.social-icon-link svg {
  width: 32px;
  height: 32px;
}

/* --- 10. Contact Section --- */
.contact-grid {
  display: block;
}

.contact-info {
  margin-bottom: var(--space-lg);
}

.contact-info p {
  margin-bottom: var(--space-sm);
}

.contact-link {
  color: var(--accent-color);
  text-decoration: none;
}

.contact-link:hover {
  text-decoration: underline;
}

.map-iframe {
  width: 100%;
  aspect-ratio: 4/3;
  border: none;
  border-radius: 12px;
}

/* --- 11. Footer --- */
.site-footer {
  text-align: center;
  padding: var(--space-lg) var(--space-md);
  border-top: 1px solid var(--color-border);
  color: var(--color-text-faint);
}

/* --- 12. Accessibility --- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.skip-link:focus {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 1000;
  width: auto;
  height: auto;
  padding: var(--space-sm) var(--space-md);
  background: var(--color-bg);
  color: var(--color-text);
  border: 2px solid var(--accent-color);
  border-radius: 4px;
}

*:focus-visible {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

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

/* --- 13. Responsive Breakpoints --- */

/* Tablet: >= 640px */
@media (min-width: 640px) {
  .section-content {
    padding: 0 40px;
  }

  .menu-tabs {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    white-space: normal;
    overflow-x: visible;
  }
}

/* Desktop: >= 1024px */
@media (min-width: 1024px) {
  .site-section {
    padding: var(--space-3xl) 0;
  }

  .cta-button {
    position: fixed;
    top: 20px;
    right: 20px;
    bottom: auto;
  }

  .contact-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-xl);
  }

  .contact-info {
    margin-bottom: 0;
  }
}

/* --- 14. Language Switcher --- */
.lang-switcher {
  position: fixed;
  top: var(--space-lg);
  left: var(--space-lg);
  z-index: 100;
  display: flex;
  gap: 0;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 22px;
  padding: 2px;
  font-size: clamp(0.8125rem, 0.78rem + 0.15vw, 0.875rem);
}

.lang-option {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 36px;
  padding: 0 var(--space-sm);
  border-radius: 20px;
  text-decoration: none;
  color: var(--color-text-muted);
  transition: color 200ms ease;
}

.lang-option:hover {
  color: var(--color-text);
}

.lang-option.active {
  background: var(--accent-color);
  color: #ffffff;
}

/* Mobile: bottom-left instead of top-left */
@media (max-width: 768px) {
  .lang-switcher {
    top: auto;
    bottom: var(--space-lg);
    left: var(--space-lg);
  }
}

/* --- Phase 17 Order Page --- */

#order-hero {
  padding: var(--space-xl) var(--space-lg) var(--space-lg);
  text-align: center;
  background: var(--color-surface);
}

#order-hero h1 {
  margin: 0 0 var(--space-sm);
  font-weight: 300;
  font-size: clamp(1.5rem, 1.2rem + 1.5vw, 2.25rem);
  line-height: 1.2;
}

#order-hero .muted {
  color: var(--color-text-muted);
  font-size: clamp(0.8125rem, 0.78rem + 0.15vw, 0.875rem);
  margin: 0;
}

#order-info {
  padding: var(--space-lg) var(--space-md) 0;
}

.order-info-banner {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: var(--space-md);
  max-width: 480px;
  margin: 0 auto var(--space-lg);
  text-align: center;
}

.order-info-banner > div {
  font-size: clamp(0.8125rem, 0.78rem + 0.15vw, 0.875rem);
  line-height: 1.5;
  color: var(--color-text);
}

.order-info-banner > div + div {
  margin-top: var(--space-xs);
}

#order-menu {
  padding: 0 var(--space-md) var(--space-xl);
}

#order-menu .menu-tabs.order-tabs {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--color-bg);
  padding: var(--space-sm) 0;
  margin-bottom: var(--space-lg);
}

.order-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-lg);
}

.order-card picture,
.order-card img.menu-card-photo {
  display: block;
  aspect-ratio: 4 / 3;
  width: 100%;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: var(--space-sm);
}

.order-card .clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Inline CTA (in hero) — reset the sticky positioning the base .cta-button applies. */
.cta-button.cta-inline {
  position: static;
  display: inline-block;
  margin-top: var(--space-md);
  box-shadow: none;
}

.cta-button.cta-inline:hover {
  background: var(--accent-dark);
}

/* Sticky order CTA uses the same bottom-right positioning as the reserve CTA
   but is offset upward so both can coexist on the page. */
.cta-button.cta-sticky.order-cta-sticky {
  bottom: 76px;
}

@media (max-width: 480px) {
  .cta-button.cta-sticky.order-cta-sticky {
    bottom: 72px;
  }
}

/* ----- Phase 18: Cart widget + checkout + fulfillment toggle + slot picker ----- */
.cart-widget {
  background: var(--color-card);
  border-radius: 12px;
  padding: var(--space-md);
  max-width: 480px;
  margin: var(--space-lg) auto;
}
.cart-widget h2 {
  margin: 0 0 var(--space-sm) 0;
  font-size: 1.1rem;
}
.cart-widget .cart-lines {
  list-style: none;
  padding: 0;
  margin: 0;
}
.cart-line {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--color-border);
}
.cart-line-qty {
  font-weight: 600;
  color: var(--accent-color);
  min-width: 32px;
}
.cart-subtotal {
  margin-top: var(--space-sm);
  font-weight: 600;
}
.qty-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--accent-color);
  background: transparent;
  color: var(--accent-color);
  border-radius: 4px;
  cursor: pointer;
}

.fulfillment-toggle {
  display: inline-flex;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 4px;
  gap: var(--space-xs);
  margin: var(--space-md) 0;
}
.fulfillment-toggle .ft-opt {
  padding: var(--space-xs) var(--space-md);
  border: 0;
  background: transparent;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  color: var(--color-text);
}
.fulfillment-toggle .ft-opt.active {
  background: var(--accent-color);
  color: #fff;
}

.slot-picker {
  margin: var(--space-md) 0;
}
.slot-picker .slot-asap {
  display: block;
  width: 100%;
  padding: var(--space-md);
  margin-bottom: var(--space-md);
  background: var(--accent-light);
  border: 1px solid var(--accent-color);
  border-radius: 6px;
  cursor: pointer;
}
.slot-picker .slot-asap.selected {
  background: var(--accent-color);
  color: #fff;
  border-color: var(--accent-color);
}
.checkout-section .section-content {
  max-width: 640px;
  margin: 0 auto;
  padding: var(--space-lg);
}
.checkout-form h2 {
  margin-top: var(--space-lg);
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-lg);
  font-size: 1.1rem;
}
.checkout-form label {
  display: block;
  margin-bottom: var(--space-sm);
}
.checkout-form input[type=text],
.checkout-form input[type=email],
.checkout-form input,
.checkout-form textarea {
  display: block;
  width: 100%;
  padding: var(--space-sm);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font: inherit;
  margin-top: var(--space-xs);
}
.booking-consent {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  margin: var(--space-md) 0;
  font-size: 0.95rem;
}

.order-confirmed {
  background: var(--color-card);
  padding: var(--space-lg);
  border-radius: 12px;
  text-align: center;
  border: 1px solid var(--color-border);
}

/* Status page */
.order-status-page {
  max-width: 640px;
  margin: var(--space-2xl) auto;
  padding: 0 var(--space-lg);
}
.order-status-card {
  background: var(--color-card);
  padding: var(--space-lg);
  border-left: 3px solid var(--accent-color);
  border-radius: 8px;
  margin-bottom: var(--space-lg);
}
.status-badge {
  display: inline-block;
  padding: var(--space-xs) var(--space-md);
  border-radius: 999px;
  background: var(--accent-color);
  color: #fff;
  font-weight: 600;
  margin-bottom: var(--space-sm);
}
.status-rejected .status-badge,
.status-cancelled .status-badge {
  background: var(--color-destructive);
}
.status-fulfilled .status-badge {
  background: var(--color-success);
}
.btn-destructive {
  background: var(--color-destructive);
  color: #fff;
  border: 0;
  padding: var(--space-sm) var(--space-lg);
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
}
.order-items {
  list-style: none;
  padding: 0;
}
.order-line {
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--color-border);
}
