@import url("https://fonts.googleapis.com/css2?family=Grandstander:wght@500;700;900&family=Figtree:wght@400;500;700&display=swap");

:root {
  --night: #0d2b3e;
  --night-2: #1b4a5a;
  --pine: #134535;
  --pine-dark: #0c2e23;
  --snow: #f4f8f7;
  --cranberry: #c8283c;
  --cranberry-dark: #9d1c2d;
  --gold: #f0b84b;
  --ink: #1d2a30;
  --muted: #6b7a80;
  --line: #dfe7e6;
  --radius-lg: 22px;
  --radius-sm: 10px;
  --display: "Grandstander", "Trebuchet MS", sans-serif;
  --body: "Figtree", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { background: var(--night); }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--snow);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; border-radius: 6px; }

/* ============ Scène de nuit ============ */
.hero {
  position: relative;
  height: clamp(360px, 52vw, 560px);
  overflow: hidden;
  background: linear-gradient(180deg, var(--night) 0%, var(--night-2) 75%);
  color: var(--snow);
}
.scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.star { animation: twinkle 3.5s ease-in-out infinite; }
@keyframes twinkle { 50% { opacity: .25; } }

.window-glow { animation: glow 4s ease-in-out infinite; }
@keyframes glow { 50% { opacity: .65; } }

.mob { display: none; }
@media (max-width: 700px) { .mob { display: inline; } }

.snowfall { position: absolute; inset: 0; pointer-events: none; }
.snowfall i {
  position: absolute; top: -12px;
  border-radius: 50%; background: #fff;
  animation: drift linear infinite;
}
@keyframes drift {
  to { transform: translate3d(var(--dx, 20px), calc(clamp(360px, 52vw, 560px) + 20px), 0); }
}

.hero-text {
  position: relative; z-index: 2;
  max-width: 900px; margin: 0 auto;
  padding: clamp(36px, 7vw, 80px) 20px 0;
  text-align: center;
}
.hero h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(3.6rem, 11vw, 7.2rem);
  line-height: .92;
  letter-spacing: -.01em;
  color: var(--snow);
  transform: rotate(-3deg);
  text-shadow:
    3px 3px 0 var(--cranberry),
    6px 6px 0 var(--cranberry-dark),
    0 18px 40px rgba(0, 0, 0, .35);
}
.hero h1 small {
  display: block;
  font-size: .38em;
  font-weight: 700;
  color: var(--gold);
  text-shadow: 2px 2px 0 var(--pine-dark);
  margin-bottom: .1em;
}
.hero .year {
  margin: 22px 0 0;
  font-family: var(--display);
  font-weight: 500;
  font-size: 1.1rem;
  color: rgba(244, 248, 247, .8);
}

/* ============ Lettre (enveloppe par avion) ============ */
main {
  position: relative; z-index: 3;
  max-width: 820px;
  margin: clamp(-120px, -10vw, -60px) auto 0;
  padding: 0 16px 56px;
}
.letter {
  padding: 10px;
  border-radius: var(--radius-lg);
  background: repeating-linear-gradient(
    -45deg,
    var(--cranberry) 0 16px, #fff 16px 26px,
    var(--pine) 26px 42px, #fff 42px 52px);
  box-shadow: 0 30px 60px -20px rgba(13, 43, 62, .45);
}
.letter-inner {
  background: #fff;
  border-radius: 14px;
  padding: clamp(22px, 4vw, 40px);
}

.intro { max-width: 60ch; margin: 0 0 22px; }
.intro h2 {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1.5rem, 4vw, 1.9rem);
  line-height: 1.15;
  margin: 0 0 6px;
  color: var(--pine);
}
.intro p { margin: 0; color: var(--muted); }

.progress { display: flex; align-items: center; gap: 12px; margin: 0 0 18px; font-size: .92rem; color: var(--muted); }
.progress .bar { flex: 1; height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress .bar span { display: block; height: 100%; width: 0; background: var(--gold); border-radius: 99px; transition: width .6s ease; }

/* ============ En-tête de tri ============ */
.sort-head {
  display: flex; align-items: center; gap: 16px;
  padding: 0 4px 8px;
  border-bottom: 2px solid var(--line);
  font-size: .85rem; color: var(--muted);
}
.sort-head .col-item { flex: 1; padding-left: 68px; }
.col-sort {
  flex: none;
  display: inline-flex; align-items: center; justify-content: flex-end; gap: 4px;
  font: 600 .85rem var(--body); color: var(--muted);
  background: none; border: none; border-radius: 99px;
  padding: 6px 10px; cursor: pointer;
}
.col-sort:hover { background: var(--snow); color: var(--ink); }
.col-sort.active { background: var(--pine); color: #fff; }
.col-sort i { font-style: normal; font-size: .75rem; }
.col-price { min-width: 80px; }
.col-status { width: 132px; }

/* ============ Ligne cadeau ============ */
.gifts { list-style: none; margin: 0; padding: 0; }
.gift {
  display: flex; align-items: center; gap: 16px;
  min-height: 76px;
  padding: 12px 4px;
  border-top: 2px dotted var(--line);
  position: relative;
}
.gift:first-child { border-top: none; }

.thumb {
  width: 52px; height: 52px; flex: none;
  border-radius: var(--radius-sm);
  object-fit: contain; background: #fff;
  border: 1px solid var(--line);
}
.present { width: 52px; height: 52px; flex: none; display: grid; place-items: center; }
.present svg { width: 40px; height: 40px; }

.gift-main { flex: 1; min-width: 0; }
.price-inline { display: none; }
.gift-title {
  min-width: 0;
  font-weight: 700; font-size: 1.02rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.gift-title a { text-decoration: none; }
.gift-title a:hover { color: var(--cranberry); text-decoration: underline; text-underline-offset: 3px; }
.gift-title .ext { font-weight: 500; font-size: .82rem; color: var(--muted); margin-left: 6px; }

.price {
  flex: none;
  font-family: var(--display); font-weight: 700; font-size: 1.1rem;
  color: var(--pine);
  min-width: 80px; text-align: right;
  font-variant-numeric: tabular-nums;
}

.slot { flex: none; width: 132px; display: flex; justify-content: flex-end; }

.reserve-btn {
  font: 700 .95rem var(--body);
  color: #fff; background: var(--pine);
  border: none; border-radius: 99px;
  padding: 10px 18px;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--pine-dark);
  transition: transform .12s, box-shadow .12s, background .2s;
}
.reserve-btn:hover { background: #1a5a46; }
.reserve-btn:active { transform: translateY(3px); box-shadow: 0 0 0 var(--pine-dark); }

/* Tampon "Offert" */
.stamp {
  font-family: var(--display); font-weight: 900; font-size: 1.05rem;
  color: var(--cranberry);
  border: 3px solid var(--cranberry);
  border-radius: 8px;
  padding: 3px 12px;
  transform: rotate(-9deg);
  opacity: .85;
  box-shadow: inset 0 0 0 2px #fff, inset 0 0 0 4px var(--cranberry);
  user-select: none;
}
.stamp.just { animation: stamp .45s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes stamp {
  from { transform: rotate(-30deg) scale(2.4); opacity: 0; }
  to { transform: rotate(-9deg) scale(1); opacity: .85; }
}
.gift.taken .gift-title,
.gift.taken .price { color: var(--muted); }
.gift.taken .thumb, .gift.taken .present { opacity: .5; filter: grayscale(.6); }

.empty { text-align: center; padding: 36px 8px; color: var(--muted); }
.empty strong { display: block; font-family: var(--display); font-size: 1.3rem; color: var(--pine); margin-bottom: 4px; }

footer { text-align: center; padding: 0 16px 40px; font-size: .9rem; color: var(--muted); }
footer a { color: var(--muted); }

@media (max-width: 600px) {
  body { font-size: 16px; }
  .gift { gap: 10px; min-height: 64px; }
  .thumb, .present { width: 40px; height: 40px; }
  .present svg { width: 32px; height: 32px; }
  .gift-title {
    font-size: .95rem; line-height: 1.3; white-space: normal;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  }
  .gift-title .ext { display: none; }
  .gift > .price { display: none; }
  .price-inline { display: block; font-family: var(--display); font-weight: 700; color: var(--pine); font-size: .95rem; margin-top: 2px; }
  .gift.taken .price-inline { color: var(--muted); }
  .slot { width: auto; }
  .sort-head { gap: 6px; justify-content: flex-end; }
  .sort-head .col-item { display: none; }
  .col-price, .col-status { min-width: 0; width: auto; }
  .reserve-btn { padding: 8px 12px; font-size: .85rem; }
  .stamp { font-size: .9rem; padding: 2px 8px; }
}
@media (max-width: 420px) {
  .letter-inner { padding: 20px 14px; }
  .gift { gap: 8px; }
  .thumb, .present { width: 44px; height: 44px; }
  .reserve-btn { padding: 8px 10px; font-size: .8rem; }
}

/* ============ Étiquette cadeau (modale) ============ */
.modal-bg {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(13, 43, 62, .72);
  backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center;
  padding: 16px;
}
.modal-bg.open { display: flex; }
.tag {
  position: relative;
  width: 100%; max-width: 420px;
  background: #fff;
  border-radius: 18px;
  padding: 44px 28px 26px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .4);
  animation: swing .5s cubic-bezier(.3, 1.4, .5, 1) both;
  transform-origin: 50% -40px;
}
@keyframes swing {
  from { transform: rotate(-6deg) translateY(-30px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
/* oeillet + ficelle */
.tag::before {
  content: ""; position: absolute; top: 14px; left: 50%;
  width: 16px; height: 16px; margin-left: -8px;
  border-radius: 50%; background: var(--night);
  box-shadow: 0 0 0 4px var(--gold);
}
.tag::after {
  content: ""; position: absolute; bottom: 100%; left: 50%;
  width: 2px; height: 60px; margin-left: -1px;
  background: var(--gold);
}
.tag h2 {
  font-family: var(--display); font-weight: 900;
  font-size: 1.7rem; line-height: 1.1;
  margin: 0 0 4px; color: var(--cranberry);
  text-align: center;
}
.tag .sub { margin: 0 0 18px; text-align: center; color: var(--muted); font-size: .95rem; }

label { display: block; font-weight: 700; font-size: .9rem; margin: 14px 0 6px; }
input {
  width: 100%; padding: 12px 14px;
  font: inherit; font-size: 16px; color: var(--ink);
  background: var(--snow);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
}
input:focus { outline: none; border-color: var(--pine); background: #fff; }
.help { font-size: .82rem; color: var(--muted); margin: 6px 0 0; }

.actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }
.btn {
  font: 700 .95rem var(--body);
  border: none; border-radius: 99px;
  padding: 11px 20px; cursor: pointer;
}
.btn.primary { background: var(--cranberry); color: #fff; box-shadow: 0 3px 0 var(--cranberry-dark); }
.btn.primary:hover { background: #b22134; }
.btn.primary:disabled { opacity: .6; cursor: wait; }
.btn.quiet { background: transparent; color: var(--muted); }
.btn.quiet:hover { color: var(--ink); }
.btn.pine { background: var(--pine); color: #fff; box-shadow: 0 3px 0 var(--pine-dark); }
.btn.small { padding: 7px 12px; font-size: .85rem; }

.msg { margin-top: 12px; font-weight: 600; font-size: .95rem; }
.msg:empty { display: none; }
.msg.err { color: var(--cranberry); }
.msg.ok { color: var(--pine); }

.done { text-align: center; }
.done p { margin: 0 0 6px; }

/* ============ Admin ============ */
.quick-add { margin-top: 24px; padding: 14px 16px; background: var(--snow); border-radius: var(--radius-sm); }
.quick-add summary { cursor: pointer; font-weight: 700; color: var(--pine); }
.quick-add ol { margin: 12px 0 8px; padding-left: 22px; }
.quick-add li { margin-bottom: 10px; }
.bookmarklet {
  display: inline-block; margin: 6px 0 0 4px;
  background: var(--cranberry); color: #fff; text-decoration: none;
  font-weight: 700; padding: 8px 16px; border-radius: 99px;
  box-shadow: 0 3px 0 var(--cranberry-dark); cursor: grab;
}
.tag.wide { max-width: 640px; }
textarea { width: 100%; padding: 12px 14px; font: inherit; font-size: 14px; color: var(--ink); background: var(--snow); border: 2px solid transparent; border-radius: var(--radius-sm); resize: vertical; }
textarea:focus { outline: none; border-color: var(--pine); background: #fff; }
input[type="file"] { background: none; padding: 6px 0; }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--pine); flex: none; margin: 0; }
.check-all { display: flex; align-items: center; gap: 10px; font-weight: 600; margin: 0 0 6px; }
.import-list { list-style: none; margin: 0; padding: 0; max-height: 46vh; overflow-y: auto; border-top: 2px dotted var(--line); }
.import-list li { border-bottom: 2px dotted var(--line); }
.import-list label { display: flex; align-items: center; gap: 12px; margin: 0; padding: 8px 2px; font-weight: 500; cursor: pointer; }
.import-list img, .import-list .noimg { width: 40px; height: 40px; flex: none; object-fit: contain; border-radius: 6px; display: grid; place-items: center; font-size: 1.3rem; }
.import-list .t { flex: 1; min-width: 0; font-size: .9rem; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.import-list .t small { display: block; color: var(--muted); font-size: .78rem; }
.import-list .p { flex: none; font-weight: 700; color: var(--pine); font-size: .9rem; }
.enrich-bar { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 30; background: var(--night); color: #fff; padding: 10px 18px; border-radius: 99px; font-weight: 600; font-size: .9rem; box-shadow: 0 10px 30px rgba(0,0,0,.3); }
.preview { margin-top: 10px; display: flex; justify-content: center; background: var(--snow); border-radius: var(--radius-sm); padding: 10px; }
.preview img { max-height: 120px; max-width: 100%; object-fit: contain; border-radius: 6px; }
.more { margin-top: 14px; }
.more summary { cursor: pointer; font-weight: 700; font-size: .9rem; color: var(--pine); }
.tag { max-height: calc(100vh - 32px); overflow-y: auto; }
.hero.slim { height: 340px; }
.hero.slim .hero-text { padding-top: 48px; }
.hero.slim ~ main { margin-top: -50px; }
.hero.slim h1 { font-size: clamp(2.4rem, 8vw, 4.4rem); }
.hero.slim .year a { color: var(--gold); }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.admin-head h2 { font-family: var(--display); font-weight: 700; font-size: 1.6rem; margin: 0; color: var(--pine); }
.who { display: block; font-size: .82rem; font-weight: 500; color: var(--cranberry); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-actions { flex: none; display: flex; gap: 2px; }
.icon-btn {
  width: 38px; height: 38px; border: none; border-radius: 50%;
  background: transparent; cursor: pointer; font-size: 1.05rem;
}
.icon-btn:hover { background: var(--snow); }
.login { max-width: 380px; margin: 0 auto; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .snowfall { display: none; }
}
