@font-face {
  font-family: "IM Fell English";
  src: url("/static/fonts/imfell-regular.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "IM Fell English";
  src: url("/static/fonts/imfell-italic.woff2") format("woff2");
  font-weight: 400; font-style: italic; font-display: swap;
}
@font-face {
  font-family: "Caveat";
  src: url("/static/fonts/caveat-700.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "IM Fell English", Georgia, "Times New Roman", serif;
  color: #2e2013;
  min-height: 100vh;
}

/* ---------- backgrounds ---------- */
.bgimg {
  position: fixed; inset: 0; z-index: 0;
  background-size: cover; background-position: center;
}
.bg-login .bgimg { background-image: url("/static/north-pole.jpg"); }
.bg-cabin .bgimg { background-image: url("/static/cabin.jpg"); }
.bg-tree  .bgimg { background-image: url("/static/tree.jpg"); }
.bg-login .bgimg::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(ellipse at center, rgba(5,8,20,.05) 40%, rgba(5,8,20,.45) 100%);
}
.bg-cabin .bgimg::after, .bg-tree .bgimg::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(rgba(20,10,4,.38), rgba(20,10,4,.55));
}
.fireglow { display: none; }
.bg-cabin .fireglow {
  display: block; position: fixed; z-index: 1; pointer-events: none;
  left: 50%; bottom: -12vh; transform: translateX(-50%);
  width: 90vw; height: 55vh;
  background: radial-gradient(ellipse at bottom, rgba(255,150,50,.34), rgba(255,90,10,.13) 45%, transparent 72%);
  animation: flicker 3.2s ease-in-out infinite;
}
@keyframes flicker {
  0%, 100% { opacity: .75; transform: translateX(-50%) scale(1); }
  30% { opacity: 1; transform: translateX(-50%) scale(1.03); }
  55% { opacity: .82; transform: translateX(-50%) scale(.99); }
  80% { opacity: .95; transform: translateX(-50%) scale(1.02); }
}
#snow { position: fixed; inset: 0; z-index: 60; pointer-events: none; }

/* ---------- login ---------- */
.login-wrap {
  position: relative; z-index: 2; min-height: 100vh;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-card {
  background: linear-gradient(160deg, #f7ecd2, #efdfba 60%, #e9d5a8);
  border: 3px solid #8a6d2f; border-radius: 10px;
  box-shadow: 0 24px 60px rgba(0,0,0,.6), inset 0 0 40px rgba(138,109,47,.18);
  padding: 34px 36px 26px; width: 100%; max-width: 400px; text-align: center;
}
.login-crest { font-size: 44px; line-height: 1; }
.login-card h1 { margin: 6px 0 2px; font-size: 40px; font-weight: 400; color: #6d1420; letter-spacing: .5px; }
.login-sub { margin: 0 0 18px; font-style: italic; color: #6b543a; }
.login-form { text-align: left; display: grid; gap: 12px; }
.login-form label, .stack label { display: grid; gap: 5px; font-size: 16px; }
input[type="text"], input[type="password"], input[type="date"] {
  font: inherit; padding: 10px 12px; border: 1px solid #a68a4f; border-radius: 6px;
  background: #fffaf0; color: #2e2013; width: 100%;
}
button {
  font: inherit; cursor: pointer; border-radius: 6px;
  border: 2px solid #8a6d2f; background: linear-gradient(#7d1f2a, #5f1420);
  color: #f7ecd2; padding: 11px 18px; font-size: 17px;
  box-shadow: 0 3px 8px rgba(0,0,0,.3);
}
button:hover { filter: brightness(1.12); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.danger { background: linear-gradient(#8c2f1d, #6b2013); }
.login-form button { margin-top: 4px; font-size: 19px; }
.login-foot { margin: 16px 0 0; font-size: 13px; color: #8a7350; font-style: italic; }
.error {
  background: #f8d7d0; border: 1px solid #b0503c; color: #6d1f10;
  border-radius: 6px; padding: 9px 12px; font-size: 15px;
}

/* ---------- logged-in chrome ---------- */
.topbar {
  position: relative; z-index: 3;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; padding: 12px 20px;
  background: rgba(24, 12, 5, .72); border-bottom: 2px solid rgba(212, 160, 23, .55);
  backdrop-filter: blur(3px);
}
.topbar .brand { color: #f3d98b; text-decoration: none; font-size: 23px; }
.topbar nav { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.topbar nav a { color: #f7ecd2; text-decoration: none; font-size: 17px; }
.topbar nav a:hover { color: #f3d98b; text-decoration: underline; }
.topbar .who { color: #d8c49a; font-style: italic; }
.logout { display: inline; }
.logout button { padding: 6px 12px; font-size: 15px; }

.wrap { position: relative; z-index: 2; max-width: 980px; margin: 0 auto; padding: 26px 18px 60px; }
.page-title { color: #f7ecd2; text-shadow: 0 2px 10px rgba(0,0,0,.8); font-weight: 400; font-size: 36px; margin: 6px 0 18px; }
.page-title.light { text-align: center; }
.event-sub { text-align: center; color: #f3d98b; font-style: italic; font-size: 19px; margin: -10px 0 8px; text-shadow: 0 2px 8px rgba(0,0,0,.85); }
.flash {
  background: #fdf3d0; border: 1px solid #a68a4f; color: #5a4517;
  border-radius: 8px; padding: 11px 14px; margin-bottom: 18px; font-size: 16px;
  box-shadow: 0 6px 18px rgba(0,0,0,.35);
}

.parchment {
  background: linear-gradient(165deg, #f7ecd2, #efe0ba 65%, #ead6a9);
  border: 2px solid #8a6d2f; border-radius: 10px;
  box-shadow: 0 14px 34px rgba(0,0,0,.5), inset 0 0 34px rgba(138,109,47,.15);
  padding: 20px 22px; margin-bottom: 20px;
}
.parchment h2 { margin: 0 0 12px; font-weight: 400; color: #6d1420; font-size: 24px; }
.parchment.center { text-align: center; max-width: 560px; margin: 26px auto; }
.cozy { font-size: 21px; font-style: italic; }
.muted { color: #7a6547; font-size: 14px; }

/* ---------- event cards ---------- */
.event-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.event-card {
  display: block; text-decoration: none; color: #2e2013;
  background: linear-gradient(160deg, #f7ecd2, #eddeb6);
  border: 2px solid #8a6d2f; border-radius: 10px; padding: 18px 20px;
  box-shadow: 0 10px 24px rgba(0,0,0,.45);
  transition: transform .15s ease, box-shadow .15s ease;
}
.event-card:hover { transform: translateY(-3px); box-shadow: 0 16px 30px rgba(0,0,0,.55); }
.event-title { font-size: 23px; color: #6d1420; margin-bottom: 4px; }
.event-date { font-style: italic; color: #6b543a; margin-bottom: 8px; }
.event-state { font-size: 15px; color: #445c2a; }
.empty {
  background: rgba(24,12,5,.55); border: 1px dashed rgba(243,217,139,.6);
  color: #f7ecd2; border-radius: 10px; padding: 28px; text-align: center; font-size: 18px;
}

/* ---------- forms & tables ---------- */
.stack { display: grid; gap: 12px; max-width: 520px; }
.stack .check, .check { display: flex; align-items: center; gap: 9px; font-size: 17px; }
.check input { width: 19px; height: 19px; accent-color: #7d1f2a; }
.table-scroll { overflow-x: auto; }
.admin-table { border-collapse: collapse; width: 100%; min-width: 520px; }
.admin-table th, .admin-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid #cbb27a; vertical-align: top; }
.admin-table th { color: #6d1420; font-weight: 400; font-size: 17px; }
.admin-table td.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.admin-table td.actions button { padding: 6px 11px; font-size: 14px; }
.admin-table td.actions input { max-width: 150px; padding: 7px 9px; }
form.inline { display: inline-flex; gap: 6px; align-items: center; margin: 0 6px 6px 0; }
.badge {
  background: #445c2a; color: #f7ecd2; border-radius: 20px;
  font-size: 12px; padding: 2px 9px; margin-left: 6px; vertical-align: middle;
}

/* ---------- the present ---------- */
.present-scene { text-align: center; padding-top: 6px; }
.present {
  position: relative; width: min(280px, 68vw); height: 350px;
  margin: 12px auto 4px;
  filter: drop-shadow(0 22px 22px rgba(0,0,0,.55));
}
.present-box {
  position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 84%; height: 185px; z-index: 2;
  background: linear-gradient(155deg, #b3242f, #8c1620 55%, #6d1019);
  border-radius: 9px;
  box-shadow: inset 0 0 0 2px rgba(246, 212, 124, .25), inset 0 -18px 30px rgba(0,0,0,.35);
}
.ribbon-v {
  position: absolute; top: 0; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 36px; background: linear-gradient(90deg, #b98a14, #f6d47c 50%, #b98a14);
}
.ribbon-h {
  position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%);
  height: 36px; background: linear-gradient(#b98a14, #f6d47c 50%, #b98a14);
}
.present-lid {
  position: absolute; bottom: 182px; left: 50%; transform: translateX(-50%);
  width: 97%; height: 48px; z-index: 3;
  background: linear-gradient(160deg, #c22a38, #931a26 60%, #771320);
  border-radius: 9px;
  box-shadow: inset 0 0 0 2px rgba(246,212,124,.3), 0 6px 14px rgba(0,0,0,.35);
  transition: transform 1s cubic-bezier(.2,.7,.3,1), opacity 1s ease;
}
.present-lid::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 50%;
  transform: translateX(-50%); width: 36px;
  background: linear-gradient(90deg, #b98a14, #f6d47c 50%, #b98a14);
}
.present-lid .bow {
  position: absolute; left: 50%; top: -40px; transform: translateX(-50%);
  width: 118px; height: 59px;
}
.paper-card {
  position: absolute; bottom: 128px; left: 50%; z-index: 1;
  width: 78%; padding: 18px 14px 20px; text-align: center;
  background: linear-gradient(170deg, #fffaf0, #f7ecd2);
  border: 1px solid #d8c49a; border-radius: 4px;
  box-shadow: 0 10px 24px rgba(0,0,0,.4);
  opacity: 0; transform: translate(-50%, 46px) rotate(-2deg);
  transition: transform 1.1s cubic-bezier(.2,.7,.3,1) .3s, opacity .8s ease .3s;
}
.paper-label { font-style: italic; color: #6b543a; font-size: 15px; margin-bottom: 2px; }
.paper-name {
  font-family: "Caveat", cursive; font-weight: 700;
  font-size: clamp(30px, 9vw, 42px); color: #43302b; line-height: 1.15;
  overflow-wrap: break-word;
}
.present.open .present-lid, .present-lid.off {
  transform: translate(-88%, -118px) rotate(-22deg); opacity: .96;
}
.present.open .paper-card, .paper-card.risen {
  opacity: 1; z-index: 4; transform: translate(-50%, -104px) rotate(-2deg);
}
.sparkle {
  position: absolute; width: 9px; height: 9px; border-radius: 50%;
  background: radial-gradient(circle, #fff6c9 0%, #f6d47c 55%, transparent 75%);
  animation: twinkle 2.6s ease-in-out infinite; z-index: 4;
}
.sparkle.s1 { top: 52px; left: 6%; }
.sparkle.s2 { top: 22px; right: 9%; animation-delay: .8s; }
.sparkle.s3 { top: 128px; right: 2%; animation-delay: 1.5s; }
@keyframes twinkle {
  0%, 100% { opacity: .15; transform: scale(.7); }
  50% { opacity: 1; transform: scale(1.25); }
}
.unwrap-btn {
  margin-top: 20px; font-size: clamp(19px, 5vw, 24px);
  padding: 14px 26px; border-radius: 10px;
  background: linear-gradient(#7d1f2a, #5f1420);
  border: 2px solid #f6d47c; color: #fdf3d0;
  box-shadow: 0 10px 24px rgba(0,0,0,.55);
  animation: glowpulse 2.8s ease-in-out infinite;
}
@keyframes glowpulse {
  0%, 100% { box-shadow: 0 10px 24px rgba(0,0,0,.55), 0 0 0 rgba(246,212,124,0); }
  50% { box-shadow: 0 10px 24px rgba(0,0,0,.55), 0 0 26px rgba(246,212,124,.55); }
}
.unwrapped-note {
  color: #fdf3d0; font-style: italic; font-size: 18px; margin-top: 18px;
  text-shadow: 0 2px 8px rgba(0,0,0,.9);
}
.unwrap-error { color: #ffb4a2; font-size: 16px; text-shadow: 0 1px 6px rgba(0,0,0,.9); }

/* ---------- small screens ---------- */
@media (max-width: 640px) {
  .login-card { padding: 26px 22px 20px; }
  .login-card h1 { font-size: 33px; }
  .page-title { font-size: 29px; }
  .topbar { padding: 10px 14px; }
  .topbar .brand { font-size: 20px; }
  .topbar nav { gap: 11px; }
  .wrap { padding: 20px 13px 48px; }
  .parchment { padding: 16px; }
  .present { height: 322px; }
  .present-box { height: 168px; }
  .present-lid { bottom: 165px; }
  .paper-card { bottom: 112px; }
}
@media (prefers-reduced-motion: reduce) {
  .fireglow, .sparkle, .unwrap-btn { animation: none; }
  .present-lid, .paper-card { transition: none; }
}
