/* Central Square Supermarket - Main stylesheet */
@import url('https://fonts.googleapis.com/css2?family=Karla:ital,wght@0,400..700;1,400..700&family=Outfit:wght@400..800&display=swap');

:root {
  /* Core Brand Tokens */
  --surface: #faf8f5;
  --card: #ffffff;
  --primary: #1b4d3e;
  --ink: #113329;
  --accent: #d97706;
  --border: #e5e0d8;
  --muted: #5c5a54;

  /* Typography Tokens */
  --font-display: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Karla', -apple-system, BlinkMacSystemFont, sans-serif;
  --lh-heading: 1.15;
  --lh-body: 1.5;

  /* Component Token Aliases */
  --color-ink: var(--ink);
  --color-surface: var(--card);
  --color-surface-alt: var(--surface);
  --color-primary: var(--primary);
  --color-accent: var(--accent);
  --color-border: var(--border);
  --color-muted: var(--muted);

  /* Spacing Tokens */
  --gutter: 1.5rem;
  --gutter-mobile: 1rem;
  --max-width: 1200px;
  --radius: 8px;
  
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4rem;

  --text-xs: 0.875rem;
  --text-sm: 0.9375rem;
  --text-base: 1.125rem;
  --text-lg: 1.35rem;
  --text-xl: 1.75rem;
  --text-2xl: 2.25rem;
  --text-3xl: clamp(2.441rem, 4vw, 3.815rem);

  --motion-base: 0.2s;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

/* CSS Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: var(--lh-body);
  color: var(--ink);
  background-color: var(--surface);
  -webkit-font-smoothing: antialiased;
}

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

/* Global Focus Styles */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Container & Typography */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

@media (max-width: 767px) {
  .container {
    padding-left: var(--gutter-mobile);
    padding-right: var(--gutter-mobile);
  }
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  line-height: var(--lh-heading);
  color: var(--ink);
  font-weight: 700;
}

h1 {
  font-size: var(--text-3xl);
  letter-spacing: -0.02em;
}

h2 {
  font-size: var(--text-2xl);
  letter-spacing: -0.01em;
}

h3 {
  font-size: var(--text-xl);
}

p {
  font-size: var(--text-base);
  color: var(--ink);
  max-width: 75ch;
}

p.muted {
  color: var(--muted);
}

a {
  color: inherit;
  transition: color var(--motion-base) var(--ease);
}

/* Buttons & CTAs */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.875rem 1.5rem;
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 700;
  text-decoration: none;
  border-radius: var(--radius);
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform var(--motion-base) var(--ease), background-color var(--motion-base) var(--ease), border-color var(--motion-base) var(--ease);
  min-height: 48px;
}

.btn:active {
  transform: scale(0.98);
}

.btn--primary {
  background-color: var(--primary);
  color: #ffffff;
}

.btn--primary:hover {
  background-color: var(--ink);
}

.btn--accent {
  background-color: var(--accent);
  color: #ffffff;
}

.btn--accent:hover {
  background-color: #b45309;
}

.btn--outline {
  background-color: transparent;
  border-color: var(--primary);
  color: var(--primary);
}

.btn--outline:hover {
  background-color: var(--primary);
  color: #ffffff;
}

/* Header & Main Nav */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background-color: var(--card);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}

.header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 80px;
}

.header__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
}

.header__logo {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.header__title-group {
  display: flex;
  flex-direction: column;
}

.header__title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.1;
}

.header__subtitle {
  font-size: 0.8125rem;
  color: var(--muted);
  font-weight: 500;
}

.header__nav {
  display: flex;
  align-items: center;
  gap: var(--space-6);
}

.header__nav-list {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  list-style: none;
}

.header__nav-link {
  font-weight: 600;
  font-size: 1rem;
  color: var(--ink);
  text-decoration: none;
  padding: var(--space-2) 0;
  position: relative;
}

.header__nav-link:hover,
.header__nav-link.active {
  color: var(--accent);
}

.header__nav-link.active::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background-color: var(--accent);
  border-radius: 2px;
}

.header__cta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.header__mobile-toggle {
  display: none;
  background: none;
  border: none;
  padding: var(--space-2);
  cursor: pointer;
  color: var(--ink);
}

/* Utility Bar rules */
.utility-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-2) var(--gutter);
  gap: var(--space-4);
  background: var(--ink);
  color: var(--surface);
  font-family: var(--font-body);
  font-size: var(--text-xs);
}

.utility-bar a {
  color: var(--surface);
  text-decoration: none;
}

.utility-bar a:hover {
  text-decoration: underline;
}

.utility-bar__meta {
  display: flex;
  gap: var(--space-5);
}

@media (max-width: 767px) {
  .utility-bar {
    display: none;
  }
}

/* Sticky Hours Component override */
.sticky-hours {
  position: sticky;
  bottom: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  background: var(--ink);
  color: var(--surface);
  font-family: var(--font-body);
  font-size: var(--text-sm);
}

.sticky-hours__status {
  font-weight: 700;
}

.sticky-hours__status.is-open {
  color: #7ce8a5;
}

.sticky-hours__status.is-closed {
  color: #ffb4a2;
}

.sticky-hours__hours {
  color: var(--border);
}

.sticky-hours__call {
  color: var(--surface);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 700;
}

/* Sticky Mobile Call Bar (Screens < 768px) */
.mobile-call-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 90;
  background-color: var(--primary);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 -4px 16px rgba(0,0,0,0.15);
}

.mobile-call-bar__inner {
  display: flex;
  width: 100%;
}

.mobile-call-bar__btn {
  flex: 1 1 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.875rem 0.5rem;
  color: #ffffff;
  font-weight: 700;
  font-size: 0.9375rem;
  text-decoration: none;
  text-align: center;
  min-height: 52px;
}

.mobile-call-bar__btn--call {
  background-color: var(--primary);
  border-right: 1px solid rgba(255, 255, 255, 0.2);
}

.mobile-call-bar__btn--directions {
  background-color: var(--ink);
}

.mobile-call-bar__btn:active {
  background-color: var(--accent);
}

@media (max-width: 767px) {
  .mobile-call-bar {
    display: block;
  }
  body {
    padding-bottom: 56px;
  }
}

/* Badge Component */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.35rem 0.85rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge--open {
  background-color: #d1fae5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.badge--closed {
  background-color: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
}

.badge__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.badge--open .badge__dot {
  background-color: #10b981;
}

.badge--closed .badge__dot {
  background-color: #ef4444;
}

/* Hero Section */
.hero {
  padding: var(--space-7) 0;
  background-color: var(--surface);
  border-bottom: 1px solid var(--border);
}

.hero__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-7);
  align-items: center;
}

.hero__content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-4);
}

.hero__headline {
  font-size: var(--text-3xl);
  color: var(--ink);
}

.hero__value-prop {
  font-size: 1.25rem;
  color: var(--muted);
  line-height: 1.45;
}

.hero__cta-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-4);
  margin-top: var(--space-2);
}

.hero__trust {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--primary);
  background-color: rgba(27, 77, 62, 0.06);
  padding: 0.5rem 0.875rem;
  border-radius: var(--radius);
}

.hero__image-wrapper {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 12px 32px rgba(17, 51, 41, 0.12);
  border: 1px solid var(--border);
  aspect-ratio: 4 / 3;
}

.hero__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Department Cards Grid */
.section {
  padding: var(--space-8) 0;
}

.section--alt {
  background-color: var(--card);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.section__header {
  margin-bottom: var(--space-6);
}

.section__title {
  font-size: var(--text-2xl);
  color: var(--ink);
}

.section__subtitle {
  font-size: 1.125rem;
  color: var(--muted);
  margin-top: var(--space-2);
}

.dept-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-5);
}

.dept-card {
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform var(--motion-base) var(--ease), box-shadow var(--motion-base) var(--ease);
  display: flex;
  flex-direction: column;
}

.dept-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}

.dept-card__img-container {
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background-color: var(--surface);
}

.dept-card__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.dept-card__body {
  padding: var(--space-4) var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex-grow: 1;
}

.dept-card__name {
  font-size: var(--text-lg);
  font-family: var(--font-display);
  color: var(--ink);
}

.dept-card__desc {
  font-size: 0.9375rem;
  color: var(--muted);
  line-height: 1.4;
}

/* Story Strip & Stats */
.story-strip {
  background-color: var(--primary);
  color: #ffffff;
  padding: var(--space-8) 0;
}

.story-strip h2 {
  color: #ffffff;
  margin-bottom: var(--space-4);
}

.story-strip p {
  color: rgba(255, 255, 255, 0.9);
  font-size: 1.25rem;
  max-width: 65ch;
  line-height: 1.6;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-5);
  margin-top: var(--space-7);
}

.stat-card {
  background-color: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius);
  padding: var(--space-5);
  text-align: center;
}

.stat-card__val {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--accent);
  margin-bottom: var(--space-1);
}

.stat-card__lbl {
  font-size: 1rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
}

/* Specials Section Base */
.specials-section {
  padding: var(--space-8) 0;
}

.specials-notice {
  background-color: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: var(--space-6);
  text-align: center;
  margin-top: var(--space-6);
}

.specials-notice p {
  margin: 0 auto;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--primary);
}

/* Contact Page Layout */
.contact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-7);
  align-items: start;
}

.nap-card {
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.nap-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.nap-item__label {
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
}

.nap-item__val {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--ink);
}

.hours-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: var(--space-2);
}

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

.hours-table tr:last-child {
  border-bottom: none;
}

.hours-table td {
  padding: var(--space-2) 0;
  font-size: 1rem;
}

.hours-table td:last-child {
  text-align: right;
  font-weight: 600;
}

.map-wrapper {
  width: 100%;
  height: 320px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  margin-top: var(--space-4);
  position: relative;
}

.map-wrapper iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Contact Form */
.contact-form-wrapper {
  background-color: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-6);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}

.form-group label {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--ink);
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--ink);
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color var(--motion-base) var(--ease);
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.15);
}

textarea.form-control {
  min-height: 140px;
  resize: vertical;
}

.demo-banner {
  display: none;
  margin-top: var(--space-4);
  padding: var(--space-4);
  background-color: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: var(--radius);
  color: #065f46;
  font-weight: 600;
  font-size: 0.9375rem;
}

.demo-banner.visible {
  display: block;
}

/* Footer */
.footer {
  background-color: var(--ink);
  color: var(--surface);
  padding-top: var(--space-8);
  padding-bottom: var(--space-6);
  margin-top: auto;
}

.footer__grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1.5fr;
  gap: var(--space-7);
  margin-bottom: var(--space-7);
}

.footer__brand-col {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.footer__title {
  color: #ffffff;
  font-size: 1.5rem;
}

.footer__tagline {
  color: var(--border);
  font-size: 1rem;
  max-width: 40ch;
}

.footer__heading {
  color: var(--accent);
  font-size: 1.125rem;
  margin-bottom: var(--space-4);
}

.footer__links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.footer__links a {
  color: var(--border);
  text-decoration: none;
  font-size: 1rem;
}

.footer__links a:hover {
  color: #ffffff;
  text-decoration: underline;
}

.footer__nap {
  color: var(--border);
  font-size: 0.9375rem;
  font-style: normal;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.footer__bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: var(--space-5);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
  color: var(--border);
}

/* Responsive Media Queries */
@media (max-width: 1024px) {
  .dept-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 767px) {
  .header__inner {
    height: auto;
    min-height: 64px;
    padding: var(--space-2) 0;
    flex-wrap: nowrap;
  }
  .header__title {
    font-size: 1.05rem;
    line-height: 1.15;
  }
  .header__subtitle {
    font-size: 0.7rem;
    line-height: 1.2;
  }
  .header__brand {
    min-width: 0;
    gap: var(--space-2);
  }
  .header__logo {
    width: 40px;
    height: 40px;
  }
  /* Bottom call bar owns calls on mobile — drop the squeezed header button. */
  .header__cta .btn {
    display: none;
  }
  .header__nav-list {
    display: none; /* simple mobile setup */
  }
  .header__nav-list.is-open {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 80px;
    left: 0;
    right: 0;
    background-color: var(--card);
    border-bottom: 1px solid var(--border);
    padding: var(--space-4) var(--gutter-mobile);
    gap: var(--space-3);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  }
  .header__mobile-toggle {
    display: block;
  }
  .hero__grid {
    grid-template-columns: 1fr;
    gap: var(--space-5);
  }
  .stats-grid {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }
  .contact-grid {
    grid-template-columns: 1fr;
  }
  .footer__grid {
    grid-template-columns: 1fr;
    gap: var(--space-6);
  }
  .dept-grid {
    grid-template-columns: 1fr;
  }
}

/* Motion Accessibility Override */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
