@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Fraunces:opsz,wght@9..144,600;9..144,700&display=swap');

:root {
  --ink: #f8f2e7;
  --ink-dark: #152638;
  --muted: #a9b9c5;
  --night: #081827;
  --night-2: #102d45;
  --red: #a52a2f;
  --red-bright: #d14a42;
  --green: #174c3d;
  --gold: #f3c969;
  --paper: #fffaf0;
  --shadow: 0 24px 70px rgba(0, 0, 0, .34);
  --radius: 1.35rem;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 10%, rgba(70, 128, 161, .18), transparent 27rem),
    linear-gradient(145deg, var(--night-2), var(--night) 55%);
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.55;
}

button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: var(--gold); text-underline-offset: .2em; }
h1, h2, h3 { margin: 0; font-family: "Fraunces", Georgia, serif; line-height: 1.02; letter-spacing: -.025em; }
h1 { font-size: clamp(2.5rem, 7vw, 5.6rem); }
h2 { font-size: clamp(1.65rem, 3vw, 2.5rem); }
p { margin: 0; }

.skip-link { position: fixed; left: 1rem; top: -5rem; z-index: 1000; padding: .75rem 1rem; background: white; color: #111; }
.skip-link:focus { top: 1rem; }
.site-header { display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; width: min(1480px, calc(100% - 2rem)); margin: 0 auto; padding: 1.15rem 0; }
.brand { display: inline-flex; align-items: center; gap: .7rem; color: var(--ink); text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 2.6rem; aspect-ratio: 1; color: var(--night); background: var(--gold); border-radius: 50%; box-shadow: 0 0 0 .25rem rgba(243, 201, 105, .15); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: .82rem; letter-spacing: .15em; }
.brand small { color: var(--muted); font-size: .75rem; }
.header-actions { display: flex; align-items: center; gap: 1rem; font-size: .88rem; }
.header-actions form { margin: 0; }
.user-chip { padding: .45rem .75rem; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12); border-radius: 999px; }
.text-link, .text-button { color: var(--ink); font-weight: 600; }
.text-button { padding: 0; border: 0; background: transparent; cursor: pointer; text-decoration: underline; text-underline-offset: .2em; }
.mobile-label { display: none; }

.eyebrow { margin-bottom: .7rem; color: var(--gold); font-size: .74rem; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
.primary-button { display: inline-flex; align-items: center; justify-content: center; min-height: 3.15rem; padding: .8rem 1.2rem; color: white; background: linear-gradient(135deg, var(--red-bright), var(--red)); border: 0; border-radius: .8rem; box-shadow: 0 .55rem 1.4rem rgba(104, 17, 25, .28); font-weight: 700; text-decoration: none; cursor: pointer; transition: transform .2s ease, box-shadow .2s ease; }
.primary-button:hover { transform: translateY(-2px); box-shadow: 0 .8rem 1.8rem rgba(104, 17, 25, .4); }
.primary-button:focus-visible, button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }

.flash-stack { position: fixed; z-index: 100; top: 5.5rem; right: 1rem; display: grid; gap: .6rem; width: min(26rem, calc(100% - 2rem)); }
.flash { padding: .9rem 1rem; color: var(--ink-dark); background: var(--paper); border-left: .35rem solid var(--gold); border-radius: .65rem; box-shadow: var(--shadow); }
.flash.error { border-color: var(--red-bright); }
.flash.success { border-color: #3b8e6c; }

/* Authentication */
.auth-page { background: linear-gradient(90deg, rgba(4,14,24,.9), rgba(4,14,24,.38)), url('../images/julvilla.png') center/cover fixed; }
.auth-page::after { content: ""; position: fixed; inset: 0; z-index: -1; background: repeating-linear-gradient(105deg, transparent 0 5rem, rgba(255,255,255,.012) 5rem 5.1rem); pointer-events: none; }
.auth-shell { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(20rem, .75fr); align-items: center; gap: clamp(2rem, 7vw, 7rem); width: min(1180px, calc(100% - 2rem)); min-height: calc(100vh - 6rem); margin: 0 auto; padding: 3rem 0 6rem; }
.auth-shell.single { grid-template-columns: minmax(20rem, 34rem); justify-content: center; }
.auth-copy { max-width: 44rem; text-shadow: 0 .2rem 1rem rgba(0,0,0,.55); }
.auth-copy > p:not(.eyebrow) { max-width: 36rem; margin-top: 1.4rem; color: #dce6ec; font-size: clamp(1rem, 2vw, 1.25rem); }
.auth-copy blockquote { margin: 2rem 0 0; padding-left: 1.2rem; border-left: .2rem solid var(--gold); font-family: "Fraunces", serif; font-size: 1.25rem; }
.auth-decoration { display: flex; gap: .8rem; margin-top: 2.2rem; }
.auth-decoration span { display: grid; place-items: center; width: 4.4rem; aspect-ratio: .82; background: rgba(132,26,34,.82); border: 2px solid rgba(255,255,255,.55); border-radius: .35rem; box-shadow: inset .3rem 0 rgba(0,0,0,.18), 0 1rem 2rem rgba(0,0,0,.22); font: 700 1.5rem "Fraunces", serif; transform: rotate(-3deg); }
.auth-decoration span:nth-child(2) { transform: rotate(4deg) translateY(.5rem); background: rgba(25,78,62,.9); }
.auth-card { padding: clamp(1.5rem, 4vw, 2.5rem); color: var(--ink-dark); background: rgba(255,250,240,.96); border: 1px solid rgba(255,255,255,.8); border-radius: var(--radius); box-shadow: var(--shadow); backdrop-filter: blur(16px); }
.auth-card h1, .auth-card h2 { margin-bottom: .8rem; }
.auth-card > p:not(.eyebrow):not(.form-foot) { margin-bottom: 1.5rem; color: #52606b; }
label { display: grid; gap: .4rem; margin-top: 1rem; color: inherit; font-size: .88rem; font-weight: 700; }
label small { color: #687681; font-weight: 500; }
input, textarea, select { width: 100%; padding: .78rem .85rem; color: var(--ink-dark); background: white; border: 1px solid #c8d0d5; border-radius: .6rem; }
textarea { resize: vertical; }
.auth-card .primary-button { width: 100%; margin-top: 1.5rem; }
.form-foot { margin-top: 1.2rem; color: #687681; font-size: .88rem; text-align: center; }
.form-foot a { color: var(--red); font-weight: 700; }
.error-card { width: min(42rem, calc(100% - 2rem)); margin: 12vh auto; padding: 3rem; color: var(--ink-dark); background: var(--paper); border-radius: var(--radius); text-align: center; box-shadow: var(--shadow); }
.error-code { color: var(--red); font: 700 5rem "Fraunces", serif; }
.error-card p:not(.error-code) { margin: 1rem 0 2rem; }

/* Calendar */
.calendar-intro { display: grid; grid-template-columns: 1.25fr .75fr; align-items: end; gap: 3rem; width: min(1380px, calc(100% - 2rem)); margin: 3rem auto 2rem; }
.intro-copy { max-width: 48rem; margin-top: 1.15rem; color: var(--muted); font-size: 1.08rem; }
.progress-card { padding: 1.3rem; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); border-radius: 1rem; }
.progress-count { display: flex; align-items: baseline; gap: .55rem; }
.progress-count strong { font: 700 2.8rem "Fraunces", serif; }
.progress-count small { color: var(--muted); }
.progress-bar { height: .5rem; margin: .65rem 0 .8rem; overflow: hidden; background: rgba(255,255,255,.1); border-radius: 999px; }
.progress-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--red-bright), var(--gold)); border-radius: inherit; transition: width .4s ease; }
.progress-card p { color: var(--muted); font-size: .9rem; }
.preview-banner { width: min(1380px, calc(100% - 2rem)); margin: 0 auto 1rem; padding: .8rem 1rem; color: #372b0f; background: var(--gold); border-radius: .65rem; }
.preview-banner a { color: #372b0f; font-weight: 700; }
.calendar-stage { position: relative; width: min(1500px, calc(100% - 1rem)); aspect-ratio: 3 / 2; margin: 0 auto; overflow: hidden; background: #0b1d2b; border: 1px solid rgba(255,255,255,.15); border-radius: clamp(.8rem, 2vw, 1.8rem); box-shadow: 0 2rem 7rem rgba(0,0,0,.5); isolation: isolate; }
.calendar-stage > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.calendar-stage::after { content: ""; position: absolute; inset: 0; z-index: 1; background: linear-gradient(180deg, rgba(3,14,24,.03), rgba(3,14,24,.1) 70%, rgba(3,14,24,.32)); pointer-events: none; }
.snow-layer { position: absolute; inset: -20%; z-index: 2; pointer-events: none; background-image: radial-gradient(circle, rgba(255,255,255,.9) 0 1px, transparent 1.5px); background-size: 3rem 3rem; opacity: .28; animation: snow 18s linear infinite; }
@keyframes snow { to { transform: translate3d(3rem, 3rem, 0); } }
.door { position: absolute; z-index: 4; left: var(--x); top: var(--y); width: clamp(2rem, 4.4vw, 4.6rem); aspect-ratio: .78; padding: 0; color: white; background: transparent; border: 0; perspective: 500px; transform: translate(-50%, -50%) rotate(var(--r)); cursor: pointer; }
.door-frame { position: absolute; inset: 0; display: grid; place-items: center; border: clamp(1px, .22vw, 3px) solid rgba(255,243,202,.9); border-radius: .25rem; box-shadow: 0 .25rem .7rem rgba(0,0,0,.42), inset 0 0 0 1px rgba(0,0,0,.3); transform-style: preserve-3d; }
.door-face { position: absolute; inset: 0; display: grid; place-items: center; color: #fff8e5; background: linear-gradient(135deg, rgba(151,30,38,.96), rgba(74,14,25,.96)); border-radius: .15rem; font: 700 clamp(.8rem, 2vw, 1.55rem) "Fraunces", serif; text-shadow: 0 1px 2px #381013; transform-origin: left center; transition: transform .55s cubic-bezier(.2,.8,.2,1), filter .2s; backface-visibility: hidden; }
.door:nth-of-type(3n) .door-face { background: linear-gradient(135deg, rgba(35,92,70,.97), rgba(14,47,43,.97)); }
.door-glow { color: var(--gold); font-size: clamp(.9rem, 2vw, 1.7rem); opacity: .85; filter: drop-shadow(0 0 .45rem var(--gold)); }
.door:hover .door-face { filter: brightness(1.18); transform: rotateY(-24deg); }
.door.is-opened .door-face { transform: rotateY(-76deg); }
.door.is-locked { cursor: not-allowed; filter: saturate(.45); }
.door.is-locked .door-face::after { content: "•"; position: absolute; right: 12%; bottom: 7%; color: var(--gold); }
.door.is-shaking { animation: shake .42s ease; }
@keyframes shake { 0%,100% { transform: translate(-50%,-50%) rotate(var(--r)); } 25% { transform: translate(-54%,-50%) rotate(calc(var(--r) - 2deg)); } 75% { transform: translate(-46%,-50%) rotate(calc(var(--r) + 2deg)); } }
.door-index { width: min(1180px, calc(100% - 2rem)); margin: 5rem auto; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 2rem; margin-bottom: 1.25rem; }
.section-heading > p { max-width: 28rem; color: var(--muted); text-align: right; }
.door-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: .65rem; }
.door-tile { display: grid; gap: .15rem; min-height: 4.7rem; padding: .6rem .3rem; color: var(--ink); background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); border-radius: .65rem; cursor: pointer; }
.door-tile span { font: 700 1.35rem "Fraunces", serif; }
.door-tile small { color: var(--muted); font-size: .67rem; }
.door-tile.is-opened { background: rgba(41,112,84,.35); border-color: rgba(104,204,160,.5); }

.door-dialog { width: min(38rem, calc(100% - 2rem)); padding: 0; overflow: visible; color: var(--ink-dark); background: var(--paper); border: 0; border-radius: 1.25rem; box-shadow: var(--shadow); }
.door-dialog::backdrop { background: rgba(2,10,18,.78); backdrop-filter: blur(7px); }
.door-dialog[open] { animation: dialog-in .35s cubic-bezier(.2,.8,.2,1); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(2rem) scale(.96); } }
.dialog-ribbon { position: absolute; top: -1rem; left: 1.5rem; padding: .65rem .9rem; color: white; background: var(--red); border-radius: .45rem; box-shadow: 0 .45rem 1rem rgba(0,0,0,.23); font-size: .75rem; font-weight: 700; letter-spacing: .12em; }
.dialog-close { position: absolute; right: .8rem; top: .7rem; width: 2.5rem; height: 2.5rem; color: #5c6870; background: transparent; border: 0; font-size: 2rem; cursor: pointer; }
.door-dialog > :not(.dialog-close):not(.dialog-ribbon):not(.dialog-image) { margin-left: clamp(1.5rem, 5vw, 3rem); margin-right: clamp(1.5rem, 5vw, 3rem); }
.door-dialog .eyebrow { margin-top: 3.2rem; }
.door-dialog h2 { margin-bottom: 1.25rem !important; font-size: clamp(2rem, 6vw, 3.4rem); }
.dialog-image { width: 100%; max-height: 18rem; margin-bottom: 1.4rem; object-fit: cover; }
.dialog-body { white-space: pre-line; font-size: 1.13rem; }
.dialog-punchline { margin-top: 1.4rem !important; padding-top: 1rem; color: #6f3840; border-top: 1px solid #dfd5c5; font-style: italic; font-weight: 600; }
.dialog-done { margin-top: 1.8rem !important; margin-bottom: 2.2rem !important; }
.toast { position: fixed; z-index: 120; left: 50%; bottom: 1.2rem; max-width: calc(100% - 2rem); padding: .75rem 1rem; color: var(--ink-dark); background: var(--gold); border-radius: 999px; box-shadow: var(--shadow); opacity: 0; transform: translate(-50%, 2rem); pointer-events: none; transition: .25s ease; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* Admin */
.admin-hero { display: flex; align-items: end; justify-content: space-between; gap: 2rem; width: min(1380px, calc(100% - 2rem)); margin: 4rem auto 3rem; }
.admin-hero p:not(.eyebrow) { max-width: 46rem; margin-top: 1rem; color: var(--muted); }
.admin-layout { display: grid; grid-template-columns: minmax(0, 1fr) 19rem; align-items: start; gap: 2rem; width: min(1380px, calc(100% - 2rem)); margin: 0 auto 6rem; }
.editor-list { min-width: 0; }
.door-editor { margin-bottom: .7rem; overflow: hidden; color: var(--ink-dark); background: rgba(255,250,240,.97); border-radius: .8rem; }
.door-editor summary { display: grid; grid-template-columns: 3rem 1fr auto; align-items: center; gap: 1rem; padding: .9rem 1rem; cursor: pointer; list-style: none; }
.door-editor summary::-webkit-details-marker { display: none; }
.door-editor summary small, .user-row small { display: block; color: #75818a; font-size: .75rem; font-weight: 500; }
.editor-day { display: grid; place-items: center; width: 2.7rem; aspect-ratio: 1; color: white; background: var(--red); border-radius: .55rem; font: 700 1rem "Fraunces", serif; }
.editor-chevron { font-size: 1.5rem; transition: transform .2s; }
.door-editor[open] .editor-chevron { transform: rotate(180deg); }
.door-editor form { padding: .25rem 1rem 1.2rem; border-top: 1px solid #e1d8c9; }
.form-row { display: grid; grid-template-columns: 13rem 1fr; gap: 1rem; }
.editor-actions { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1.2rem; }
.editor-actions span { color: #75818a; font-size: .75rem; }
.user-panel { position: sticky; top: 1rem; padding: 1.25rem; color: var(--ink-dark); background: var(--paper); border-radius: 1rem; }
.user-list { display: grid; gap: .8rem; margin: 1.2rem 0; }
.user-row { display: flex; align-items: center; gap: .7rem; }
.avatar { display: grid; place-items: center; width: 2.4rem; aspect-ratio: 1; color: white; background: var(--green); border-radius: 50%; font-weight: 700; }
.admin-note { margin-top: 1.5rem; padding: 1rem; background: #f0e7d8; border-radius: .7rem; font-size: .83rem; }
.admin-note p { margin-top: .45rem; color: #65717a; }

@media (max-width: 900px) {
  .header-actions .user-chip { display: none; }
  .auth-shell, .calendar-intro { grid-template-columns: 1fr; }
  .auth-copy { padding-top: 3rem; }
  .calendar-intro { align-items: start; gap: 1.5rem; }
  .door-grid { grid-template-columns: repeat(6, 1fr); }
  .admin-layout { grid-template-columns: 1fr; }
  .user-panel { position: static; }
}

@media (max-width: 620px) {
  .site-header { align-items: flex-start; }
  .brand small, .desktop-label { display: none; }
  .mobile-label { display: inline; }
  .header-actions { gap: .65rem; }
  .auth-shell { grid-template-columns: 1fr; padding-top: 1rem; }
  .auth-copy h1 { font-size: 3.1rem; }
  .auth-decoration { display: none; }
  .calendar-intro { margin-top: 2rem; }
  .calendar-stage { width: 100%; border-left: 0; border-right: 0; border-radius: 0; }
  .door { width: 2rem; }
  .door-grid { grid-template-columns: repeat(4, 1fr); }
  .section-heading, .admin-hero, .editor-actions { align-items: flex-start; flex-direction: column; }
  .section-heading > p { text-align: left; }
  .form-row { grid-template-columns: 1fr; gap: 0; }
  .admin-hero { margin-top: 2rem; }
  .admin-hero .primary-button, .editor-actions .primary-button { width: 100%; }
  .door-editor summary { grid-template-columns: 2.7rem 1fr auto; gap: .65rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
