/* Cousinorga - warm family-table aesthetic: cream paper, fir green, terracotta. */
:root {
  --paper: #f7f1e3;
  --card: #fffdf6;
  --ink: #33302a;
  --green: #3f5d45;
  --green-dark: #2e4634;
  --terracotta: #c65f3d;
  --terracotta-dark: #a84c2e;
  --muted: #7d766a;
  --line: #e3d9c3;
  --radius: 14px;
  --font-display: Georgia, "Times New Roman", serif;
  --font-body: "Trebuchet MS", Verdana, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  /* A long word (a menu, an address) wraps instead of widening the page. */
  overflow-wrap: break-word;
  background:
    radial-gradient(circle at 15% 10%, rgba(198, 95, 61, 0.06), transparent 40%),
    radial-gradient(circle at 85% 90%, rgba(63, 93, 69, 0.07), transparent 45%),
    var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  width: min(46rem, 100% - 2rem);
  margin: 0 auto 3rem;
  flex: 1;
}
/* The party page spreads its information and pictures over the whole width */
main.wide { width: calc(100% - 2rem); }

/* Header */
.site-header {
  background: var(--green);
  color: var(--paper);
  /* Installed on a phone, the header runs under the status bar: pad for it. */
  padding: calc(0.9rem + env(safe-area-inset-top)) calc(1.2rem + env(safe-area-inset-right))
    0.9rem calc(1.2rem + env(safe-area-inset-left));
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.4rem;
  align-items: center;
  justify-content: space-between;
  border-bottom: 4px double rgba(247, 241, 227, 0.5);
  margin-bottom: 1.5rem;
}
.brand {
  color: inherit;
  text-decoration: none;
  font-family: var(--font-display);
  font-size: 1.35rem;
  letter-spacing: 0.03em;
}
.brand-mark { color: #e8b04b; }
.site-header nav { display: flex; gap: 1rem; flex-wrap: wrap; }
.site-header nav a { color: var(--paper); text-decoration: underline dotted; }
.site-header nav a.nav-btn {
  background: var(--terracotta);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  padding: 0.45rem 1rem;
  border-radius: 10px;
}
.site-header nav a.nav-btn:hover { background: var(--terracotta-dark); }

/* Hero */
.hero { text-align: center; padding: 2.5rem 1rem 1.5rem; }
.hero.small { padding: 1rem 1rem 0.5rem; }
.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 6vw, 3.2rem);
  line-height: 1.1;
  margin: 0 0 0.6rem;
  color: var(--green-dark);
}
.lead { color: var(--muted); font-size: 1.1rem; margin: 0 auto 1rem; max-width: 34rem; }

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 3px 0 rgba(63, 93, 69, 0.08);
  padding: 1.3rem 1.4rem;
  margin: 1.2rem 0;
}
.card h2 {
  font-family: var(--font-display);
  font-size: 1.35rem;
  margin: 0 0 0.7rem;
  color: var(--green-dark);
}

/* Section title followed by its "?" help button */
.card-head { display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.7rem; }
.card-head h2 { margin: 0; }
.help-btn {
  flex: none;
  width: 2.4rem;
  height: 2.4rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--green-dark);
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
}
.help-btn:hover { background: var(--green); color: var(--paper); border-color: var(--green-dark); }
.help-text > :first-child { margin-top: 0; }
.help-text h1, .help-text h2, .help-text h3 {
  font-family: var(--font-display);
  color: var(--green-dark);
  font-size: 1.1rem;
  margin: 1.1rem 0 0.3rem;
}
.help-text ul, .help-text ol { padding-left: 1.2rem; }
.help-text li { margin: 0.3rem 0; }
.help-text code {
  background: rgba(63, 93, 69, 0.1);
  padding: 0.05rem 0.3rem;
  border-radius: 6px;
}

/* Forms */
input[type="text"], input[type="password"], input[type="number"],
input[type="date"], select, textarea {
  font: inherit;
  color: inherit;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 0.65rem 0.8rem;
  width: 100%;
}
/* Safari on iPhone sizes a date field on its own content and adds our padding
   on top of it, ignoring box-sizing: the field then runs off the right of the
   screen. Dropping its native appearance makes it an ordinary field again,
   respecting the width we ask for; the date picker still opens on tap. */
input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
  min-width: 0;
  /* A field stripped of its native appearance may lose its height on iOS:
     keep it at least as tall as a button, so it stays easy to tap. */
  min-height: 3rem;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 3px solid var(--terracotta);
  outline-offset: 2px;
}
label { display: block; margin: 0.5rem 0; font-weight: 600; }
.stack label { margin-bottom: 0.9rem; }
textarea { resize: vertical; }

.inline-form { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: flex-end; }
.inline-form input[type="text"] { flex: 1 1 14rem; }
.inline-form input[type="number"] { width: 6.5rem; }
.inline-form input[type="date"] { width: auto; }
.inline-form select { flex: 1 1 14rem; }
.inline-form label { margin: 0; flex: 1 1 14rem; font-size: 0.9rem; }
.inline-form label.narrow { flex: 0 0 7.5rem; }
.inline-form label input[type="number"] { width: 100%; }

.dates { display: flex; gap: 1rem; flex-wrap: wrap; }
/* min-width lets the date fields shrink: left alone they keep their own width,
   wider than a narrow phone. */
.dates label { flex: 1 1 12rem; min-width: 0; }

button {
  font: inherit;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  padding: 0.7rem 1.3rem;
  cursor: pointer;
  background: var(--line);
  color: var(--ink);
  min-height: 48px;
}
button.primary { background: var(--terracotta); color: #fff; }
button.primary:hover { background: var(--terracotta-dark); }
button.danger { background: transparent; color: var(--terracotta-dark); text-decoration: underline; min-height: 40px; }
button.small-btn { padding: 0.3rem 0.8rem; min-height: 36px; }
button.toggle { background: #efe8d6; border: 2px solid var(--line); }
button.toggle.on { background: var(--green); color: #fff; border-color: var(--green-dark); }

/* Big accessible checkboxes and radios */
input[type="checkbox"], input[type="radio"] {
  width: 1.5rem;
  height: 1.5rem;
  accent-color: var(--green);
  flex: none;
}
.check, .big-check {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  font-weight: 500;
  padding: 0.45rem 0.6rem;
  border-radius: 10px;
  cursor: pointer;
}
.check:hover, .big-check:hover { background: rgba(63, 93, 69, 0.07); }
.big-check { font-size: 1.15rem; font-weight: 700; }

fieldset {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  margin: 1rem 0;
  padding: 0.6rem 0.9rem 0.9rem;
  /* Browsers never shrink a fieldset below its content: without this the
     tarifs, chambres and repas boxes stick out of the sheet on a phone. */
  min-width: 0;
}
legend {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--green-dark);
  padding: 0 0.4rem;
}

/* min(...) keeps a column narrower than the screen: a fixed 11rem column
   overflows a small phone, or a phone with big text. */
.meal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(11rem, 100%), 1fr));
  gap: 0.8rem;
}
.meal-day strong { display: block; margin-bottom: 0.2rem; color: var(--terracotta-dark); }

/* Lists */
.family-list, .item-list { list-style: none; margin: 0; padding: 0; }
.family-list li { margin: 0.5rem 0; }
.family-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1rem;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 10px;
  color: var(--green-dark);
  font-weight: 700;
  text-decoration: none;
}
.family-link:hover { border-color: var(--green); }
.item-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--line);
}

.pill {
  background: rgba(63, 93, 69, 0.12);
  color: var(--green-dark);
  border-radius: 999px;
  padding: 0.15rem 0.7rem;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}
.pill.saved { background: var(--green); color: #fff; }
.pill.full { background: rgba(198, 95, 61, 0.15); color: var(--terracotta-dark); }
/* Shareable link with its copy button */
.share-row { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.share-link {
  flex: 1 1 18rem;
  font-family: monospace;
  font-size: 0.95rem;
  background: #fff;
}
.copy-link { flex: none; }

.code-badge {
  background: var(--green-dark);
  color: var(--paper);
  padding: 0.2rem 0.7rem;
  border-radius: 8px;
  letter-spacing: 0.15em;
  font-family: monospace;
  font-size: 1.1em;
}

.person-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.head-actions { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }

/* Guest cards: one small card per family member, details in a modal */
.person-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(13rem, 100%), 1fr));
  gap: 0.9rem;
  margin-top: 1rem;
}
.person-card {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.9rem 1rem;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
}
.person-card:hover { border-color: var(--green); }
.person-card.absent { background: #f4f1e8; color: var(--muted); }
.person-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.person-top strong {
  font-family: var(--font-display);
  font-size: 1.15rem;
  color: var(--green-dark);
}
.person-card.absent .person-top strong { color: var(--muted); }
.person-card .line { font-size: 0.88rem; color: var(--muted); }
.person-card .allergy { color: var(--terracotta-dark); }
.person-edit {
  margin-top: auto;
  padding-top: 0.5rem;
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--terracotta-dark);
  text-decoration: underline;
}
.pill.off { background: rgba(125, 118, 106, 0.15); color: var(--muted); }

/* Modal sheets */
dialog.sheet {
  width: min(36rem, calc(100% - 1.5rem));
  max-height: 88vh;
  padding: 0;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 18px 40px rgba(51, 48, 42, 0.25);
}
dialog.sheet::backdrop { background: rgba(51, 48, 42, 0.55); }
/* The title and its cross stay visible while the long forms scroll. */
.sheet-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 0.6rem 0.4rem 1.2rem;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.sheet-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  color: var(--green-dark);
}
.dialog-close {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.75rem;
  min-height: 2.75rem;
  font-size: 1.8rem;
  line-height: 1;
  text-decoration: none;
  color: var(--muted);
  border-radius: 8px;
}
.dialog-close:hover { background: rgba(63, 93, 69, 0.08); color: var(--ink); }
.sheet-body { padding: 0.6rem 1.2rem 1.2rem; }
/* Without javascript the sheet simply unfolds in the page when linked to. */
dialog.sheet:target {
  display: block;
  position: static;
  width: auto;
  margin: 1rem 0;
  box-shadow: none;
}

/* Lodging cards of the admin setup page: one small card per house */
.lodging-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(15rem, 100%), 1fr));
  gap: 0.9rem;
  margin-top: 1rem;
}
.lodging-card {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
}
.lodging-card h3 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: var(--green-dark);
  margin: 0;
}
.lodging-card .beds { margin: 0; font-size: 0.9rem; color: var(--muted); }
.lodging-card .beds strong { color: var(--green-dark); font-size: 1.15rem; }
.lodging-card .note { margin: 0; font-size: 0.85rem; color: var(--muted); }
.lodging-card .note em { display: block; }
.lodging-card.full { background: #fbf2ec; border-color: rgba(198, 95, 61, 0.35); }
.lodging-card.full .beds { color: var(--terracotta-dark); font-weight: 700; }

.bed-meter {
  height: 0.45rem;
  border-radius: 999px;
  background: rgba(63, 93, 69, 0.12);
  overflow: hidden;
}
.bed-meter span { display: block; height: 100%; background: var(--green); }
.lodging-card.full .bed-meter span { background: var(--terracotta); }

.bed-taken { margin: 0 0 0.6rem; }
.bed-taken strong { display: block; font-size: 0.9rem; }
.bed-taken em { color: var(--muted); }

.lodging-rooms { list-style: none; margin: 0; padding: 0; font-size: 0.9rem; }
.lodging-rooms li { padding: 0.35rem 0; border-top: 1px dashed var(--line); }
.lodging-rooms li:first-child { border-top: none; }
.lodging-rooms em { color: var(--muted); font-size: 0.9em; }
.lodging-rooms .empty { color: var(--muted); font-style: italic; }

.plus { font-size: 2.4rem; line-height: 1; color: var(--terracotta); }

/* The dashed "add" card of the participants grid */
.person-card.add {
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  min-height: 9rem;
  border-style: dashed;
  background: transparent;
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--green-dark);
  text-align: center;
}
.person-card.add:hover { background: rgba(63, 93, 69, 0.07); }

/* Lodging cards of the admin setup page: rooms can be removed and added */
.lodging-rooms .room-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}
.lodging-foot { margin-top: auto; padding-top: 0.3rem; }
.lodging-foot label { font-size: 0.85rem; margin: 0 0 0.3rem; }
.room-fields { display: flex; gap: 0.5rem; }
.room-fields label { flex: 1 1 auto; min-width: 0; }
.room-fields label.narrow { flex: 0 0 5rem; }
.lodging-card .primary { width: 100%; }
.lodging-card button.danger { padding-left: 0; padding-right: 0; }
.duplicate-form { border-top: 1px dashed var(--line); padding-top: 0.5rem; }
.duplicate-form label { font-size: 0.85rem; margin: 0 0 0.3rem; }
.duplicate-form button { width: 100%; }
.room-row button.danger { font-size: 1.4rem; line-height: 1; text-decoration: none; padding: 0 0.4rem; }
.lodging-card.add { border-style: dashed; background: transparent; }
.lodging-card.add h3 { display: flex; align-items: center; gap: 0.4rem; }
.lodging-card.add label { font-size: 0.85rem; margin: 0; }
.lodging-card.add .primary { margin-top: auto; }

/* Price card on the family page */
.price-table .detail { display: block; color: var(--muted); font-size: 0.85rem; }
.price-table td:nth-child(2) { white-space: nowrap; font-weight: 700; }

/* Family pin */
.pin-banner { border: 2px solid var(--terracotta); }
.pin-reminder { text-align: center; color: var(--muted); }

/* Meal menu (viande, poisson, vegetarien...) */
.menu { display: block; color: var(--muted); font-size: 0.88em; font-style: italic; }
li .menu, td .menu { display: inline; }

/* Code entry */
.code-form { max-width: 24rem; margin: 0 auto; text-align: center; }
.code-input {
  text-align: center;
  font-size: 1.4rem;
  letter-spacing: 0.2em;
  font-family: monospace;
}
.code-form button { width: 100%; margin-top: 0.8rem; }
.error { color: var(--terracotta-dark); font-weight: 700; }

/* Stats */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(9rem, 100%), 1fr));
  gap: 0.8rem;
  margin: 1rem 0;
}
.stat {
  background: var(--green);
  color: var(--paper);
  border-radius: var(--radius);
  padding: 0.9rem;
  text-align: center;
}
.stat-num { display: block; font-family: var(--font-display); font-size: 2rem; }
.export-row { text-align: center; margin: 0 0 1.5rem; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--line); }
th { font-family: var(--font-display); color: var(--green-dark); }
.total-row td { font-weight: 700; border-top: 2px solid var(--green); }
/* Grouped table: a house row followed by its indented rooms */
.group-row td {
  font-weight: 700;
  color: var(--green-dark);
  background: rgba(63, 93, 69, 0.07);
  border-top: 2px solid var(--line);
}
td.indent { padding-left: 1.8rem; }
.card { overflow-x: auto; }

/* Party page: practical information on the left, pictures on the right */
.info-columns {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 1.2rem;
  align-items: start;
  margin: 1.2rem 0;
}
.info-columns.alone { grid-template-columns: minmax(0, 1fr); }
.info-columns .card { margin: 0; }
.description > :last-child { margin-bottom: 0; }
.description h1, .description h2, .description h3 {
  font-family: var(--font-display);
  color: var(--green-dark);
}
.description h1 { font-size: 1.5rem; }
.description h3 { font-size: 1.15rem; }
.description img { max-width: 100%; border-radius: var(--radius); }
.description a { color: var(--terracotta-dark); font-weight: 700; }
.pictures { display: flex; flex-direction: column; gap: 1rem; }
.pictures a { display: block; line-height: 0; }
.pictures img {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: 0 3px 0 rgba(63, 93, 69, 0.08);
  background: #fff;
}

/* Call to action closing the party page: a link dressed as the primary button */
.cta { text-align: center; margin: 2rem 0; }
.cta p { color: var(--muted); margin: 0 0 0.8rem; }
a.button {
  display: inline-block;
  max-width: 100%;
  font-weight: 700;
  text-decoration: none;
  border-radius: 10px;
  padding: 0.9rem 2.4rem;
  font-size: 1.15rem;
  min-height: 48px;
}
a.button.primary { background: var(--terracotta); color: #fff; }
a.button.primary:hover { background: var(--terracotta-dark); }

.site-footer {
  text-align: center;
  color: var(--muted);
  padding: 1.2rem 1.2rem calc(1.2rem + env(safe-area-inset-bottom));
  font-size: 0.9rem;
}

@media (max-width: 640px) {
  .info-columns { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 480px) {
  body { font-size: 16px; }
  .card { padding: 1rem; }
  .dates label { flex-basis: 100%; }
  /* Forms laid out in a row stack, so their button is never squeezed. */
  .inline-form > *, .share-row > * { flex-basis: 100%; }
  .inline-form input[type="number"] { width: 100%; }
  .inline-form label.narrow { flex-basis: 100%; }
  /* Modals turn into a sheet rising from the bottom, easier to reach with
     one thumb, with a full-width button to save. */
  dialog.sheet {
    width: 100%;
    max-width: none;
    max-height: 92dvh;
    margin: auto 0 0;
    border: none;
    border-radius: var(--radius) var(--radius) 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  dialog.sheet:target { margin: 1rem 0; border-radius: var(--radius); }
  /* Narrower sides: the long labels (repas, chambres) get the whole screen. */
  .sheet-head { padding-left: 0.9rem; }
  .sheet-body { padding: 0.6rem 0.9rem 1.2rem; }
  .check, .big-check { padding-left: 0.2rem; padding-right: 0.2rem; }
  .sheet-body button.primary { width: 100%; }
  .sheet-body button.danger { width: 100%; }
}

/* Admin cards reached through an anchor after a change keep some air above */
.card[id], .lodging[id] { scroll-margin-top: 1rem; }

/* Building plan (templates/plan.html.j2): grey walls like the paper plan,
   fitted to the card, scrolled sideways on phones rather than shrunk unreadable */
.plan-wrap { position: relative; margin: 1rem 0; }
/* The tooltip of the bottom row goes past the card: no table here to scroll */
#logements.card { overflow: visible; }
.plan-scroll { overflow-x: auto; }
.plan-tip {
  position: absolute;
  z-index: 2;
  max-width: 18rem;
  padding: 0.5rem 0.7rem;
  background: var(--ink);
  color: #fff;
  border-radius: 8px;
  font-size: 0.85rem;
  white-space: pre-line;
  pointer-events: none;
}
.plan-tip[hidden] { display: none; }
.plan { display: block; width: 100%; min-width: 36rem; height: auto; }
.plan-box rect { fill: #fff; stroke: #8a8a8a; stroke-width: 6; }
.plan-box.full rect { fill: #fbf2ec; }
.plan-box.ours rect { fill: #e3eee3; }
.plan a:hover .plan-box rect { fill: #f1f6f1; stroke: var(--green); }
.plan-name { font-family: var(--font-display); font-size: 16px; font-weight: 700; fill: var(--green-dark); }
.plan-room { font-size: 12px; fill: var(--ink); }
.plan-free { font-size: 12px; font-style: italic; fill: var(--muted); }
.plan-box.full .plan-free { fill: var(--terracotta-dark); font-weight: 700; }
.plan-floor { font-size: 15px; font-weight: 700; fill: var(--ink); text-decoration: underline; }

/* Level of a house on the admin cards */
.floor-form { display: flex; align-items: flex-end; gap: 0.4rem; }
.floor-form label { flex: 1 1 auto; font-size: 0.85rem; margin: 0; }
