/* The reader-facing calendar layout. Colours come from themes.css. */

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--bg); }
body {
  margin: 0; min-height: 100dvh; color: var(--ink); font: 16px/1.6 var(--sans);
  background: radial-gradient(120% 80% at 50% 0%, var(--bg2), var(--bg) 70%) fixed;
}
a { color: var(--accent); }
button { font: inherit; }

/* Theme decoration (themes.css) and the organiser's own background picture, softened so text stays readable */
.sky { position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .9; }
.bg-photo { position: fixed; inset: 0; z-index: 0; background: center / cover no-repeat; pointer-events: none; }
.bg-photo::after { content: ''; position: absolute; inset: 0; background: linear-gradient(color-mix(in srgb, var(--bg) 55%, transparent), color-mix(in srgb, var(--bg) 85%, transparent)); }

main { position: relative; z-index: 1; max-width: 1080px; margin: 0 auto; padding: 32px 16px 60px; }

.hero { text-align: center; padding: 8px 0 22px; }
/* Header picture: shown whole, whatever its shape (1200x630 is only a suggestion) */
.hero-art { margin: 0 auto 22px; max-width: 880px; display: flex; justify-content: center; }
.hero-art img { display: block; max-width: 100%; max-height: 70vh; width: auto; height: auto; border-radius: var(--radius); box-shadow: 0 18px 50px rgb(0 0 0 / .25); }
.host { margin: 0; color: var(--soft); letter-spacing: .12em; text-transform: uppercase; font-size: 12.5px; }
.title { font: 600 clamp(32px, 6vw, 60px) / 1.05 var(--display); margin: 8px 0 10px; text-wrap: balance; }
.tagline { margin: 0 auto; max-width: 620px; color: var(--soft); font-size: 18px; text-wrap: balance; }

.status { text-align: center; margin: 4px 0 24px; }
.clock { display: inline-flex; gap: 10px; margin-top: 10px; }
.clock span { min-width: 64px; padding: 10px 6px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); font: 600 26px/1 var(--display); }
.clock small { display: block; font: 500 11px var(--sans); color: var(--soft); margin-top: 6px; letter-spacing: .08em; text-transform: uppercase; }
.status p { margin: 0; }
.status .big { font: 500 20px var(--display); }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; backdrop-filter: blur(10px); }
.signup { max-width: 620px; margin: 0 auto 28px; }
.signup h2 { font: 600 24px var(--display); margin: 0 0 6px; }
.signup .row { display: flex; gap: 10px; flex-wrap: wrap; }
.signup .row > * { flex: 1 1 200px; }
.signup input[type=email], .signup input[type=text], .d-lock input[type=email], .d-lock input[type=text] {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: inherit;
}
.signup input:focus, .d-lock input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.consent { display: flex; gap: 10px; align-items: flex-start; margin: 14px 0; font-size: 14.5px; }
.consent input { margin-top: 5px; width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.authors-list { font-size: 14px; color: var(--soft); margin: 0 0 12px; }
.authors-list summary { cursor: pointer; color: var(--ink); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 13px 26px; border: 0; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn:disabled { opacity: .6; }
.fine { font-size: 12.5px; color: var(--soft); margin: 10px 0 0; }
.hp { position: absolute; left: -9999px; }

.intro { max-width: 680px; margin: 0 auto 28px; text-align: center; color: var(--soft); white-space: pre-line; }

/* Doors */
.doors { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); grid-auto-flow: dense; gap: 14px; perspective: 1400px; }
.door { position: relative; aspect-ratio: 3 / 4; border: 0; padding: 0; background: none; border-radius: 14px; cursor: pointer; color: var(--door-ink); }
/* The last door is the grand finale: two doors wide, same height as the others */
.door.wide { grid-column: span 2; aspect-ratio: 3 / 2; }

/* Behind the door: the cover or picture, or the title on the theme's colours */
.door .inside {
  position: absolute; inset: 0; border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end;
  padding: 12px; text-align: left; border: 2px solid var(--door-edge);
  background: linear-gradient(160deg, color-mix(in srgb, var(--door-edge) 35%, var(--inside)), var(--inside));
}
.door .inside.has-img { background: var(--inside) center / cover no-repeat; }
.door .inside.has-img::before { content: ''; position: absolute; inset: 0; background: linear-gradient(transparent 45%, rgb(0 0 0 / .78)); }
.door .inside .badge {
  position: absolute; top: 8px; left: 8px; min-width: 28px; height: 28px; padding: 0 8px; border-radius: 999px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font: 600 14px/1 var(--display);
}
.door .inside .peek { position: relative; font: 600 14px/1.25 var(--display); color: #fff; text-shadow: 0 1px 6px rgb(0 0 0 / .6); }
.door .inside .who { position: relative; font-size: 12px; color: rgb(255 255 255 / .8); margin-top: 3px; }

.door .leaf {
  position: absolute; inset: 0; border-radius: 14px; background: var(--door); border: 2px solid var(--door-edge);
  transform-origin: left center; transition: transform .8s cubic-bezier(.3, .8, .3, 1), opacity .35s .45s; backface-visibility: hidden;
  display: grid; place-items: center; box-shadow: 0 6px 18px rgb(0 0 0 / .18);
}
.door .leaf::after { content: ''; position: absolute; right: 12px; top: 50%; width: 7px; height: 7px; border-radius: 50%; background: var(--door-edge); }
.door .n { font: 600 clamp(34px, 5vw, 48px) / 1 var(--display); }
.door .when { position: absolute; bottom: 10px; left: 0; right: 0; text-align: center; font-size: 12px; opacity: .75; }
.door.locked { cursor: default; }
.door.locked .leaf { filter: saturate(.7); }
.door.locked .n { opacity: .55; }
.door.ready:not(.seen) .leaf { animation: nudge 3.5s ease-in-out infinite; }
.door.today .leaf { border-width: 3px; box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 35%, transparent), 0 8px 24px rgb(0 0 0 / .25); }
.door.today .when { opacity: 1; font-weight: 600; color: var(--accent); }
.door:not(.seen) .inside { visibility: hidden; }
.door.opening .inside { visibility: visible; }
.door.opening .leaf { transform: rotateY(-110deg); opacity: 0; animation: none; }
.door.seen .leaf { display: none; }
.door.seen:hover .inside { filter: brightness(1.08); }
.door:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
@keyframes nudge { 0%, 88%, 100% { transform: rotateY(0); } 92% { transform: rotateY(-8deg); } 96% { transform: rotateY(-3deg); } }

/* Little burst when a door opens (snow, stars, embers, hearts or confetti by theme) */
.fx-layer { position: fixed; inset: 0; width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: transparent; overflow: visible; pointer-events: none; }
.burst { position: fixed; z-index: 20; pointer-events: none; left: 0; top: 0; font-size: 16px; line-height: 1; color: var(--accent); will-change: transform, opacity; animation: burst 1.1s cubic-bezier(.2, .7, .3, 1) forwards; }
@keyframes burst {
  from { transform: translate(var(--x0), var(--y0)) scale(.4) rotate(0); opacity: 1; }
  to { transform: translate(var(--x1), var(--y1)) scale(1) rotate(var(--r)); opacity: 0; }
}
dialog#door[open] { animation: pop .45s cubic-bezier(.2, 1.3, .4, 1); }
@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Sharing */
.share { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; margin: 0 auto 28px; }
main > .share { margin-top: 32px; }
.share .label { color: var(--soft); font-size: 14px; margin-right: 4px; }
.share a, .share button {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); font-size: 14px; font-weight: 500; text-decoration: none; cursor: pointer;
}
.share a:hover, .share button:hover { border-color: var(--accent); }
.share svg { width: 16px; height: 16px; fill: currentColor; }
.d-share { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.d-share .share { justify-content: flex-start; margin: 0; }

/* Door content */
dialog#door { border: 0; padding: 0; border-radius: 22px; width: min(620px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); background: var(--bg); color: var(--ink); }
dialog#door::backdrop { background: rgb(5 5 10 / .6); backdrop-filter: blur(6px); }
.d-wrap { padding: 26px; }
.d-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 6px; }
.d-num { font: 500 13px var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--soft); }
.d-close { border: 0; background: var(--card); color: var(--ink); width: 38px; height: 38px; border-radius: 50%; cursor: pointer; font-size: 20px; line-height: 1; }
.d-title { font: 600 28px/1.15 var(--display); margin: 4px 0 14px; }
.d-title:has(+ .d-author) { margin-bottom: 4px; }
.d-author { color: var(--soft); margin: 0 0 14px; }
.d-img { position: relative; margin: 0 0 16px; border-radius: 14px; overflow: hidden; background: var(--card); }
.d-img img { display: block; width: 100%; max-height: 60vh; object-fit: contain; }
.own-cal-more { margin: 10px 0 0; font-size: 14px; }
.own-cal-more a { color: inherit; }

/* Organiser preview only: a door that readers won't see yet */
.pv-only { margin: 0 0 12px; padding: 6px 10px; border: 1px dashed currentColor; border-radius: 8px; font: 500 13px var(--sans); opacity: .8; }
.d-body { white-space: pre-line; margin: 0 0 16px; }
.d-body.rich { white-space: normal; }
.d-body.rich p { margin: 0 0 .8em; }
.d-body.rich p:last-child { margin-bottom: 0; }
.d-body a, .d-text a, .d-scene a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.d-text { white-space: pre-line; font: 17px/1.75 'Fraunces', Georgia, serif; max-height: 50vh; overflow: auto; padding-right: 6px; margin-bottom: 16px; }
.d-code { display: flex; gap: 8px; align-items: center; margin: 0 0 16px; }
.d-code code { flex: 1; padding: 12px 14px; border: 2px dashed var(--accent); border-radius: 12px; font: 600 20px/1 ui-monospace, monospace; text-align: center; letter-spacing: .08em; }
.d-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.adult-gate { position: relative; min-height: 240px; }
.adult-gate .blur { filter: blur(26px); pointer-events: none; user-select: none; }
.adult-gate .gate { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 16px; }
.adult-gate .gate div { background: var(--bg); border-radius: 14px; padding: 18px; max-width: 320px; }

.foot { margin-top: 48px; text-align: center; font-size: 13px; color: var(--soft); display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
.foot a { color: inherit; }
.preview-bar { position: sticky; top: 0; z-index: 5; background: #1f4d45; color: #fff; text-align: center; padding: 8px 16px; font-size: 14px; }
.preview-bar input { font: inherit; padding: 2px 6px; margin-left: 6px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; z-index: 30; }

@media (max-width: 560px) {
  main { padding-top: 20px; }
  .doors { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .door.wide { grid-column: span 1; aspect-ratio: 3 / 4; }
  .door .when { display: none; }
  .door.today .when { display: block; font-size: 11px; }
  .door .inside { padding: 8px; }
  .door .inside .peek { font-size: 12px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
  .door .inside .who { display: none; }
  .door .inside .badge { min-width: 24px; height: 24px; font-size: 12px; top: 6px; left: 6px; }
  .panel { padding: 18px; }
  .clock span { min-width: 54px; font-size: 22px; }
  .d-wrap { padding: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  .sky, .door.ready:not(.seen) .leaf, dialog#door[open] { animation: none; }
  .burst { display: none; }
  .door .leaf { transition: none; }
}

/* Reminder choice, signed-in bar, prize, my treats */
.confirm-note { text-align: center; margin: 12px 0 0; font-size: 14.5px; }
.confirm-note .btn { margin-left: 6px; }
.remind { border: 0; padding: 0; margin: 14px 0 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 14.5px; }
.remind legend { font-weight: 600; margin-bottom: 6px; width: 100%; }
.remind label { display: inline-flex; gap: 6px; align-items: center; }
.remind input { accent-color: var(--accent); }
.ts { margin: 0 0 12px; }
.reader-bar { max-width: 720px; margin: 0 auto 24px; }
.reader-bar .bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 18px; padding: 12px 18px; font-size: 15px; }
.reader-bar select { margin-left: 6px; padding: 6px 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: inherit; }
.btn.small { padding: 7px 16px; font-size: 14px; }
.prize { text-align: center; margin: 12px 0 0; color: var(--ink); }
.prize a { margin-left: 4px; }
.treats { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.treats button { width: 100%; display: flex; gap: 12px; align-items: center; text-align: left; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; }
.treats button:hover { border-color: var(--accent); }
.treats .badge { flex: none; min-width: 30px; height: 30px; border-radius: 999px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); font: 600 14px var(--display); }
.treats small { display: block; color: var(--soft); }

/* Scratch card over coupon codes */
.code-wrap { position: relative; flex: 1; display: flex; }
.code-wrap code { flex: 1; }
.scratch { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 12px; cursor: grab; touch-action: none; transition: opacity .45s; }
.scratch.gone { opacity: 0; }
.scratch-reveal { position: absolute; right: -4px; bottom: -48px; padding: 6px 14px; font-size: 13px; }
.d-code:has(.scratch-reveal) { margin-bottom: 56px; }
.phone-cal { margin: 12px auto 0; }
.phone-cal .label { width: 100%; text-align: center; margin: 0 0 2px; }

/* Book scene doors */
.scene-head { display: flex; gap: 14px; align-items: center; margin: 0 0 16px; }
.scene-cover { width: 74px; border-radius: 6px; box-shadow: 0 4px 14px rgb(0 0 0 / .3); flex: none; }
.scene-from { margin: 0; color: var(--soft); }
.d-scene { font: 17px/1.8 'Fraunces', Georgia, serif; margin: 0 0 20px; }
.d-scene p { margin: 0 0 1em; }
.d-scene p:first-child::first-letter { font-size: 2.6em; float: left; line-height: .9; margin: .08em .08em 0 0; color: var(--accent); }
.scene-more { border-top: 1px solid var(--line); padding-top: 16px; }
.scene-more h3 { font: 600 20px var(--display); margin: 0 0 12px; }
.scene-code { margin-top: 14px; }
.scene-code p { margin: 0 0 8px; }
.affiliate-note { margin: 12px 0 0; font-size: 12.5px; color: var(--soft); }

/* Audio and video doors */
.d-media { margin: 0 0 16px; border-radius: 12px; overflow: hidden; background: #000; }
.d-media iframe, .d-media video { display: block; width: 100%; border: 0; }
.d-media.video iframe, .d-media video { aspect-ratio: 16 / 9; height: auto; }
.d-media.audio iframe { height: 166px; }
.d-media.list iframe { height: 352px; }
.d-media.audio-file { background: none; }
.d-media audio { display: block; width: 100%; }

/* "Run your own calendar" box on calendars for authors */
.own-cal { margin-top: 40px; text-align: center; }
.own-cal h2 { margin: 0 0 8px; font-family: var(--display); }
.own-cal p { margin: 0 0 16px; color: var(--soft); }
.own-cal.own-cal-quiet { margin-top: 28px; padding: 14px 18px; }
.own-cal.own-cal-quiet p { margin: 0; font-size: 14px; }
.own-cal-quiet a { color: inherit; font-weight: 600; white-space: nowrap; }

/* Door-by-door sign-up */
.d-lock { margin: 18px 0 8px; }
.d-lock h3 { margin: 0 0 10px; font-family: var(--display); }
.d-lock .row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.d-lock .row input { flex: 1 1 160px; }
.d-scene.teaser { -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }

.d-text.rich { white-space: normal; }
.d-text.rich p { margin: 0 0 1em; }
.d-text.teaser { -webkit-mask-image: linear-gradient(#000 70%, transparent); mask-image: linear-gradient(#000 70%, transparent); }
.d-scene hr, .d-text hr { border: 0; margin: 1.2em 0; text-align: center; }
.d-scene hr::after, .d-text hr::after { content: '* * *'; letter-spacing: .4em; color: var(--soft); }
.d-scene blockquote, .d-text blockquote { margin: 0 0 1em 1.2em; font-style: italic; }

/* Doors open on their day only: the ones a reader missed */
.door.missed { opacity: .45; filter: grayscale(.6); }

/* Mixed door sizes (the grid fills gaps so it stays tidy) */
.doors { grid-auto-flow: dense; }
.door.tall { grid-row: span 2; aspect-ratio: auto; }

/* Password box */
.pw .row { display: flex; gap: 10px; flex-wrap: wrap; }
.pw input { flex: 1 1 200px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: inherit; }

/* Inside someone else's website: no page-filling background picture, a little less space */
.embedded .bg-photo { position: absolute; }
.embedded main { padding-top: 16px; }

/* Behind the scenes: the author's note under a scene or story */
.author-note { margin: 4px 0 22px; padding: 16px 18px; border-left: 3px solid var(--accent); border-radius: 0 12px 12px 0; background: color-mix(in srgb, var(--accent) 8%, transparent); font-size: 15.5px; }
.author-note p { margin: 0 0 .6em; font-style: italic; }
.author-note p:last-child { margin-bottom: 0; }
.author-note .an-head { font-style: normal; font-weight: 600; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--soft); }

/* Long welcome text folds away */
.intro.clamped { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.intro-more { display: block; margin: -6px auto 18px; }
.d-next { text-align: right; margin: 8px 0 0; }

/* Daily advent calendars: the number says the date, so only "Today" is written on a door */
.doors.no-dates .door:not(.today) .when { display: none; }
