/* Self-hosted display font (Bricolage Grotesque, SIL OFL 1.1) — no external
   requests, so it keeps the no-tracking promise. */
@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
  src: url("/fonts/BricolageGrotesque.woff2") format("woff2");
}

:root {
  --paper: #fbfaf6;
  --ink: #16201c;
  --muted: #6e7a74;
  --line: #e4e0d6;
  --green-0: #f1eee6;
  --green-1: #cbe7d2;
  --green-2: #93d3a8;
  --green-3: #4fb37c;
  --green-4: #1f8f58;
  --coral: #e2654c;
  --accent: #1f8f58;

  --serif: Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --display: "Bricolage Grotesque", "Trebuchet MS", var(--sans);
  --nav-h: 58px;
}

* {
  box-sizing: border-box;
}

/* Ensure the `hidden` attribute always wins, even on flex/grid elements
   whose class sets an explicit display. */
[hidden] {
  display: none !important;
}

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

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 18px 56px;
}

a {
  color: var(--accent);
}

h1,
h2,
h3 {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0;
}

.title {
  font-size: clamp(28px, 5vw, 36px);
  line-height: 1.04;
}

.subtitle {
  color: var(--muted);
  max-width: 62ch;
  margin: 8px 0 0;
}

.room-heading {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 12px;
}
.room-heading .title {
  font-size: clamp(22px, 3.4vw, 28px);
}
.room-title {
  font-family: var(--display);
  font-weight: 600;
  font-size: 16px;
  color: var(--muted);
  margin: 0;
}
.room-title:not(:empty)::before {
  content: "·";
  margin-right: 8px;
}

.hint {
  color: var(--muted);
  font-size: 13px;
  margin: 8px 0 0;
}

.foot {
  margin-top: 40px;
  color: var(--muted);
  font-size: 12px;
}

/* --- controls ---------------------------------------------------------- */
.btn {
  font: inherit;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.05s;
}
.btn:hover {
  border-color: var(--accent);
}
.btn:active {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn.primary:hover {
  filter: brightness(1.05);
}
.btn.icon {
  padding: 9px 13px;
  font-size: 18px;
  line-height: 1;
}

.input {
  font: inherit;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
}
.input::placeholder {
  color: var(--muted);
}
.code-input {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-family: var(--display);
  font-size: 20px;
}

.input.flash {
  animation: flash 0.9s ease;
}
@keyframes flash {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(226, 101, 76, 0);
  }
  25% {
    box-shadow: 0 0 0 3px rgba(226, 101, 76, 0.55);
  }
}

/* --- landing ----------------------------------------------------------- */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 26px;
}
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px;
}
.card h2 {
  font-size: 20px;
}
.card .input {
  margin-top: 12px;
}
.field {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* --- room header / share ---------------------------------------------- */
.room-head {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  align-items: center;
  justify-content: space-between;
}
.share {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.code-pill {
  display: inline-flex;
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 7px 14px;
}
.code-pill .code {
  font-family: var(--display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.14em;
}

.name-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 12px 0 0;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.name-bar .input {
  width: auto;
  flex: 1 1 200px;
}
.name-bar .hint {
  margin: 0;
  flex-basis: 100%;
}

/* --- toolbar ----------------------------------------------------------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
}
.segmented {
  display: inline-flex;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.segmented button {
  font: inherit;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 15px;
  border-radius: 999px;
  cursor: pointer;
}
.segmented button[aria-pressed="true"] {
  background: var(--accent);
  color: #fff;
}
.yearnav {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.yearnav .y {
  font-family: var(--display);
  font-size: 18px;
  font-weight: 600;
  min-width: 56px;
  text-align: center;
}

/* --- calendar (matches the spec exactly) ------------------------------- */
.calendar {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(228px, 1fr));
  gap: 16px;
  margin-top: 14px;
}
.month {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}
.month-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  min-height: 18px;
}
.month h3 {
  font-size: 14px;
  font-weight: 600;
  text-transform: capitalize;
  margin: 0;
}
.month-all {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}
.month-all input {
  width: 15px;
  height: 15px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent);
}
.weekdays,
.days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}
.weekdays span {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  text-align: center;
  letter-spacing: 0.04em;
}
.days {
  margin-top: 4px;
}
.day {
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  background: var(--green-0);
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
.day.blank {
  background: transparent;
}
.day.weekend {
  color: var(--muted);
}
.day.past {
  opacity: 0.38;
}
.day.painted {
  background: var(--green-3);
  color: #fff;
}
/* group / windows heatmap */
.day.h0 {
  background: var(--green-0);
}
.day.h1 {
  background: var(--green-1);
}
.day.h2 {
  background: var(--green-2);
}
.day.h3 {
  background: var(--green-3);
  color: #fff;
}
.day.h4 {
  background: var(--green-4);
  color: #fff;
  box-shadow: inset 0 0 0 2px var(--accent);
}
/* today ring and hover highlight win over heat rings (placed last) */
.day.today {
  box-shadow: inset 0 0 0 2px var(--coral);
  font-weight: 700;
}
.day.hl {
  box-shadow: inset 0 0 0 2px var(--coral);
  font-weight: 700;
}
.calendar.mode-mine .day:not(.blank) {
  cursor: pointer;
}

/* --- panels ------------------------------------------------------------ */
.panel {
  margin-top: 14px;
}

/* "Meilleures plages": narrow list on the left, wide calendar on the right.
   The list is sticky so you can hover its rows while scrolling the calendar. */
.content.windows-split {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-top: 14px;
}
.content.windows-split #panelWindows {
  order: 1;
  flex: 0 0 320px;
  max-width: 320px;
  margin-top: 0;
  position: sticky;
  top: 72px;
}
.content.windows-split #calendar {
  order: 2;
  flex: 1 1 0;
  min-width: 0;
  margin-top: 0;
}
.content.windows-split .win {
  cursor: pointer;
}
.content.windows-split .win .body {
  flex: 1 1 auto;
  min-width: 0;
}
@media (max-width: 760px) {
  .content.windows-split {
    flex-direction: column;
  }
  .content.windows-split #panelWindows {
    flex-basis: auto;
    max-width: none;
    position: static;
  }
}
.roster {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
}
.chip .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
}
.chip .count {
  color: var(--muted);
}
.chip.me {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  color: var(--muted);
  font-size: 13px;
  margin-top: 14px;
}
.legend .item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.legend .sw {
  width: 15px;
  height: 15px;
  border-radius: 4px;
  flex: none;
}

/* windows section header: title + hint on the left, N input inline on the right */
.windows-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px 16px;
}
.nfield-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}
.nfield-inline .input {
  width: 72px;
}

.windows {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.win {
  display: flex;
  gap: 16px;
  align-items: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px;
}
.win:hover {
  border-color: var(--accent);
}
.win .big {
  font-family: var(--display);
  font-size: 26px;
  font-weight: 600;
  line-height: 1;
  min-width: 62px;
  text-align: center;
  color: var(--accent);
}
.win .big small {
  display: block;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 400;
  color: var(--muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.win .body .range {
  font-weight: 600;
}
.win .body .meta {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}
.win .body .missing {
  color: var(--coral);
  font-size: 13px;
  margin-top: 2px;
}

/* --- notices / toast --------------------------------------------------- */
.notice {
  margin-top: 12px;
  padding: 9px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  font-size: 14px;
}
.notice.error {
  border-color: var(--coral);
  color: var(--coral);
}
.windows .notice {
  margin-top: 0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 9px 15px;
  border-radius: 10px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.toast.show {
  opacity: 1;
}

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

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
  .input.flash {
    animation: none;
    box-shadow: 0 0 0 3px rgba(226, 101, 76, 0.55);
  }
}

@media (max-width: 560px) {
  .wrap {
    padding: 20px 14px 56px;
  }
  .room-head {
    flex-direction: column;
  }
  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .segmented {
    justify-content: center;
  }
  .yearnav {
    justify-content: center;
  }
}

/* --- navbar ------------------------------------------------------------ */
.nav {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 18px;
  background: rgba(251, 250, 246, 0.85);
  backdrop-filter: saturate(1.2) blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  font-family: var(--display);
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -0.03em;
  color: var(--ink);
  text-decoration: none;
}
.brand .o {
  color: var(--accent);
}
.brand .dot {
  color: var(--coral);
}
.nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --- member avatars ---------------------------------------------------- */
/* No card around the group roster — the avatars sit directly above the
   calendar so they take as little vertical space as possible. */
.members-bar {
  margin-top: 14px;
}
.members-bar .members-hint {
  margin: 6px 0 0;
}
.members {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-start;
}
.avatar {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 0;
  background: none;
  padding: 0;
  cursor: default;
  font: inherit;
}
.members.interactive .avatar {
  cursor: pointer;
}
.avatar .circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: var(--display);
  font-weight: 700;
  font-size: 17px;
  line-height: 1;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.members.interactive .avatar:hover .circle {
  transform: translateY(-2px);
}
.avatar.active .circle {
  box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--accent);
}
.avatar.me .circle::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 14px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--paper);
}
/* name tooltip that fades in below on hover/focus */
.avatar .nm {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}
.avatar:hover .nm,
.avatar:focus-visible .nm,
.avatar.active .nm {
  opacity: 1;
  transform: translateY(0);
}
.avatar .badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}
.members-hint {
  color: var(--muted);
  font-size: 13px;
  margin: 10px 0 0;
}

/* --- joined name bar (after you've picked a name) ---------------------- */
.name-input-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  width: 100%;
}
.name-input-row .hint {
  margin: 0;
  flex-basis: 100%;
}
.name-bar.joined {
  align-items: center;
}
.joined-id {
  display: flex;
  align-items: center;
  gap: 12px;
}
.joined-id .circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: var(--display);
  font-weight: 700;
  font-size: 15px;
  flex: none;
}
.joined-id .who {
  margin-right: 2px;
}
.joined-id .who small {
  color: var(--muted);
  font-size: 13px;
}
.joined-id .who .nm {
  font-family: var(--display);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
  margin-left: 2px;
}

/* --- modal (members dashboard) ---------------------------------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 28px 16px;
  background: rgba(22, 32, 28, 0.42);
  overflow-y: auto;
}
.modal.open {
  display: flex;
}
.modal-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  width: 100%;
  max-width: 540px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.modal-head h2 {
  font-size: 22px;
}
.modal-close {
  border: 0;
  background: none;
  font-size: 24px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 8px;
}
.member-rows {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.member-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}
.member-row .circle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: var(--display);
  font-weight: 700;
  flex: none;
}
.member-row .info {
  flex: 1;
  min-width: 0;
}
.member-row .info .nm {
  font-weight: 600;
}
.member-row .info small {
  color: var(--muted);
}
.member-row .tag {
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
}
.btn.danger {
  border-color: var(--coral);
  color: var(--coral);
  padding: 6px 11px;
}
.btn.danger:hover {
  background: var(--coral);
  color: #fff;
}
.day.solo {
  font-weight: 600;
}
