/*
 * Plain CSS without custom properties or grid, so it also works on old
 * phones (Android 4.4+, iOS 9+). Vendor prefixes are kept on purpose.
 */

[hidden] { display: none !important; }

* { -webkit-box-sizing: border-box; box-sizing: border-box; }

html, body { margin: 0; padding: 0; min-height: 100%; }

body {
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  color: #1d2433;
  background: #0b1a3a;
  background-image: -webkit-linear-gradient(top, #071230 0%, #0f2a5c 60%, #1d4a88 100%);
  background-image: linear-gradient(to bottom, #071230 0%, #0f2a5c 60%, #1d4a88 100%);
  background-attachment: fixed;
  -webkit-text-size-adjust: 100%;
}

/* ------------------------------------------------------------ scene */

.sky {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

#snow { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 3; }

.star {
  position: absolute;
  top: 3%;
  left: 8%;
  width: 70px;
  height: 70px;
  -webkit-animation: twinkle 3s ease-in-out infinite;
  animation: twinkle 3s ease-in-out infinite;
}

.christkind {
  position: absolute;
  top: 8%;
  right: 4%;
  width: 110px;
  height: 117px;
  opacity: 0.95;
  -webkit-animation: float 6s ease-in-out infinite;
  animation: float 6s ease-in-out infinite;
}

.ground {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 34vh;
  max-height: 260px;
  min-height: 140px;
  z-index: 1;
}

@-webkit-keyframes twinkle { 0%, 100% { opacity: 1; } 50% { opacity: 0.65; } }
@keyframes twinkle { 0%, 100% { opacity: 1; } 50% { opacity: 0.65; } }
@-webkit-keyframes float {
  0%, 100% { -webkit-transform: translateY(0) rotate(-3deg); }
  50% { -webkit-transform: translateY(-12px) rotate(3deg); }
}
@keyframes float {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-12px) rotate(3deg); }
}

/* ------------------------------------------------------------ layout */

.page {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  padding: 0 16px 180px;
}

.topbar {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
  -webkit-box-pack: justify;
  -webkit-justify-content: space-between;
  justify-content: space-between;
  max-width: 640px;
  margin: 0 auto;
  padding: 14px 0;
}

.brand {
  margin: 0;
  font-size: 26px;
  color: #fff;
  font-family: Georgia, "Times New Roman", serif;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

.lang {
  border: 1px solid rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 15px;
  font-weight: bold;
  padding: 6px 12px;
  border-radius: 18px;
  cursor: pointer;
}

.topbar-buttons { white-space: nowrap; }
.music { margin-right: 8px; padding: 5px 10px; line-height: 1; font-size: 17px; }

#main { max-width: 640px; margin: 0 auto; }

.card {
  background: #fff;
  background: rgba(255, 255, 255, 0.94);
  border-radius: 16px;
  padding: 20px;
  margin: 12px auto;
  max-width: 420px;
  -webkit-box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

.card.wide { max-width: 640px; }
.card.center { text-align: center; }

.card h2 {
  margin: 0 0 8px;
  font-family: Georgia, "Times New Roman", serif;
  color: #b71c1c;
  font-size: 26px;
}

.card h3 { margin: 22px 0 6px; color: #0f2a5c; font-size: 19px; }
.card h4 { margin: 10px 0 6px; }

.card-head {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-box-pack: justify;
  -webkit-justify-content: space-between;
  justify-content: space-between;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
}

.lead { font-size: 19px; margin: 0 0 10px; color: #333; }
.hint { font-size: 14px; color: #5b6475; margin: 6px 0; }

.footer {
  position: relative;
  z-index: 2;
  text-align: center;
  color: #fff;
  margin-top: 24px;
  font-family: Georgia, serif;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
}

.msg {
  max-width: 420px;
  margin: 8px auto;
  padding: 10px 14px;
  background: #fff3cd;
  border-radius: 10px;
  color: #6b4e00;
}

/* ------------------------------------------------------------ forms */

label { display: block; font-weight: bold; margin: 12px 0 4px; font-size: 15px; }

input[type="text"],
input[type="password"],
input[type="number"],
select {
  display: block;
  width: 100%;
  font-size: 17px;
  padding: 10px 12px;
  border: 1px solid #b9c2d3;
  border-radius: 10px;
  background: #fff;
  color: #1d2433;
  -webkit-appearance: none;
}

select { -webkit-appearance: menulist; padding: 8px; }

input:focus, select:focus, button:focus { outline: 3px solid #ffd54f; outline-offset: 1px; }

.form-error { color: #b71c1c; font-weight: bold; margin: 8px 0; }

.btn {
  display: inline-block;
  font-size: 16px;
  padding: 10px 16px;
  margin: 6px 4px 0 0;
  border-radius: 10px;
  border: 1px solid #b9c2d3;
  background: #f1f4f9;
  color: #1d2433;
  cursor: pointer;
}

.btn.primary { background: #c62828; border-color: #a31515; color: #fff; font-weight: bold; }
form .btn.primary { width: 100%; margin-top: 14px; }
.inline-form .btn.primary { width: auto; margin-top: 0; }
.btn.danger { background: #fff; border-color: #c62828; color: #b71c1c; }
.btn.link { background: none; border-color: transparent; color: #0f4fa8; text-decoration: underline; padding: 8px 6px; }
.btn.small { font-size: 14px; padding: 6px 10px; }
.btn[disabled] { opacity: 0.6; cursor: default; }

.row {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
  -webkit-box-align: center;
  -webkit-align-items: center;
  align-items: center;
}

.row input[type="text"], .row input[type="number"] {
  -webkit-box-flex: 1;
  -webkit-flex: 1 1 160px;
  flex: 1 1 160px;
  width: auto;
  margin: 6px 8px 0 0;
}

.check { display: inline-block; font-weight: normal; margin: 6px 12px 0 0; }

.actions { margin-top: 18px; border-top: 1px solid #e3e7ef; padding-top: 8px; }

/* ------------------------------------------------------------ the present */

.gift {
  position: relative;
  display: block;
  width: 200px;
  height: 210px;
  margin: 16px auto 4px;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.gift-box {
  position: absolute;
  left: 20px;
  bottom: 0;
  width: 160px;
  height: 120px;
  border-radius: 6px;
  background-color: #c62828;
  background-image: -webkit-linear-gradient(left, transparent 68px, #ffd54f 68px, #ffd54f 92px, transparent 92px);
  background-image: linear-gradient(to right, transparent 68px, #ffd54f 68px, #ffd54f 92px, transparent 92px);
  -webkit-box-shadow: inset 0 -10px 0 rgba(0, 0, 0, 0.12), 0 10px 18px rgba(0, 0, 0, 0.25);
  box-shadow: inset 0 -10px 0 rgba(0, 0, 0, 0.12), 0 10px 18px rgba(0, 0, 0, 0.25);
  z-index: 2;
}

.gift-lid {
  position: absolute;
  left: 10px;
  bottom: 116px;
  width: 180px;
  height: 36px;
  border-radius: 6px;
  background-color: #e53935;
  background-image: -webkit-linear-gradient(left, transparent 78px, #ffd54f 78px, #ffd54f 102px, transparent 102px);
  background-image: linear-gradient(to right, transparent 78px, #ffd54f 78px, #ffd54f 102px, transparent 102px);
  -webkit-box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
  z-index: 4;
  -webkit-transition: -webkit-transform 0.8s cubic-bezier(.2, .8, .3, 1.2), opacity 0.8s;
  transition: transform 0.8s cubic-bezier(.2, .8, .3, 1.2), opacity 0.8s;
}

.gift-bow { position: absolute; left: 50%; top: -34px; width: 0; height: 0; }
.gift-bow span {
  position: absolute;
  top: 0;
  width: 44px;
  height: 34px;
  border: 9px solid #ffd54f;
  border-radius: 50% 50% 10% 50%;
}
.gift-bow span:first-child { right: 0; -webkit-transform: rotate(-20deg); transform: rotate(-20deg); }
.gift-bow span:last-child { left: 0; border-radius: 50% 50% 50% 10%; -webkit-transform: rotate(20deg); transform: rotate(20deg); }

.gift:not(.open):not(.busy) .gift-box,
.gift:not(.open):not(.busy) .gift-lid {
  -webkit-animation: wiggle 2.4s ease-in-out infinite;
  animation: wiggle 2.4s ease-in-out infinite;
}

.gift.busy .gift-box, .gift.busy .gift-lid {
  -webkit-animation: shake 0.35s linear infinite;
  animation: shake 0.35s linear infinite;
}

.gift.open .gift-lid {
  -webkit-transform: translate(70px, -110px) rotate(35deg);
  transform: translate(70px, -110px) rotate(35deg);
  opacity: 0;
}

/* starts hidden inside the box and rises to where the lid was, so the page
   layout does not change; anchored at the top so long names grow downwards */
.gift-result {
  position: absolute;
  left: 10px;
  right: 10px;
  top: 64px;
  z-index: 3;
  display: block;
  padding: 10px 6px;
  background: #fffdf3;
  border: 2px solid #ffd54f;
  border-radius: 10px;
  opacity: 0;
  -webkit-transform: translateY(0) scale(0.6);
  transform: translateY(0) scale(0.6);
  -webkit-transition: -webkit-transform 0.7s 0.35s cubic-bezier(.2, .8, .3, 1.3), opacity 0.5s 0.35s;
  transition: transform 0.7s 0.35s cubic-bezier(.2, .8, .3, 1.3), opacity 0.5s 0.35s;
}

.gift.open .gift-result {
  opacity: 1;
  -webkit-transform: translateY(-56px) scale(1);
  transform: translateY(-56px) scale(1);
  z-index: 5;
}

.gift-result-label { display: block; font-size: 14px; color: #5b6475; }
.gift-result-name {
  display: block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 28px;
  font-weight: bold;
  color: #b71c1c;
  word-wrap: break-word;
}

/* focus ring only for keyboard users, not after a tap or click */
.gift:focus:not(:focus-visible) { outline: none; }
.secret-note { font-style: italic; color: #0f2a5c; }

@-webkit-keyframes wiggle {
  0%, 80%, 100% { -webkit-transform: rotate(0); }
  85% { -webkit-transform: rotate(-4deg); }
  90% { -webkit-transform: rotate(4deg); }
  95% { -webkit-transform: rotate(-2deg); }
}
@keyframes wiggle {
  0%, 80%, 100% { transform: rotate(0); }
  85% { transform: rotate(-4deg); }
  90% { transform: rotate(4deg); }
  95% { transform: rotate(-2deg); }
}
@-webkit-keyframes shake {
  0%, 100% { -webkit-transform: translateX(0); }
  25% { -webkit-transform: translateX(-4px); }
  75% { -webkit-transform: translateX(4px); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* ------------------------------------------------------------ admin */

.user-list, .year-list { list-style: none; margin: 0; padding: 0; }

.user-list li, .year-list li {
  padding: 10px 0;
  border-bottom: 1px solid #e3e7ef;
}

.user-list .who { font-weight: bold; font-size: 18px; }
.badge {
  display: inline-block;
  font-size: 12px;
  padding: 1px 8px;
  border-radius: 10px;
  margin-left: 6px;
  background: #e3e7ef;
  color: #33405a;
  vertical-align: middle;
}
.badge.ok { background: #d8f0dc; color: #1b5e20; }
.badge.warn { background: #fff3cd; color: #6b4e00; }
.badge.admin { background: #fde0e0; color: #8e1b1b; }

.link-box {
  margin: 12px 0;
  padding: 12px;
  border: 2px dashed #c62828;
  border-radius: 12px;
  background: #fffaf7;
}
.link-box p { margin: 4px 0; }

.year-editor { margin-top: 12px; padding: 12px; background: #f6f8fc; border-radius: 12px; }
.year-editor table { width: 100%; border-collapse: collapse; }
.year-editor td, .year-editor th { padding: 4px; text-align: left; }
.year-editor td.arrow { width: 24px; text-align: center; color: #5b6475; }

/* ------------------------------------------------------------ misc */

@media (max-width: 700px) {
  /* on phones the card covers the top right corner: let the Christkind fly next to the crib */
  .christkind { top: auto; right: auto; left: 3%; bottom: 120px; width: 80px; height: 85px; }
}

@media (max-width: 420px) {
  .star { width: 50px; height: 50px; }
  .card { padding: 16px; }
  .brand { font-size: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  .star, .christkind,
  .gift:not(.open):not(.busy) .gift-box,
  .gift:not(.open):not(.busy) .gift-lid { -webkit-animation: none; animation: none; }
}
