/* ============================================================
   Middag — kollektiv-køkken
   Aesthetic: Norwegian hytte-kitchen / editorial cookbook.
   Warm paper, serif display, hand-stamped feel.
   ============================================================ */

:root {
  /* Paper palette */
  --paper:        #efe4cd;
  --paper-warm:   #faf1d8;
  --paper-edge:   #e3d4b0;

  /* Ink + muted */
  --ink:          #1f1810;
  --ink-soft:     #6e5d44;
  --ink-faint:    #9d8a6d;
  --line:         #cdb88e;
  --line-soft:    #ddc9a0;

  /* Accent system */
  --rust:         #b6471f;
  --rust-deep:    #8a3416;
  --rust-soft:    #f1c4ad;
  --mustard:      #c69317;
  --olive:        #7a8847;
  --teal:         #2f6e6a;
  --forest:       #4a6a39;
  --forest-soft:  #d6e0c0;
  --forest-line:  #97a378;

  /* User signature colors */
  --u-Gorm:    #b6471f;  /* rust */
  --u-Erling:  #c69317;  /* mustard */
  --u-Vemund:  #7a8847;  /* olive */
  --u-Espen:   #2f6e6a;  /* teal */
  --u-default: #6e5d44;

  /* Type */
  --font-display: "Fraunces", "Cormorant Garamond", "Georgia", serif;
  --font-body:    "Newsreader", "Georgia", serif;

  /* Effects */
  --shadow-card:    0 4px 0 -2px var(--paper-edge), 0 10px 24px -12px rgba(50, 30, 10, 0.18);
  --shadow-modal:   0 30px 80px -20px rgba(40, 25, 10, 0.35);
  --radius:         4px;
  --radius-lg:      8px;
}

/* ---------- reset + body ---------- */
*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

/* HTML's [hidden] must win over our layout display values */
[hidden] { display: none !important; }

body {
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  background-image:
    radial-gradient(rgba(50, 30, 10, 0.045) 1px, transparent 1.4px),
    radial-gradient(rgba(50, 30, 10, 0.03) 1px, transparent 1.4px),
    linear-gradient(180deg, var(--paper) 0%, var(--paper) 100%);
  background-size: 5px 5px, 9px 9px, 100% 100%;
  background-position: 0 0, 2px 3px, 0 0;
  min-height: 100vh;
  overflow-x: hidden;
}

::selection { background: var(--rust); color: var(--paper-warm); }

/* ---------- typographic primitives ---------- */
h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  font-variation-settings: "opsz" 90, "SOFT" 50;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--ink);
}

h1 { font-size: clamp(2.2rem, 4vw, 3.2rem); line-height: 0.95; font-weight: 700; font-variation-settings: "opsz" 144, "SOFT" 80; }
h2 { font-size: clamp(1.5rem, 2.6vw, 2rem); line-height: 1.05; }
h3 { font-size: 1.05rem; }

.overline {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  display: inline-block;
}

.hint {
  color: var(--ink-soft);
  font-size: 0.95rem;
  margin: 0.4rem 0 0;
  max-width: 60ch;
}
.hint strong { color: var(--forest); font-weight: 600; }

.error {
  color: var(--rust-deep);
  font-size: 0.92rem;
  margin: 0.6rem 0 0;
  font-style: italic;
}

/* ---------- masthead ---------- */
.masthead {
  padding: clamp(1.4rem, 3vw, 2.6rem) clamp(1rem, 3vw, 3rem) 0.6rem;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1.5rem;
  border-bottom: 1px solid var(--line);
  position: relative;
}
.masthead::before {
  /* second hairline under for editorial double-rule */
  content: "";
  position: absolute;
  left: clamp(1rem, 3vw, 3rem);
  right: clamp(1rem, 3vw, 3rem);
  bottom: -4px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.9rem;
}
.brand-mark {
  color: var(--rust);
  flex-shrink: 0;
  transform: rotate(-4deg);
}
.brand-text .overline { display: block; margin-bottom: 0.15rem; }

.masthead-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.2rem;
}

.back-home {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-soft);
  text-decoration: none;
  letter-spacing: 0.04em;
  transition: color 0.15s;
}
.back-home:hover { color: var(--rust); }

.who {
  font-size: 0.95rem;
  color: var(--ink-soft);
}
.who strong {
  color: var(--ink);
  font-weight: 600;
  font-family: var(--font-display);
}
.who .logout-btn {
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  margin-left: 0.6rem;
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.who .logout-btn:hover {
  background: var(--ink);
  color: var(--paper-warm);
  border-color: var(--ink);
}

/* ---------- login screen ---------- */
.login {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 60vh;
  padding: 3rem 1rem;
}
.login-card {
  background: var(--paper-warm);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 2rem 2.2rem 2.2rem;
  max-width: 460px;
  width: 100%;
  box-shadow: var(--shadow-card);
  position: relative;
}
.login-card::before {
  /* rotated stamp */
  content: "Kollektiv";
  position: absolute;
  top: -14px;
  right: 24px;
  transform: rotate(8deg);
  background: var(--rust);
  color: var(--paper-warm);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  padding: 0.3rem 0.7rem;
  border-radius: 2px;
  box-shadow: 0 2px 0 var(--rust-deep);
}
.login-card h2 { margin: 0.3rem 0 0.5rem; }

.login-form {
  display: grid;
  gap: 1rem;
  margin-top: 1.2rem;
}

.field { display: grid; gap: 0.3rem; }
.field > span {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.field select, .field input {
  font-family: var(--font-body);
  font-size: 1.05rem;
  padding: 0.7rem 0.85rem;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field select:focus, .field input:focus,
.suggest-form input:focus {
  border-color: var(--rust);
  box-shadow: 0 0 0 3px var(--rust-soft);
}

/* ---------- buttons ---------- */
.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1rem;
  padding: 0.7rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s, color 0.15s;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--ink);
  color: var(--paper-warm);
  border-color: var(--ink);
}
.btn-primary:hover { background: var(--rust); border-color: var(--rust); }

/* ---------- app shell ---------- */
.app {
  padding: clamp(1.5rem, 3vw, 2.8rem) clamp(1rem, 3vw, 3rem) 4rem;
  display: grid;
  gap: 3rem;
  max-width: 1280px;
  margin: 0 auto;
}

.panel {
  position: relative;
}
.panel-head {
  margin-bottom: 1.4rem;
}
.panel-head .overline { display: block; margin-bottom: 0.35rem; }
.panel-head h2 { margin-bottom: 0.2rem; }

.calendar-head-actions {
  display: grid;
  gap: 0.65rem;
}

.ai-plan-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.availability-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.availability-status {
  min-height: 1em;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.ai-plan-status {
  font-size: 0.82rem;
  color: var(--ink-soft);
}

/* ---------- calendar grid ---------- */
.weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.6rem;
  padding: 0 0.2rem;
  margin-bottom: 0.6rem;
}
.weekdays span {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
  text-align: left;
  padding-left: 0.3rem;
}
.weekdays span:nth-child(6),
.weekdays span:nth-child(7) { color: var(--rust); }

.calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 0.6rem;
}

.cal-empty {
  background:
    repeating-linear-gradient(
      135deg,
      transparent 0 6px,
      rgba(0, 0, 0, 0.025) 6px 7px
    );
  border-radius: var(--radius);
  min-height: 150px;
}

.day {
  position: relative;
  background: var(--paper-warm);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.7rem 0.75rem 0.8rem;
  min-height: 150px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  text-align: left;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  box-shadow: 0 1px 0 var(--paper-edge);
  /* fine torn-paper look on top */
  background-image:
    radial-gradient(rgba(50, 30, 10, 0.025) 1px, transparent 1.4px);
  background-size: 6px 6px;
  background-position: 0 0;

}
.day:hover {
  transform: translateY(-2px) rotate(-0.4deg);
  box-shadow: var(--shadow-card);
  z-index: 2;
}
.day:focus-visible {
  outline: 2px solid var(--rust);
  outline-offset: 2px;
}

/* Day card meta line */
.day-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
}
.day-weekday {
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.day-number {
  font-family: var(--font-display);
  font-weight: 700;
  font-variation-settings: "opsz" 144, "SOFT" 80;
  font-size: 2.1rem;
  line-height: 0.85;
  color: var(--ink);
  letter-spacing: -0.02em;
}
.day-month {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin-left: 0.3rem;
}

/* "Today" stamp */
.day.is-today .day-number {
  position: relative;
  z-index: 1;
}
.day.is-today .day-number::after {
  content: "";
  position: absolute;
  inset: -8px -10px -6px -10px;
  background: var(--rust-soft);
  border: 1.5px solid var(--rust);
  border-radius: 50%;
  transform: rotate(-6deg);
  z-index: -1;
  opacity: 0.85;
}
.day.is-today .day-weekday { color: var(--rust); font-weight: 700; }

/* Weekend tint */
.day.is-weekend { background-color: #f6e9c8; }

/* Everyone in */
.day.is-everyone {
  background-color: var(--forest-soft);
  border-color: var(--forest-line);
}
.day.is-everyone .day-weekday { color: var(--forest); }
.day.is-everyone .day-number  { color: var(--forest); }
.day .everyone-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  background: var(--forest);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--paper-warm);
  transform: rotate(8deg);
  box-shadow: 0 2px 0 #324d28;
}
.day .everyone-badge svg { width: 16px; height: 16px; }
.day:not(.is-everyone) .everyone-badge { display: none; }

/* Avatars row */
.avatars {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.avatar {
  --user-color: var(--u-default);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--user-color);
  background: transparent;
  color: var(--user-color);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.66rem;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  transition: transform 0.1s, background 0.15s, color 0.15s;
  position: relative;
  text-transform: uppercase;
}
.avatar[data-user="Gorm"]   { --user-color: var(--u-Gorm); }
.avatar[data-user="Erling"] { --user-color: var(--u-Erling); }
.avatar[data-user="Vemund"] { --user-color: var(--u-Vemund); }
.avatar[data-user="Espen"]  { --user-color: var(--u-Espen); }

.avatar.is-in {
  background: var(--user-color);
  color: var(--paper-warm);
}
.avatar.is-mine {
  box-shadow: 0 0 0 2.5px var(--paper-warm), 0 0 0 3.5px var(--user-color);
}

/* Self-toggle button inside day card — one-tap "I'm eating" */
.day-self {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  padding: 0.32rem 0.55rem;
  border-radius: 999px;
  border: 1.5px dashed var(--line);
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.1s;
  align-self: flex-start;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.day-self:hover {
  background: var(--ink);
  color: var(--paper-warm);
  border-color: var(--ink);
  border-style: solid;
}
.day-self.is-on {
  background: var(--forest);
  color: var(--paper-warm);
  border: 1.5px solid var(--forest);
}
.day-self.is-on:hover {
  background: var(--rust);
  border-color: var(--rust);
}
.day-self:active { transform: translateY(1px); }

/* Suggestion teaser inside day card */
.day-sugs {
  padding-top: 0.5rem;
  border-top: 1px dashed var(--line-soft);
  display: grid;
  grid-template-columns: minmax(0, 1fr); /* prevent auto-column from expanding to fit long content */
  gap: 0.25rem;
  min-width: 0;
}
.day-sug {
  font-family: var(--font-body);
  font-size: 0.85rem;
  line-height: 1.3;
  color: var(--ink);
  display: flex;
  justify-content: space-between;
  gap: 0.4rem;
  min-width: 0;
}
.day-sug .text {
  flex: 1 1 0; /* explicit 0 basis so it can shrink below content */
  min-width: 0; /* flex items need this for truncation to fire */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.day-sug .like-count {
  font-family: var(--font-display);
  font-weight: 600;
  font-style: italic;
  color: var(--rust);
  font-size: 0.85rem;
  flex-shrink: 0;
}
.day-sugs .more {
  font-size: 0.75rem;
  color: var(--ink-faint);
  font-style: italic;
}

/* ---------- general suggestions panel ---------- */
.suggestion-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1.4rem;
  display: grid;
  gap: 0.6rem;
}
.suggestion-list:empty { display: none; }

.sug {
  background: var(--paper-warm);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.75rem 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  box-shadow: 0 1px 0 var(--paper-edge);
  position: relative;
}
.sug-body {
  flex: 1;
  min-width: 0;
}
.sug-text {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 500;
  font-variation-settings: "opsz" 36, "SOFT" 40;
  line-height: 1.25;
  color: var(--ink);
  word-break: break-word;
}
.sug-meta {
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin-top: 0.15rem;
}
.sug-meta .by {
  font-style: italic;
}
.sug-meta .by-name {
  font-weight: 600;
  color: var(--ink);
  font-style: normal;
}
.sug-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}
.like-btn {
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 600;
  background: transparent;
  color: var(--rust);
  border: 1.5px solid var(--rust);
  padding: 0.32rem 0.7rem;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}
.like-btn .heart {
  width: 14px; height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
}
.like-btn:hover { background: var(--rust-soft); }
.like-btn.is-liked {
  background: var(--rust);
  color: var(--paper-warm);
}
.like-btn.is-liked .heart { fill: currentColor; stroke: currentColor; }
.like-btn:active { transform: scale(0.96); }

.delete-btn {
  background: none;
  border: none;
  color: var(--ink-faint);
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-style: italic;
  cursor: pointer;
  padding: 0.3rem 0.4rem;
  transition: color 0.15s;
}
.delete-btn:hover { color: var(--rust); text-decoration: underline; }

.suggest-form {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.suggest-form input {
  flex: 1 1 200px;
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 0.7rem 0.9rem;
  background: var(--paper-warm);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.empty-msg {
  font-style: italic;
  color: var(--ink-faint);
  padding: 0.6rem 0.95rem;
  font-size: 0.95rem;
}

.footer {
  border-top: 1px solid var(--line);
  padding-top: 1rem;
  text-align: center;
  color: var(--ink-faint);
}

/* ---------- tabs ---------- */
.tab-nav {
  display: flex;
  gap: 0.25rem;
  border-bottom: 2px solid var(--line);
  margin-bottom: 0;
  padding-bottom: 0;
}
.tab-btn {
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 0.55rem 1.1rem;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  border-radius: var(--radius) var(--radius) 0 0;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.tab-btn:hover { color: var(--ink); background: var(--paper-warm); }
.tab-btn.active {
  color: var(--ink);
  border-bottom-color: var(--rust);
  background: transparent;
}

.tab-panel { padding-top: 2rem; display: grid; gap: 3rem; }
.tab-panel[hidden] { display: none; }

/* ---------- recipe cards ---------- */
.recipe-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1.6rem;
  display: grid;
  gap: 0.8rem;
}
.recipe-list:empty { display: none; }

.recipe-card {
  background: var(--paper-warm);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 0 var(--paper-edge);
  overflow: hidden;
}
.recipe-card-head {
  padding: 0.85rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
}
.recipe-card-head::-webkit-details-marker { display: none; }
.recipe-card-title {
  flex: 1;
  min-width: 0;
}
.recipe-name {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  font-variation-settings: "opsz" 36, "SOFT" 40;
  color: var(--ink);
  line-height: 1.2;
}
.recipe-meta {
  font-size: 0.8rem;
  color: var(--ink-soft);
  margin-top: 0.1rem;
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.recipe-meta span { display: inline-flex; align-items: center; gap: 0.2rem; }

.recipe-card-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.recipe-expand-btn {
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  width: 28px; height: 28px;
  color: var(--ink-soft);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  transition: background 0.15s, color 0.15s, transform 0.2s;
}
.recipe-expand-btn:hover { background: var(--paper); color: var(--ink); }
.recipe-expand-btn.is-open { transform: rotate(180deg); }

.recipe-body {
  padding: 0 1rem 1rem;
  border-top: 1px dashed var(--line-soft);
  margin-top: 0;
}
.recipe-body[hidden] { display: none; }

.recipe-section { margin-top: 0.9rem; }
.recipe-section h4 {
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 0.4rem;
}
.recipe-ingr-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.2rem;
}
.recipe-ingr-list li {
  font-size: 0.95rem;
  padding-left: 1rem;
  position: relative;
}
.recipe-ingr-list li::before {
  content: "·";
  position: absolute;
  left: 0;
  color: var(--ink-faint);
}
.recipe-method {
  font-size: 0.95rem;
  line-height: 1.6;
  white-space: pre-wrap;
  color: var(--ink);
}

/* ---------- add recipe form ---------- */
.add-recipe-wrap { margin-top: 0.5rem; }
.add-recipe-form {
  margin-top: 1rem;
  display: grid;
  gap: 1rem;
  background: var(--paper-warm);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.4rem 1.4rem 1.2rem;
}

.form-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.field-grow { flex: 1 1 200px; }
.field-sm { flex: 0 0 100px; }

.field textarea {
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 0.6rem 0.85rem;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  resize: vertical;
  width: 100%;
  box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field textarea:focus {
  border-color: var(--rust);
  box-shadow: 0 0 0 3px var(--rust-soft);
}

.form-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
}

.btn-outline {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.btn-outline:hover { background: var(--paper-warm); border-color: var(--ink); }

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border-color: transparent;
}
.btn-ghost:hover { color: var(--rust); }

em.req { color: var(--rust); font-style: normal; }

/* ---------- log list ---------- */
.log-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1.6rem;
  display: grid;
  gap: 0.5rem;
}
.log-list:empty { display: none; }

.log-entry {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.7rem 1rem;
  background: var(--paper-warm);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 0 var(--paper-edge);
}
.log-date {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  font-variation-settings: "opsz" 48;
  color: var(--ink);
  white-space: nowrap;
  min-width: 90px;
}
.log-body { flex: 1; min-width: 0; }
.log-navn {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--ink);
  line-height: 1.2;
}
.log-detail {
  font-size: 0.78rem;
  color: var(--ink-soft);
  margin-top: 0.05rem;
}

/* ---------- log form ---------- */
.log-form {
  display: grid;
  gap: 0.9rem;
  background: var(--paper-warm);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 1.2rem 1.4rem;
}
.log-source-wrap { display: grid; gap: 0.5rem; }
.log-source-toggle {
  display: flex;
  gap: 1.2rem;
  font-size: 0.9rem;
  color: var(--ink-soft);
}
.log-source-toggle label { display: flex; align-items: center; gap: 0.35rem; cursor: pointer; }
.log-recipe-select,
.log-fri-tekst {
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 0.65rem 0.85rem;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.log-recipe-select:focus,
.log-fri-tekst:focus {
  border-color: var(--rust);
  box-shadow: 0 0 0 3px var(--rust-soft);
}

/* ---------- calendar log indicator ---------- */
.day-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.day-log {
  padding-top: 0.35rem;
  border-top: 1px solid var(--forest-line);
}
.day-log-text {
  font-family: var(--font-body);
  font-size: 0.8rem;
  color: var(--forest);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}
.day-log-text::before {
  content: "✓ ";
  font-size: 0.72rem;
  opacity: 0.8;
}

/* ---------- modal log section ---------- */
.modal-log-list {
  list-style: none;
  padding: 0;
  margin: 0 0 0.75rem;
  display: grid;
  gap: 0.4rem;
}
.modal-log-list:empty { display: none; }

.modal-log-entry {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  font-size: 0.9rem;
  padding: 0.3rem 0;
}
.modal-log-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  color: var(--ink);
  flex: 1;
}
.modal-log-meta {
  font-size: 0.78rem;
  color: var(--ink-soft);
  font-style: italic;
  white-space: nowrap;
}

.modal-log-form {
  display: grid;
  gap: 0.5rem;
  padding: 0.75rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-top: 0.3rem;
}
.modal-log-form select,
.modal-log-form input[type="text"],
.modal-log-form input[type="number"] {
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 0.5rem 0.75rem;
  background: var(--paper-warm);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.modal-log-form select:focus,
.modal-log-form input:focus {
  border-color: var(--rust);
  box-shadow: 0 0 0 3px var(--rust-soft);
}
.modal-log-form input[type="number"] { width: auto; max-width: 120px; }
.modal-log-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.btn-sm {
  font-size: 0.88rem;
  padding: 0.45rem 0.85rem;
}

/* ---------- AI suggestion on calendar cards ---------- */
.day-sug.is-ai {
  font-style: italic;
  color: var(--ink-soft);
  border-left: 2px solid var(--rust);
  padding-left: 0.4rem;
  opacity: 0.85;
}
.day-sug.is-ai.is-accepted {
  opacity: 1;
  border-left-color: var(--forest);
  color: var(--forest);
}
.day-sug.is-ai .text::before {
  content: "✨ ";
  font-style: normal;
  font-size: 0.7em;
}

/* ---------- AI recipe button pair ---------- */
.add-recipe-btns {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.btn-ai {
  color: var(--rust);
  border-color: var(--rust);
}
.btn-ai:hover {
  background: var(--rust);
  color: var(--paper-warm);
  border-color: var(--rust);
}

/* ---------- AI recipe fill form ---------- */
.ai-recipe-form {
  margin-top: 1rem;
  display: grid;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

/* ---------- AI modal section ---------- */
.ai-forslag-list {
  list-style: none;
  padding: 0;
  margin: 0 0 0.75rem;
  display: grid;
  gap: 0.5rem;
}
.ai-forslag-list:empty { display: none; }

.ai-forslag-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  border-left: 3px solid var(--rust);
  transition: border-color 0.15s;
}
.ai-forslag-item.is-accepted {
  border-left-color: var(--forest);
  background: var(--forest-soft);
}
.ai-forslag-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.ai-forslag-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
}
.ai-forslag-desc {
  font-size: 0.82rem;
  color: var(--ink-soft);
  font-style: italic;
}
.ai-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--forest-soft);
  color: var(--forest);
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  margin-top: 0.2rem;
  width: fit-content;
}
.ai-forslag-actions {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: flex-end;
  flex-shrink: 0;
}

/* ---------- day recipe modal form ---------- */
.modal-day-recipe-form {
  display: grid;
  gap: 0.5rem;
  padding: 0.75rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-top: 0.5rem;
}
.modal-day-recipe-form input[type="text"],
.modal-day-recipe-form input[type="number"] {
  font-family: var(--font-body);
  font-size: 0.95rem;
  padding: 0.5rem 0.75rem;
  background: var(--paper-warm);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  outline: none;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.modal-day-recipe-form input:focus {
  border-color: var(--rust);
  box-shadow: 0 0 0 3px var(--rust-soft);
}
.modal-day-recipe-form input[type="number"] { width: auto; max-width: 120px; }

/* ---------- spiskammer / pantry ---------- */
.pantry-list {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem;
  display: grid;
  gap: 0.4rem;
}
.pantry-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 0.75rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.pantry-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.pantry-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
}
.pantry-notat {
  font-size: 0.78rem;
  color: var(--ink-soft);
  font-style: italic;
}
.pantry-form {
  display: grid;
  gap: 0.75rem;
}

/* ---- push notification bar ---- */
#push-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: -1.8rem;
}
#push-btn {
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.28rem 0.85rem;
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--ink-soft);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
#push-btn::before {
  content: "🔔";
  font-size: 13px;
  line-height: 1;
}
#push-btn:hover {
  background: var(--ink);
  color: var(--paper-warm);
  border-color: var(--ink);
}
#push-btn[aria-pressed="true"] {
  background: var(--forest);
  color: var(--paper-warm);
  border-color: var(--forest);
}
#push-btn[aria-pressed="true"]::before { content: "🔕"; }
#push-btn:disabled { opacity: 0.5; cursor: wait; }

/* ---------- modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1rem, 3vw, 2rem);
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(31, 24, 16, 0.55);
  backdrop-filter: blur(2px);
  animation: backdropIn 0.2s ease forwards;
}
@keyframes backdropIn { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  position: relative;
  background: var(--paper-warm);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  width: min(560px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  padding: 1.8rem 1.8rem 1.6rem;
  box-shadow: var(--shadow-modal);
  background-image:
    radial-gradient(rgba(50, 30, 10, 0.025) 1px, transparent 1.4px);
  background-size: 6px 6px;
  animation: cardIn 0.28s cubic-bezier(0.2, 0.7, 0.3, 1.1) forwards;
  transform-origin: center 30%;
}
@keyframes cardIn {
  from { opacity: 0; transform: scale(0.94) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-close {
  position: absolute;
  top: 0.7rem;
  right: 0.7rem;
  width: 36px; height: 36px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 50%;
  color: var(--ink-soft);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.modal-close:hover { background: var(--paper); color: var(--rust); border-color: var(--line); }

.modal-header {
  margin-bottom: 1.4rem;
  border-bottom: 1px dashed var(--line);
  padding-bottom: 1.1rem;
}
.modal-header .overline { display: block; margin-bottom: 0.2rem; color: var(--rust); }
.modal-header h2 {
  font-size: clamp(1.7rem, 3.5vw, 2.4rem);
  font-weight: 700;
  font-variation-settings: "opsz" 144, "SOFT" 80;
  line-height: 1;
}
.modal-status {
  margin-top: 0.6rem;
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1rem;
  color: var(--ink-soft);
}
.modal-status.is-on { color: var(--forest); font-weight: 600; font-style: normal; }
.modal-status.is-on::before {
  content: "✻ ";
  color: var(--forest);
}

.modal-section { margin-top: 1.2rem; }
.modal-section .overline { display: block; margin-bottom: 0.55rem; }

.avatars-row {
  display: flex;
  gap: 0.7rem;
  margin-bottom: 0.9rem;
  flex-wrap: wrap;
}
.avatars-row .avatar {
  width: 44px;
  height: 44px;
  font-size: 1rem;
  border-width: 2px;
}
.avatars-row .avatar-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}
.avatars-row .avatar-label {
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.mine-toggle {
  width: 100%;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  padding: 0.8rem 1rem;
  border-radius: var(--radius);
  border: 1.5px solid var(--ink);
  cursor: pointer;
  background: var(--ink);
  color: var(--paper-warm);
  transition: background 0.15s, color 0.15s, transform 0.1s, border-color 0.15s;
}
.mine-toggle:hover { background: var(--rust); border-color: var(--rust); }
.mine-toggle.is-on {
  background: var(--forest-soft);
  color: var(--forest);
  border-color: var(--forest-line);
}
.mine-toggle.is-on:hover { background: var(--paper); }
.mine-toggle:active { transform: translateY(1px); }

/* ---------- responsive ---------- */

/* Tablet — keep the 7-col grid, just tighten things up a bit. */
@media (max-width: 980px) and (min-width: 721px) {
  .avatar { width: 24px; height: 24px; font-size: 0.6rem; }
  .day-self { font-size: 0.72rem; padding: 0.28rem 0.5rem; }
  .day-sug { font-size: 0.78rem; }
}

/* Phone — switch from grid calendar to a vertical "agenda" of day cards.
   7 columns at <720px gives ~50px cells which is unusable. Each day
   becomes a full-width card with the same data, just laid out for thumbs. */
@media (max-width: 720px) {
  .masthead { padding: 1rem 1rem 0.5rem; }
  h1 { font-size: 1.9rem; }
  .who { font-size: 0.88rem; }

  .app { padding: 1.2rem 0.9rem 3rem; gap: 2rem; }

  .panel-head { margin-bottom: 1rem; }
  .panel-head h2 { font-size: 1.45rem; }

  /* hide the weekday header row and the leading/trailing empty cells */
  .weekdays { display: none; }
  .cal-empty { display: none; }

  /* one card per row, full-width */
  .calendar {
    grid-template-columns: minmax(0, 1fr);
    gap: 0.55rem;
    width: 100%;
    max-width: 100%;
  }
  .panel { max-width: 100%; min-width: 0; }
  .calendar-panel { min-width: 0; }

  .day {
    min-height: auto;
    min-width: 0; /* so long content can't expand the card */
    overflow: hidden; /* belt-and-suspenders: clip anything that escapes */
    padding: 0.9rem 1rem;
    gap: 0.65rem;
    flex-direction: column;
    align-items: stretch;
    background-image:
      radial-gradient(rgba(50, 30, 10, 0.02) 1px, transparent 1.4px);
  }
  .day:hover { transform: none; }  /* no hover effects on touch */

  .day-head {
    justify-content: flex-start;
    align-items: baseline;
    gap: 0.7rem;
    border-bottom: 1px dashed var(--line-soft);
    padding-bottom: 0.55rem;
    padding-right: 40px; /* clearance for the everyone-badge in top-right */
  }
  .day-weekday {
    font-size: 0.72rem;
    letter-spacing: 0.14em;
  }
  .day-number {
    font-size: 1.7rem;
    line-height: 1;
    padding-left: 8px; /* leave space for today stamp ::after */
  }
  .day-month {
    display: inline;
    font-size: 0.8rem;
    margin-left: 0.3rem;
  }

  /* today stamp scales with the smaller number */
  .day.is-today .day-number::after {
    inset: -6px -8px -4px -8px;
  }

  /* avatars row: full size, comfortable */
  .avatars {
    gap: 8px;
    justify-content: flex-start;
  }
  .avatar {
    width: 30px;
    height: 30px;
    font-size: 0.7rem;
    border-width: 1.5px;
  }
  .avatar.is-mine {
    box-shadow: 0 0 0 2.5px var(--paper-warm), 0 0 0 3.5px var(--user-color);
  }

  /* toggle button: full-width, big tap target */
  .day-self {
    font-size: 0.95rem;
    padding: 0.65rem 1rem;
    border-radius: 8px;
    border-width: 1.5px;
    text-align: center;
    align-self: stretch;
    max-width: none;
  }
  .day-self::before { content: none; }   /* undo any icon-only override */

  /* suggestions: comfortable line height, no truncation */
  .day-sugs {
    padding-top: 0.55rem;
    gap: 0.3rem;
  }
  .day-sug {
    font-size: 0.95rem;
    line-height: 1.3;
    display: block;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
  }
  .day-sug .text {
    display: block;
    flex: none;
    width: 100%;
    max-width: 100%;
    white-space: normal;
    overflow: visible;
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  .day-sug .like-count {
    display: inline-block;
    margin-top: 0.15rem;
    font-size: 0.85rem;
    white-space: nowrap;
  }
  .day-sugs .more { font-size: 0.85rem; }

  /* everyone badge: keep top-right but tone down */
  .day .everyone-badge {
    width: 28px;
    height: 28px;
    top: 10px;
    right: 10px;
  }

  /* modal: full-bleed on phone */
  .modal { padding: 0; align-items: stretch; }
  .modal-card {
    width: 100%;
    max-height: 100vh;
    border-radius: 0;
    border: none;
    padding: 1.4rem 1.1rem 1.6rem;
  }
  .modal-header h2 { font-size: 1.8rem; }
  .avatars-row { gap: 0.6rem; }
  .avatars-row .avatar { width: 40px; height: 40px; font-size: 0.85rem; }

  /* general suggestion list */
  .sug { padding: 0.7rem 0.85rem; }
  .sug-text { font-size: 1rem; }
  .suggest-form { gap: 0.5rem; }
  .suggest-form input { font-size: 0.95rem; padding: 0.65rem 0.8rem; }
  .btn { font-size: 0.95rem; padding: 0.65rem 1rem; }
}
