/* ---------- Design tokens ---------- */
:root {
  --paper: #eef1e8;
  --paper-card: #fbfaf4;
  --ink: #263229;
  --ink-soft: #5c6b5e;
  --moss: #4b6b4e;
  --moss-deep: #33492f;
  --moss-tint: #dce6da;
  --ochre: #c98a2e;
  --ochre-soft: #f0dcb8;
  --rose-soft: #f2dde0;
  --line: #d8dcc9;
  --shadow: 0 1px 0 rgba(38, 50, 41, 0.06), 0 6px 16px -10px rgba(38, 50, 41, 0.25);

  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-body: "Karla", "Segoe UI", system-ui, sans-serif;

  /* the header band is deliberately dark in both themes, so its text
     stays a fixed light tone rather than following the surface tokens */
  --signboard-ink: #fbfaf4;

  /* one color per barnehage — fixed base values, used as-is in light
     mode and lightened under the dark-mode blocks below so each stays
     legible on whichever surface it lands on */
  --bh-kirkerudbakken: #c1573d;
  --bh-kolsastrollet: #3e7ca6;
  --bh-ekrekroken: #9c5b9e;
  --bh-sollia: #a69436;
  --bh-oddenskogen: #3f8e7c;
  --bh-epleskogen: #b4484f;
  --bh-gjettum: #5c5fa0;
  --bh-berghoff: #8a6a3e;
  --bh-grindaberget: #a34568;
  --bh-marihona: #6e8a3f;

  /* fixed (never flips) — for the signboard header, which stays dark
     in both themes */
  --bhfix-kirkerudbakken: #c1573d;
  --bhfix-kolsastrollet: #3e7ca6;
  --bhfix-ekrekroken: #9c5b9e;
  --bhfix-sollia: #a69436;
  --bhfix-oddenskogen: #3f8e7c;
  --bhfix-epleskogen: #b4484f;
  --bhfix-gjettum: #5c5fa0;
  --bhfix-berghoff: #8a6a3e;
  --bhfix-grindaberget: #a34568;
  --bhfix-marihona: #6e8a3f;

  /* the currently selected barnehage's color, set by app.js */
  --you: var(--moss);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1b211c;
    --paper-card: #232a22;
    --ink: #edeee4;
    --ink-soft: #a8b2a0;
    --moss: #86ab80;
    --moss-deep: #a8c6a2;
    --moss-tint: #2b3a2b;
    --ochre: #e3a94a;
    --ochre-soft: #3a331f;
    --rose-soft: #3a2a2c;
    --line: #3a4238;
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 10px 24px -14px rgba(0, 0, 0, 0.6);

    --bh-kirkerudbakken: #e07e5f;
    --bh-kolsastrollet: #6fa3c9;
    --bh-ekrekroken: #c285c4;
    --bh-sollia: #cbb466;
    --bh-oddenskogen: #63b39f;
    --bh-epleskogen: #d3767c;
    --bh-gjettum: #8586c4;
    --bh-berghoff: #b08f5f;
    --bh-grindaberget: #c56f8d;
    --bh-marihona: #9db568;
  }
}

:root[data-theme="dark"] {
  --paper: #1b211c;
  --paper-card: #232a22;
  --ink: #edeee4;
  --ink-soft: #a8b2a0;
  --moss: #86ab80;
  --moss-deep: #a8c6a2;
  --moss-tint: #2b3a2b;
  --ochre: #e3a94a;
  --ochre-soft: #3a331f;
  --rose-soft: #3a2a2c;
  --line: #3a4238;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 10px 24px -14px rgba(0, 0, 0, 0.6);

  --bh-kirkerudbakken: #e07e5f;
  --bh-kolsastrollet: #6fa3c9;
  --bh-ekrekroken: #c285c4;
  --bh-sollia: #cbb466;
  --bh-oddenskogen: #63b39f;
  --bh-epleskogen: #d3767c;
  --bh-gjettum: #8586c4;
  --bh-berghoff: #b08f5f;
  --bh-grindaberget: #c56f8d;
  --bh-marihona: #9db568;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { color-scheme: light dark; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

@media (prefers-reduced-motion: no-preference) {
  .card, .primary-btn, .ghost-btn, .vote-btn { transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease; }
}

/* ---------- Header ---------- */
.site-header {
  position: relative;
  background: var(--moss-deep);
  color: var(--signboard-ink);
  padding: 2.75rem 1.5rem 2.25rem;
  overflow: hidden;
}
:root:not([data-theme="light"]) .site-header,
:root[data-theme="dark"] .site-header {
  background: #14201a;
}
.site-header::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(251, 250, 244, 0.07) 1.4px, transparent 1.4px);
  background-size: 18px 18px;
  pointer-events: none;
}

.header-inner { position: relative; max-width: 62rem; margin: 0 auto; }

.eyebrow {
  font-family: var(--font-body);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  opacity: 0.75;
  margin: 0 0 0.5rem;
}

.site-header h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.2rem, 5vw, 3.2rem);
  margin: 0 0 0.6rem;
  text-wrap: balance;
}

.lede {
  max-width: 38rem;
  opacity: 0.9;
  margin: 0 0 1.4rem;
  font-size: 1.05rem;
}

.barnehage-tags {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0;
  margin: 0;
}
.barnehage-tags li {
  --tag-color: color-mix(in srgb, var(--bh-color, #fbfaf4) 78%, white);
  border: 1.5px solid var(--tag-color);
  color: var(--tag-color);
  border-radius: 999px;
  padding: 0.3rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 700;
}

/* ---------- Identity bar ---------- */
.identity-bar {
  background: var(--paper-card);
  border-bottom: 3px solid var(--you);
  position: sticky;
  top: 0;
  z-index: 5;
  transition: border-color 0.2s ease;
}
.identity-inner {
  max-width: 62rem;
  margin: 0 auto;
  padding: 0.85rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  align-items: end;
}
.identity-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink-soft);
}
.identity-field em { font-weight: 400; font-style: normal; }
.identity-field select,
.identity-field input {
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--ink);
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  min-width: 12rem;
}

/* ---------- Notice board ---------- */
.notice-board {
  background: var(--ochre-soft);
  border-bottom: 1px solid var(--line);
}
.notice-board-inner {
  max-width: 62rem;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 1.75rem;
}
.notice-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.2rem;
  padding-top: 0.3rem;
}
/* A literal sticky note — used for both the notice board and each
   proposed date, so they read as scraps stuck onto the board rather
   than as ordinary UI rows. */
.postit {
  position: relative;
  border: none !important;
  background: var(--note-color);
  box-shadow:
    0 1px 1px rgba(38, 50, 41, 0.18),
    0 7px 10px -3px rgba(38, 50, 41, 0.3),
    0 16px 22px -14px rgba(38, 50, 41, 0.4);
  transform: rotate(var(--tilt, 0deg));
}
.postit::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 1.3rem;
  height: 1.3rem;
  background: linear-gradient(
    135deg,
    transparent 47%,
    rgba(38, 50, 41, 0.22) 48% 51%,
    rgba(255, 255, 255, 0.4) 52%,
    transparent 63%
  );
  border-radius: 0 10px 0 0;
  pointer-events: none;
}
@media (prefers-reduced-motion: no-preference) {
  .postit { transition: transform 0.2s ease, box-shadow 0.2s ease; }
  .postit:hover {
    transform: rotate(0deg) translateY(-3px) scale(1.015);
    box-shadow:
      0 1px 1px rgba(38, 50, 41, 0.18),
      0 12px 18px -6px rgba(38, 50, 41, 0.34),
      0 22px 30px -18px rgba(38, 50, 41, 0.45);
  }
}

.notice-card {
  flex: 1 1 220px;
  max-width: 320px;
  padding: 1rem 1.1rem 1.2rem;
}
.notice-stack .postit:nth-child(3n+1) { --tilt: -2.2deg; --note-color: var(--ochre-soft); }
.notice-stack .postit:nth-child(3n+2) { --tilt: 1.8deg; --note-color: var(--moss-tint); }
.notice-stack .postit:nth-child(3n+3) { --tilt: -1.4deg; --note-color: var(--rose-soft); }
.notice-message {
  font-size: 0.95rem;
  margin: 0 0 0.4rem;
  padding-right: 1.2rem;
  white-space: pre-wrap;
}
.notice-location {
  font-size: 0.85rem;
  color: var(--ink-soft);
  margin: 0 0 0.4rem;
}
.notice-location:empty { display: none; }

/* ---------- Layout ---------- */
.board-grid {
  max-width: 62rem;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}
@media (min-width: 860px) {
  .board-grid { grid-template-columns: 1fr 1fr; align-items: start; }
}

.board-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  margin-bottom: 1rem;
}
.board-kicker {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ochre);
  margin: 0 0 0.15rem;
}
.board-head h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.5rem;
  margin: 0;
}

/* ---------- Buttons ---------- */
.primary-btn {
  background: var(--moss);
  color: var(--paper-card);
  border: none;
  border-radius: 8px;
  padding: 0.6rem 1.1rem;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
}
.primary-btn:hover { background: var(--moss-deep); }
.primary-btn.small { padding: 0.45rem 0.85rem; font-size: 0.85rem; }

.ghost-btn {
  background: transparent;
  border: 1px solid var(--moss);
  color: var(--moss);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
}
.ghost-btn:hover { background: var(--moss-tint); }

.text-btn {
  background: none;
  border: none;
  color: var(--ink-soft);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  padding: 0.4rem 0.2rem;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.text-btn:hover { color: var(--ink); }

button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--ochre);
  outline-offset: 2px;
}

/* ---------- Forms ---------- */
.add-form {
  background: var(--moss-tint);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  margin-bottom: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.form-row { display: flex; flex-direction: column; }
.form-row.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
}
.form-row label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink-soft);
}
.form-row em { font-weight: 400; font-style: normal; }
.form-row input, .form-row textarea {
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--ink);
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-card);
  resize: vertical;
}
.form-actions { display: flex; gap: 0.75rem; align-items: center; }

/* ---------- Cards ---------- */
.card-stack, .proposal-stack {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
.empty-state {
  color: var(--ink-soft);
  font-style: italic;
  padding: 1rem 0;
}

.card {
  position: relative;
  background: var(--paper-card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}

.meeting-card {
  padding-top: 1.4rem;
  transform: rotate(var(--tilt, 0deg));
}
.meeting-card::before {
  content: "";
  position: absolute;
  top: -0.4rem;
  left: 1.3rem;
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  background: var(--bh-color, var(--ochre));
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.25);
}
.card-stack .meeting-card:nth-child(3n+1) { --tilt: -0.6deg; }
.card-stack .meeting-card:nth-child(3n+2) { --tilt: 0.5deg; }
.card-stack .meeting-card:nth-child(3n+3) { --tilt: -0.3deg; }
@media (prefers-reduced-motion: no-preference) {
  .meeting-card { transition: transform 0.2s ease, box-shadow 0.2s ease; }
  .meeting-card:hover {
    transform: rotate(0deg) translateY(-2px);
    box-shadow: 0 2px 0 rgba(38, 50, 41, 0.06), 0 14px 22px -12px rgba(38, 50, 41, 0.32);
  }
}

.bh-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem 0.2rem 0.45rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--bh-color) 16%, var(--paper-card));
  color: var(--bh-color);
  white-space: nowrap;
}
.bh-badge::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: var(--bh-color);
  flex: none;
}

.card-remove {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  background: none;
  border: none;
  color: var(--ink-soft);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  border-radius: 6px;
}
.card-remove:hover { color: var(--ink); background: var(--moss-tint); }

.card-corner-actions {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.1rem;
}
.card-corner-actions .card-remove { position: static; }
.card-corner-actions .text-btn { text-decoration: none; font-size: 0.78rem; }

.meeting-card.is-past { opacity: 0.55; }

.card-date {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ochre);
  margin: 0 0 0.25rem;
}
.card-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.2rem;
  margin: 0 0 0.2rem;
  padding-right: 4.5rem;
}
.card-meta {
  color: var(--ink-soft);
  font-size: 0.88rem;
  margin: 0 0 0.3rem;
}
.card-note {
  font-size: 0.92rem;
  margin: 0;
}
.card-note:empty { display: none; }

.card-badge-row { margin-top: 0.5rem; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.card-badge-row:empty { display: none; }

.card-attendance {
  margin-top: 0.6rem;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--line);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.card-attendance:empty { display: none; }

.meeting-vote-actions {
  margin-top: 0.6rem;
  display: flex;
  gap: 0.5rem;
}
.attendance-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
}
.attendance-label {
  color: var(--ink-soft);
  font-weight: 700;
}

/* ---------- Proposal cards ---------- */
.proposal-card-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
  margin-bottom: 0.8rem;
}
.card-head-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex: none;
}
.card-head-actions .card-remove { position: static; }
.proposal-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
  margin: 0 0 0.2rem;
}
.proposal-description {
  color: var(--ink-soft);
  font-size: 0.9rem;
  margin: 0;
}
.proposal-description:empty { display: none; }

.option-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  margin-bottom: 0.6rem;
}
.option-list > .option-row-wrap:nth-child(3n+1) { --tilt: -1.6deg; --note-color: var(--ochre-soft); }
.option-list > .option-row-wrap:nth-child(3n+2) { --tilt: 1.3deg; --note-color: var(--moss-tint); }
.option-list > .option-row-wrap:nth-child(3n+3) { --tilt: -0.9deg; --note-color: var(--rose-soft); }

.edit-option-form {
  margin-top: 0.5rem;
  background: var(--moss-tint);
  border-radius: 10px;
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.option-row {
  border-radius: 10px;
  padding: 0.8rem 1rem 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
  position: relative;
}
.option-date {
  font-weight: 700;
  margin: 0 0 0.3rem;
  text-transform: capitalize;
}
.option-votes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}
.vote-chip {
  font-size: 0.75rem;
  font-weight: 700;
  background: color-mix(in srgb, var(--bh-color, var(--moss)) 20%, var(--paper-card));
  color: var(--bh-color, var(--moss-deep));
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
}
.vote-chip.is-empty {
  background: none;
  color: var(--ink-soft);
  font-weight: 400;
  padding: 0.15rem 0;
}
.vote-chip.is-no {
  background: var(--line);
  color: var(--ink-soft);
  text-decoration: line-through;
  text-decoration-thickness: 1.5px;
}
.option-votes-no:empty { display: none; }
.option-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.vote-btn {
  background: var(--paper);
  border: 1px solid var(--you);
  color: var(--you);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, background-color 0.15s ease, transform 0.15s ease;
}
.vote-btn.is-voted {
  background: var(--you);
  color: var(--paper-card);
}
.vote-btn.is-voted:active { transform: scale(0.96); }

.vote-no {
  border-color: var(--line);
  color: var(--ink-soft);
}
.vote-no.is-voted {
  background: var(--ink-soft);
  border-color: var(--ink-soft);
  color: var(--paper-card);
}
.option-remove {
  background: none;
  border: none;
  color: var(--ink-soft);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.2rem 0.3rem;
  border-radius: 6px;
}
.option-remove:hover { color: var(--ink); background: var(--moss-tint); }

.add-option-toggle { align-self: flex-start; }
.add-option-form {
  margin-top: 0.6rem;
  background: var(--moss-tint);
  border-radius: 10px;
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

/* ---------- Footer ---------- */
.site-footer {
  max-width: 62rem;
  margin: 0 auto;
  padding: 0 1.5rem 3rem;
  color: var(--ink-soft);
  font-size: 0.82rem;
}

/* ---------- Entrance ---------- */
@media (prefers-reduced-motion: no-preference) {
  @keyframes rise-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
  }
  .card-stack > .card, .proposal-stack > .card {
    animation: rise-in 0.35s ease backwards;
  }
  .card-stack > .card:nth-child(2), .proposal-stack > .card:nth-child(2) { animation-delay: 0.05s; }
  .card-stack > .card:nth-child(3), .proposal-stack > .card:nth-child(3) { animation-delay: 0.1s; }
  .card-stack > .card:nth-child(n+4), .proposal-stack > .card:nth-child(n+4) { animation-delay: 0.15s; }
}

/* ---------- Confetti (fired once when a date is locked in) ---------- */
.confetti-burst {
  position: fixed;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 50;
}
.confetti-dot {
  position: absolute;
  top: 0;
  left: 0;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--dot-color);
  animation: confetti-fly 0.7s ease-out forwards;
}
@keyframes confetti-fly {
  to {
    transform: translate(var(--dx), var(--dy)) rotate(var(--rot));
    opacity: 0;
  }
}

/* ---------- Config warning ---------- */
.config-warning {
  background: var(--ochre-soft);
  color: var(--ink);
  border-bottom: 1px solid var(--ochre);
  padding: 0.75rem 1.5rem;
  font-size: 0.88rem;
  font-weight: 700;
  text-align: center;
}
