/* ==================================================================
   Fontänhuset App — Stylesheet
   Cognitive aid design — large text, clear hierarchy, calm motion
   ================================================================== */

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

img, svg, picture {
  display: block;
  max-width: 100%;
  height: auto;
}

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

a {
  color: inherit;
  text-decoration: none;
}

/* ---- Design tokens ---- */
:root {
  /* Colors — ärver från broschyren */
  --bg: #FAF8F5;
  --bg-card: #FFFFFF;
  --bg-soft: #F5F1EA;
  --text: #1E1E1E;
  --text-soft: #4A4A4A;
  --text-muted: #7A736B;
  --red: #A80F44;
  --red-dark: #750A2F;
  --red-rgb: 168, 15, 68;
  --red-soft: rgba(168, 15, 68, 0.06);
  --border: #E8E2D8;
  --border-soft: #F0EBE0;

  /* Typography scale — kognitivt hjälpmedel: stort */
  --text-xs: 0.875rem;     /* 14px */
  --text-sm: 1rem;         /* 16px */
  --text-base: 1.25rem;    /* 20px — body min */
  --text-lg: 1.5rem;       /* 24px */
  --text-xl: 1.75rem;      /* 28px */
  --text-2xl: 2rem;        /* 32px */
  --text-3xl: 2.5rem;      /* 40px */
  --text-4xl: 3rem;        /* 48px */
  --text-5xl: 4rem;        /* 64px */
  --text-6xl: 5rem;        /* 80px */

  /* Spacing — 8px-grid, generös */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 64px;
  --s-9: 96px;
  --s-10: 128px;

  /* Radii — mjuka, aldrig vassa */
  --r-sm: 8px;
  --r: 16px;
  --r-lg: 24px;
  --r-xl: 32px;
  --r-full: 9999px;

  /* Shadows — komposit, mjuka */
  --shadow-card:
    0 2px 8px rgba(0, 0, 0, 0.04),
    0 8px 24px rgba(0, 0, 0, 0.06);
  --shadow-card-today:
    0 4px 12px rgba(var(--red-rgb), 0.10),
    0 16px 40px rgba(var(--red-rgb), 0.14);
  --shadow-fab:
    0 8px 24px rgba(var(--red-rgb), 0.32),
    0 4px 12px rgba(var(--red-rgb), 0.20);
  --shadow-modal:
    0 24px 64px rgba(0, 0, 0, 0.20),
    0 12px 32px rgba(0, 0, 0, 0.12);

  /* Layout */
  --max-w: 720px;
  --tap-min: 64px;

  /* Motion */
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --dur: 250ms;
  --dur-slow: 400ms;
}

/* ---- Base ---- */
html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

@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;
  }
}

body {
  background: var(--bg);
  font-family: 'Open Sans', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: var(--s-10); /* utrymme för FAB */
}

/* ---- Focus ring (synlig, brand-aligned) ---- */
:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: 4px;
  border-radius: var(--r-sm);
}

/* ---- Skip link ---- */
.skip-link {
  position: absolute;
  top: -200px;
  left: var(--s-4);
  background: var(--red);
  color: #fff;
  padding: var(--s-4) var(--s-5);
  border-radius: var(--r);
  font-size: var(--text-base);
  font-weight: 700;
  z-index: 1000;
  transition: top var(--dur) var(--ease);
  text-decoration: none;
}
.skip-link:focus {
  top: var(--s-4);
}

/* ---- Site header ---- */
.site-header {
  background: rgba(250, 248, 245, 0.92);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  padding: var(--s-5) var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.site-header__inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: var(--s-3);
}

.site-emblem {
  width: 64px;
  height: 64px;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 6px rgba(var(--red-rgb), 0.12));
}

.site-header__nav {
  flex: 1;
  min-width: 0;
}

.beta-badge {
  background: #2563eb;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 6px 10px;
  border-radius: var(--r-full);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  flex-shrink: 0;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

/* ---- Hamburger menu (matchar chevron-pilarna i storlek) ---- */
.hamburger {
  width: 64px;
  height: 64px;
  border: 2px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: var(--s-3);
  border-radius: var(--r);
  flex-shrink: 0;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.hamburger:hover {
  background: var(--bg-soft);
  border-color: var(--text-muted);
}

.hamburger__line {
  display: block;
  width: 24px;
  height: 3px;
  background: var(--text);
  border-radius: 2px;
  transition: background var(--dur) var(--ease);
}

/* ---- Menu drawer (slide-in from right) ---- */
.menu-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 300;
  animation: fade-in var(--dur) var(--ease);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

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

.menu-drawer {
  position: absolute;
  top: 0;
  right: 0;
  width: 320px;
  max-width: 85vw;
  height: 100%;
  background: var(--bg-card);
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  animation: slide-in-right var(--dur-slow) var(--ease);
  overflow-y: auto;
}

@keyframes slide-in-right {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

.menu-drawer__header {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-5);
  border-bottom: 1px solid var(--border);
}

.menu-drawer__emblem {
  width: 72px;
  height: 72px;
  flex-shrink: 0;
}

.menu-drawer__header .beta-badge {
  margin-right: auto;
}

.menu-drawer__close {
  width: 48px;
  height: 48px;
  border: none;
  background: transparent;
  font-size: var(--text-3xl);
  color: var(--text-muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  border-radius: var(--r);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
  line-height: 1;
}

.menu-drawer__close:hover {
  background: var(--bg-soft);
  color: var(--text);
}

/* ---- Menu items ---- */
.menu-drawer__list {
  flex: 1;
  padding: var(--s-4) 0;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-5) var(--s-6);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: background var(--dur) var(--ease);
  position: relative;
}

.menu-item:hover {
  background: var(--bg-soft);
}

.menu-item--active {
  color: var(--red);
  font-weight: 800;
  background: rgba(var(--red-rgb), 0.04);
  border-left: 4px solid var(--red);
}

.menu-item--soon {
  opacity: 0.5;
  cursor: default;
}

.menu-item--soon:hover {
  background: transparent;
}

.menu-item__icon {
  font-size: var(--text-xl);
  width: 36px;
  text-align: center;
  flex-shrink: 0;
}

.menu-item__label {
  flex: 1;
}

.menu-item__badge {
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: #2563eb;
  color: #fff;
  padding: 5px 12px;
  border-radius: var(--r-full);
  white-space: nowrap;
}

/* ---- Menu footer ---- */
.menu-drawer__footer {
  padding: var(--s-5) var(--s-6);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.menu-drawer__wordmark {
  width: 100%;
  max-width: 220px;
  height: auto;
  display: block;
}

.menu-drawer__version {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: 600;
}

@media (max-width: 480px) {
  .site-header { padding: var(--s-3) var(--s-3); }
  .site-header__inner { gap: var(--s-2); }
  .site-emblem { width: 48px; height: 48px; }
  .beta-badge { font-size: 0.55rem; padding: 4px 8px; }
  .hamburger { width: 52px; height: 52px; gap: 5px; }
  .hamburger__line { width: 22px; height: 2.5px; }
}

/* Mycket smala skärmar: gömmer pilar, shrink:ar IDAG-texten */
@media (max-width: 374px) {
  .site-emblem { width: 40px; height: 40px; }
  .week-stepper__arrow { display: none; }
  .beta-badge { display: none; }
  .hamburger { width: 40px; height: 40px; gap: 4px; }
  .hamburger__line { width: 18px; }
}

/* ---- Main container ---- */
.main {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: var(--s-6) var(--s-4) var(--s-9);
}

/* ---- Loading state ---- */
.loading {
  text-align: center;
  padding: var(--s-9) var(--s-4);
  font-size: var(--text-lg);
  color: var(--text-muted);
}

/* ---- Week view container ---- */
.week-view {
  display: block;
}

/* IDAG-kortet är hero — alltid överst, alltid synligt */
.week-view > .meal-card--today {
  margin-bottom: var(--s-7);
}

/* ---- Week stepper [◀] Denna vecka v.15 [▶] ---- */
.week-stepper {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  justify-content: center;
  flex: 1;
}

.week-stepper__arrow {
  width: 64px;
  height: 64px;
  border-radius: var(--r); /* matchar hamburger-menyn */
  border: 2px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  font-size: var(--text-2xl);
  display: grid;
  place-items: center;
  transition: all var(--dur) var(--ease);
  color: var(--text);
  font-family: inherit;
  flex-shrink: 0;
  line-height: 1;
}

.week-stepper__arrow:hover:not(:disabled) {
  border-color: var(--red);
  color: var(--red);
  background: var(--bg-soft);
  transform: scale(1.05);
}

.week-stepper__arrow:active:not(:disabled) {
  transform: scale(0.92);
}

.week-stepper__arrow:disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.week-stepper__label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 100px;
  height: 64px; /* matchar pilarnas höjd */
  user-select: none;
  padding: 0 var(--s-3);
}

.week-stepper__primary {
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--text);
  line-height: 1;
  white-space: nowrap;
}

@media (max-width: 480px) {
  .week-stepper__arrow { width: 52px; height: 52px; font-size: var(--text-xl); }
  .week-stepper__primary { font-size: var(--text-lg); }
  .week-stepper__secondary { font-size: var(--text-base); }
  .week-stepper__label { min-width: 90px; }
}

@media (max-width: 374px) {
  .week-stepper__arrow { width: 44px; height: 44px; font-size: var(--text-lg); border-radius: var(--r); }
  .week-stepper__primary { font-size: var(--text-base); }
  .week-stepper__secondary { font-size: var(--text-sm); }
}

/* ---- Week content (selected week's meals) ---- */
.week-content {
  display: block;
}

/* ---- Meal cards ---- */
.meal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-6);
  margin-bottom: var(--s-4);
  box-shadow: var(--shadow-card);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}

.meal-card:hover {
  transform: translateY(-2px);
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.06),
    0 12px 32px rgba(0, 0, 0, 0.10);
}

.meal-card__date {
  font-size: var(--text-base);
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: var(--s-3);
}

.meal-card__description {
  font-size: var(--text-2xl);
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* ---- Today's card (the hero) ---- */
.meal-card--today {
  background: var(--bg-card);
  border: 2px solid var(--red);
  border-left-width: 12px;
  padding: var(--s-7);
  box-shadow: var(--shadow-card-today);
  margin-bottom: var(--s-6);
}

.meal-card--today:hover {
  transform: none;
  box-shadow: var(--shadow-card-today);
}

.meal-card__label-row {
  display: flex;
  align-items: baseline;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
}

.meal-card__label {
  display: inline-block;
  font-size: var(--text-base);
  font-weight: 800;
  color: var(--red);
  text-transform: uppercase;
  letter-spacing: 0.16em;
}

.meal-card__week {
  margin-left: auto; /* högerställd */
  font-size: var(--text-base);
  font-weight: 800;
  color: var(--text); /* hög kontrast — #1E1E1E på vit bakgrund = AAA */
  letter-spacing: 0.06em;
}

.meal-card--today .meal-card__date {
  font-size: var(--text-xl);
  color: var(--text);
  font-weight: 700;
  margin-bottom: var(--s-5);
}

.meal-card--today .meal-card__description {
  font-size: clamp(var(--text-3xl), 7vw, var(--text-5xl));
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.meal-card--today .meal-card__description--empty {
  color: var(--text-muted);
  font-weight: 600;
  font-size: var(--text-2xl);
  font-style: italic;
}

/* ---- Empty state ---- */
.empty {
  text-align: center;
  padding: var(--s-9) var(--s-5);
  background: var(--bg-card);
  border: 2px dashed var(--border);
  border-radius: var(--r-lg);
}

.empty__title {
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--text);
  margin-bottom: var(--s-3);
}

.empty p {
  font-size: var(--text-base);
  color: var(--text-muted);
  line-height: 1.5;
  max-width: 32ch;
  margin: 0 auto;
}

/* ---- Floating Action Button ---- */
.fab {
  position: fixed;
  bottom: var(--s-6);
  right: var(--s-6);
  width: 96px;
  height: 96px;
  border-radius: var(--r-full);
  background: var(--red);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: var(--shadow-fab);
  display: grid;
  place-items: center;
  font-size: 56px;
  font-weight: 300;
  line-height: 1;
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease);
  z-index: 100;
  padding-bottom: 4px;
}

.fab:hover {
  transform: scale(1.05);
  background: var(--red-dark);
}

.fab:active {
  transform: scale(0.95);
}

.fab:focus-visible {
  outline-offset: 6px;
}

/* ---- Modal ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: grid;
  place-items: center;
  padding: var(--s-4);
  z-index: 200;
  animation: fade-in var(--dur) var(--ease);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--bg-card);
  border-radius: var(--r-xl);
  padding: var(--s-7);
  max-width: 540px;
  width: 100%;
  box-shadow: var(--shadow-modal);
  animation: slide-up var(--dur-slow) var(--ease);
  max-height: calc(100vh - var(--s-8));
  overflow-y: auto;
}

@keyframes slide-up {
  from { transform: translateY(48px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal__title {
  font-size: var(--text-2xl);
  font-weight: 800;
  margin-bottom: var(--s-5);
  color: var(--text);
  letter-spacing: -0.01em;
}

.modal__field {
  margin-bottom: var(--s-5);
}

.modal__field:last-of-type {
  margin-bottom: var(--s-6);
}

.modal__label {
  display: block;
  font-size: var(--text-base);
  font-weight: 700;
  margin-bottom: var(--s-3);
  color: var(--text);
}

.modal__input,
.modal__textarea {
  width: 100%;
  padding: var(--s-4);
  font-size: var(--text-lg);
  font-family: inherit;
  border: 2px solid var(--border);
  border-radius: var(--r);
  background: var(--bg);
  color: var(--text);
  min-height: var(--tap-min);
  transition: border-color var(--dur) var(--ease);
}

.modal__textarea {
  min-height: 160px;
  resize: vertical;
  line-height: 1.4;
}

.modal__input:focus,
.modal__textarea:focus {
  outline: none;
  border-color: var(--red);
}

.modal__actions {
  display: flex;
  gap: var(--s-3);
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* ---- Buttons ---- */
.btn {
  padding: var(--s-4) var(--s-6);
  font-size: var(--text-base);
  font-weight: 700;
  font-family: inherit;
  border: none;
  border-radius: var(--r);
  cursor: pointer;
  min-height: var(--tap-min);
  min-width: 120px;
  transition: all var(--dur) var(--ease);
}

.btn--primary {
  background: var(--red);
  color: #fff;
}
.btn--primary:hover {
  background: var(--red-dark);
}
.btn--primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn--ghost {
  background: transparent;
  color: var(--text);
  border: 2px solid var(--border);
}
.btn--ghost:hover {
  background: var(--bg-soft);
  border-color: var(--text-muted);
}

/* ---- Error toast ---- */
.error-text {
  color: var(--red);
  font-size: var(--text-base);
  font-weight: 600;
  margin-top: var(--s-3);
}

/* ---- Mobile adjustments ---- */
@media (max-width: 540px) {
  .main { padding: var(--s-4) var(--s-3) var(--s-9); }
  .meal-card { padding: var(--s-5); }
  .meal-card--today { padding: var(--s-5); }
  .meal-card--today .meal-card__description {
    font-size: clamp(var(--text-2xl), 8vw, var(--text-4xl));
  }
  .modal { padding: var(--s-5); border-radius: var(--r-lg); }
  .fab {
    width: 80px;
    height: 80px;
    bottom: var(--s-5);
    right: var(--s-5);
    font-size: 48px;
  }
}

@media (max-width: 374px) {
  .main { padding: var(--s-3) var(--s-2) var(--s-8); }
  .meal-card--today .meal-card__description {
    font-size: clamp(var(--text-xl), 7vw, var(--text-3xl));
  }
  .meal-card--today .meal-card__date { font-size: var(--text-sm); }
  .meal-card__date { font-size: var(--text-sm); }
  .meal-card__description { font-size: var(--text-xl); }
  .fab { width: 64px; height: 64px; font-size: 36px; }
}
