/* La Hotte
   Palette : sapin (structure), houx (accent rare), or (réservé), neige (fond).
   Élément signature : l'étiquette cadeau qui porte l'état de chaque idée. */

:root {
  --sapin: #173a2e;
  --sapin-2: #245443;
  --houx: #b3263a;
  --or: #9a6a10;
  --neige: #f2f4f1;
  --papier: #ffffff;
  --encre: #1b2420;
  --brume: #5b6962;
  --ligne: #d8dfda;
  --voile: #e7ece8;
  --ok-bg: #e4f0e8;
  --warn-bg: #fbf1dc;
  --err-bg: #f8e3e5;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --r-sm: 6px;
  --r-md: 12px;
  --tap: 44px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --sapin: #7fc4a3;
    --sapin-2: #9ad6b9;
    --houx: #ec7b8b;
    --or: #e2b457;
    --neige: #0f1814;
    --papier: #17231d;
    --encre: #e4ece7;
    --brume: #9aaaa2;
    --ligne: #2b3a33;
    --voile: #1e2c25;
    --ok-bg: #1b3327;
    --warn-bg: #362b14;
    --err-bg: #3a1e22;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 106.25%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--neige);
  color: var(--encre);
  font: 1rem/1.55 var(--sans);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
img { max-width: 100%; display: block; }
a { color: var(--sapin); text-underline-offset: .15em; }
h1, h2, h3 { font-family: var(--serif); line-height: 1.2; margin: 0 0 .5rem; font-weight: 600; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 .75rem; }
q { font-style: italic; color: var(--brume); }
q::before { content: "« "; } q::after { content: " »"; }
.display { font-size: clamp(2rem, 7vw, 2.8rem); letter-spacing: -.01em; }
.lede { color: var(--brume); font-size: 1.05rem; max-width: 60ch; }
.hint, small { color: var(--brume); font-size: .88rem; }
.optional { color: var(--brume); font-weight: 400; font-size: .88rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--houx); outline-offset: 2px; }

/* --- Structure ----------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: calc(.7rem + env(safe-area-inset-top, 0px)) 1.1rem .7rem;
  background: var(--sapin); color: #fff;
}
@media (prefers-color-scheme: dark) { .topbar { background: #10241b; } }
.brand { font-family: var(--serif); font-size: 1.35rem; font-weight: 600; color: #fff; text-decoration: none; }
.page { max-width: 760px; margin: 0 auto; padding: 1.4rem 1.1rem 3rem; }
.narrow { max-width: 520px; }
.section { margin-top: 2.2rem; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: .75rem; }
.section-head h1, .section-head h2 { margin: 0; }
.crumb { font-size: .92rem; margin-bottom: .4rem; }
.crumb a { color: var(--brume); }
.crumb a::before { content: "‹ "; }

.nav { display: flex; gap: .25rem; }
.nav a {
  display: flex; align-items: center; gap: .4rem;
  color: rgba(255, 255, 255, .78); text-decoration: none;
  padding: .45rem .7rem; border-radius: var(--r-sm); font-size: .95rem;
}
.nav a:hover { color: #fff; background: rgba(255, 255, 255, .08); }
.nav a[aria-current="page"] { color: #fff; background: rgba(255, 255, 255, .14); }
.icon { width: 1.15em; height: 1.15em; flex: none; }

/* Mobile : barre d'onglets en bas, à portée de pouce. */
@media (max-width: 719px) {
  .authed .page { padding-bottom: calc(5.5rem + env(safe-area-inset-bottom, 0px)); }
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    justify-content: space-around; gap: 0;
    padding: .3rem .3rem calc(.3rem + env(safe-area-inset-bottom, 0px));
    background: var(--papier); border-top: 1px solid var(--ligne);
  }
  .nav a {
    flex: 1; flex-direction: column; gap: .15rem; min-height: 3.2rem; justify-content: center;
    color: var(--brume); font-size: .72rem; padding: .3rem .2rem;
  }
  .nav a span { max-width: 11ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .nav a .icon { width: 1.4rem; height: 1.4rem; }
  .nav a:hover { background: none; color: var(--encre); }
  .nav a[aria-current="page"] { background: none; color: var(--sapin); font-weight: 600; }
}

/* --- Boutons et formulaires ------------------------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: var(--tap); padding: .55rem 1.05rem;
  border: 1px solid var(--ligne); border-radius: var(--r-sm);
  background: var(--papier); color: var(--encre);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { border-color: var(--brume); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-primary { background: var(--sapin); border-color: var(--sapin); color: #fff; }
@media (prefers-color-scheme: dark) { .btn-primary { color: #0f1814; } }
.btn-primary:hover { background: var(--sapin-2); border-color: var(--sapin-2); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--brume); font-weight: 500; }
.btn-ghost:hover { color: var(--encre); border-color: var(--ligne); }
.btn-danger { background: transparent; border-color: var(--houx); color: var(--houx); }
.btn-small { min-height: 38px; padding: .35rem .8rem; font-size: .92rem; }

.card { background: var(--papier); border: 1px solid var(--ligne); border-radius: var(--r-md); padding: 1.2rem; margin-bottom: 1.2rem; }
.form { display: grid; gap: 1rem; }
.form h2 { margin: 0; }
label { display: grid; gap: .3rem; font-weight: 600; font-size: .95rem; }
label small { font-weight: 400; }
input, select, textarea {
  width: 100%; min-height: var(--tap); padding: .55rem .7rem;
  border: 1px solid var(--ligne); border-radius: var(--r-sm);
  background: var(--papier); color: var(--encre); font: inherit; font-weight: 400;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--sapin); outline-offset: 0; border-color: var(--sapin); }
fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: .45rem; }
legend { font-weight: 600; font-size: .95rem; margin-bottom: .3rem; padding: 0; }
.check { display: flex; align-items: center; gap: .6rem; font-weight: 400; min-height: 38px; }
.check input { width: 1.25rem; min-height: 0; height: 1.25rem; accent-color: var(--sapin); flex: none; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
@media (max-width: 420px) { .grid-2 { grid-template-columns: 1fr; } }
.with-button { display: flex; gap: .5rem; }
.with-button input { flex: 1; min-width: 0; }
.form-actions { display: flex; flex-wrap: wrap; gap: .6rem; }

.preview { display: flex; align-items: center; gap: .8rem; }
.preview img { width: 88px; height: 88px; object-fit: contain; background: #fff; border: 1px solid var(--ligne); border-radius: var(--r-sm); }

/* --- Messages ------------------------------------------------------------- */
.flash { padding: .75rem 1rem; border-radius: var(--r-sm); margin-bottom: 1rem; background: var(--voile); }
.flash-success { background: var(--ok-bg); }
.flash-warning { background: var(--warn-bg); }
.flash-error { background: var(--err-bg); }
.notice { display: block; padding: .9rem 1rem; border: 1px solid var(--ligne); border-radius: var(--r-md); background: var(--papier); margin-bottom: 1rem; color: var(--encre); text-decoration: none; }
.notice p:last-child { margin: 0; }
.notice-alert { border-color: var(--or); background: var(--warn-bg); }
.notice.compact { padding: .6rem .8rem; margin: .6rem 0; }
.notice.compact form { margin-top: .4rem; }
a.notice-alert { font-weight: 600; }

/* Bandeau « secret » : rappelle qui voit quoi. */
.secret {
  border-left: 3px solid var(--houx);
  padding: .15rem 0 .15rem .9rem; margin: 1rem 0 1.2rem;
  color: var(--brume); font-size: .95rem;
}
.secret p { margin: 0; }

.empty { text-align: center; padding: 3rem 0; }
.empty-line { color: var(--brume); padding: .5rem 0; }

/* --- Listes (tableau de bord) --------------------------------------------- */
.list-cards { list-style: none; margin: 0; padding: 0; display: grid; gap: .8rem; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.list-card {
  display: grid; gap: .2rem; height: 100%;
  padding: 1.05rem 1.1rem 1rem;
  background: var(--papier); border: 1px solid var(--ligne); border-radius: var(--r-md);
  color: var(--encre); text-decoration: none;
}
.list-card:hover { border-color: var(--sapin); }
.list-card .owner { font-family: var(--serif); font-size: 1.45rem; font-weight: 600; line-height: 1.15; }
.list-card .list-title { font-weight: 600; }
.list-card .when, .when { color: var(--brume); font-size: .92rem; }
.list-card em { font-style: normal; color: var(--houx); }
.list-card .count { font-size: .88rem; color: var(--brume); }
progress {
  -webkit-appearance: none; appearance: none; width: 100%; height: 6px; margin: .55rem 0 .15rem;
  border: 0; border-radius: 3px; background: var(--voile); overflow: hidden;
}
progress::-webkit-progress-bar { background: var(--voile); }
progress::-webkit-progress-value { background: var(--or); }
progress::-moz-progress-bar { background: var(--or); }

.rows { list-style: none; margin: 0 0 1rem; padding: 0; border-top: 1px solid var(--ligne); }
.rows > li { border-bottom: 1px solid var(--ligne); }
.row { display: grid; gap: .1rem; padding: .8rem .2rem; color: var(--encre); text-decoration: none; }
a.row:hover .row-main { color: var(--sapin); text-decoration: underline; }
.row-main { font-weight: 600; }
.row-sub { color: var(--brume); font-size: .9rem; }
.row-muted { opacity: .6; }
.row-alert { background: var(--warn-bg); padding-left: .7rem; padding-right: .7rem; }
.row-actions { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .3rem; }
.row form { margin-top: .3rem; }
.copy-line { display: flex; gap: .4rem; margin-top: .35rem; }
.copy-line input { flex: 1; min-width: 0; font-size: .85rem; min-height: 38px; }
.archives summary { cursor: pointer; font-family: var(--serif); font-size: 1.15rem; font-weight: 600; padding: .5rem 0; }

/* --- Page d'une liste ------------------------------------------------------ */
.list-head { margin-bottom: .5rem; }
.list-head .owner { font-family: var(--serif); font-size: 1.15rem; color: var(--houx); margin: 0; }
.list-head .display { margin-bottom: .2rem; }
.list-desc { white-space: pre-line; margin-top: .8rem; max-width: 62ch; }
.shared { font-size: .92rem; color: var(--brume); }
.actions-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; margin-bottom: 1.2rem; }
.toggle { margin-left: auto; }
@media (max-width: 520px) { .toggle { margin-left: 0; } }

.gifts { list-style: none; margin: 0; padding: 0; display: grid; gap: .8rem; }
.gift {
  display: grid; grid-template-columns: 84px 1fr; gap: 1rem;
  padding: 1rem; background: var(--papier);
  border: 1px solid var(--ligne); border-radius: var(--r-md);
  scroll-margin-top: 5rem;
}
.gift:target { border-color: var(--sapin); box-shadow: 0 0 0 2px var(--sapin); }
.gifts.compact .gift { grid-template-columns: 60px 1fr; }
.thumb {
  position: relative; width: 100%; aspect-ratio: 1; border-radius: var(--r-sm);
  background: var(--voile); overflow: hidden; display: grid; place-items: center;
}
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #fff; }
.thumb-fallback { color: var(--brume); opacity: .55; }
.thumb-fallback .icon { width: 2rem; height: 2rem; }
.gift-body { min-width: 0; }
.gift-title { margin-bottom: .2rem; overflow-wrap: anywhere; }
.gift-title a { color: inherit; }
.priority { font-size: .85rem; color: var(--brume); margin-bottom: .3rem; }
.priority.p1 { color: var(--houx); font-weight: 600; }
.surprise-note { font-size: .85rem; color: var(--houx); font-weight: 600; margin-bottom: .3rem; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem 1rem; margin-bottom: .4rem; font-size: .95rem; }
.price { font-weight: 600; }
.shop { display: inline-flex; align-items: center; gap: .25rem; min-height: 32px; overflow-wrap: anywhere; }
.shop .icon { width: .95em; height: .95em; }
.desc { white-space: pre-line; font-size: .95rem; margin-bottom: .5rem; }
.claim { background: var(--voile); border-radius: var(--r-sm); padding: .55rem .75rem; margin: .5rem 0; font-size: .95rem; }
.claim p { margin: 0; }
.participants { margin: .3rem 0 0; padding-left: 1.1rem; }
.gift-actions { display: flex; flex-wrap: wrap; align-items: flex-start; gap: .45rem; margin-top: .6rem; }
.gift-actions form { margin: 0; }
.inline-form { flex-basis: 100%; }
.inline-form > summary { list-style: none; }
.inline-form > summary::-webkit-details-marker { display: none; }
.inline-form[open] > summary { margin-bottom: .6rem; }
.inline-form .form { gap: .7rem; padding: .9rem; border: 1px dashed var(--ligne); border-radius: var(--r-sm); }
@media (min-width: 560px) { .inline-form:not([open]) { flex-basis: auto; } }

/* L'étiquette cadeau : trou de ficelle + encoche, couleur selon l'état. */
.tag {
  --tag: var(--sapin);
  float: right; position: relative;
  margin: 0 -.2rem .5rem .8rem;
  padding: .2rem .75rem .2rem 1.3rem;
  font-size: .8rem; font-weight: 700; line-height: 1.5; white-space: nowrap;
  color: #fff; background: var(--tag);
  clip-path: polygon(.65rem 0, 100% 0, 100% 100%, .65rem 100%, 0 50%);
  border-radius: 0 3px 3px 0;
}
.tag::before {
  content: ""; position: absolute; left: .6rem; top: 50%;
  width: .32rem; height: .32rem; border-radius: 50%;
  background: var(--papier); transform: translateY(-50%);
}
@media (prefers-color-scheme: dark) { .tag { color: #0f1814; } }
.status-reserve .tag, .status-commun .tag { --tag: var(--or); }
.status-achete .tag { --tag: var(--brume); }
.status-achete .thumb { opacity: .55; }
.status-achete .gift-title { color: var(--brume); }
.is-surprise { border-style: dashed; border-color: var(--houx); }
.hide-taken .gift:not([data-status="libre"]) { display: none; }

.danger-zone { margin-top: 2.5rem; border-top: 1px solid var(--ligne); padding-top: 1rem; }
.danger-zone summary { cursor: pointer; color: var(--brume); padding: .4rem 0; }
.danger-zone form { display: grid; gap: .4rem; justify-items: start; margin-top: 1rem; }

@media (prefers-reduced-motion: no-preference) {
  .gift:target { transition: box-shadow .4s; }
}
