/* ============================================================================
   10.000 Dreams — submission portal.
   Extends the palette and typography already defined in index.html; it adds no
   new colours of its own, so the form reads as part of the same sky.
   ========================================================================== */

/* The [hidden] attribute is how this page shows and hides panels from JavaScript.
   A class rule such as `.preview { display: flex }` outranks the user-agent
   `[hidden] { display: none }`, so state it once here and win. */
[hidden] { display: none !important; }

.portal {
  background: url('../img/background.jpeg') center / cover no-repeat;
}

.portal-card {
  max-width: 760px;
  margin: 0 auto;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 26px;
  padding: clamp(24px, 4vw, 48px);
  box-shadow: 0 18px 50px rgba(30, 122, 191, .10);
}
.portal-card .eyebrow { justify-content: flex-start; }
.portal-card h2 { font-size: clamp(1.8rem, 3.6vw, 2.5rem); }
.portal-card .lede { margin-bottom: 1.4rem; }

.form-note {
  display: flex; gap: 10px; align-items: flex-start;
  background: rgba(13, 140, 140, .08);
  border: 1px solid rgba(13, 140, 140, .22);
  border-radius: 14px;
  padding: .8rem 1rem;
  font-size: .9rem; color: var(--soft);
  margin-bottom: 1.8rem;
}

/* ---- who is dreaming ------------------------------------------------------ */
.dform-who { border: 0; padding: 0; margin: 0 0 1.6rem; }
.dform-who legend {
  font-size: .72rem; font-weight: 800; letter-spacing: .18em;
  text-transform: uppercase; color: var(--teal); padding: 0 0 .6rem;
}
.who-opts { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.who { position: relative; display: block; cursor: pointer; }
/* Visually hidden but still a real, focusable radio: clipped rather than
   zero-sized, so pointer, keyboard and assistive technology all still reach it. */
.who input {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
.who-body {
  display: grid; grid-template-columns: auto 1fr; gap: 4px 10px;
  border: 2px solid var(--border); border-radius: 16px;
  padding: 14px 16px; height: 100%;
  transition: border-color .18s, background .18s;
}
.who-ico { grid-row: 1 / span 2; align-self: start; font-size: 1.3rem; }
.who-t { font-weight: 700; color: var(--heading); font-size: .96rem; }
.who-h { font-size: .82rem; color: var(--muted); line-height: 1.45; }
.who input:checked + .who-body { border-color: var(--gold); background: rgba(240, 180, 41, .08); }
.who input:focus-visible + .who-body { outline: 3px solid var(--azure); outline-offset: 2px; }

/* ---- fields --------------------------------------------------------------- */
.dgrid { display: grid; gap: 0 18px; grid-template-columns: 1fr 140px; }
@media (max-width: 560px) { .dgrid { grid-template-columns: 1fr; } }

.field { margin-bottom: 1.3rem; }
.field > label {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
  font-weight: 700; font-size: .92rem; color: var(--heading); margin-bottom: .4rem;
}
.field > label em {
  font-style: normal; font-weight: 700; font-size: .7rem;
  letter-spacing: .1em; text-transform: uppercase; color: var(--muted);
}
.field > label em.req { color: var(--gold-dk); }

.field input[type="text"],
.field input[type="number"],
.field textarea {
  width: 100%;
  font-family: var(--body); font-size: 1rem; color: var(--text);
  background: var(--tint);
  border: 2px solid var(--border); border-radius: 14px;
  padding: .72rem .95rem;
  transition: border-color .18s, background .18s;
}
.field textarea { resize: vertical; min-height: 108px; line-height: 1.6; }
.field input:focus, .field textarea:focus {
  outline: none; border-color: var(--azure); background: var(--white);
}
.field input[aria-invalid="true"], .field textarea[aria-invalid="true"] { border-color: #cf4a4a; }

.hint  { font-size: .82rem; color: var(--muted); margin: .4rem 0 0; max-width: none; }
.count { font-size: .76rem; color: var(--muted); margin: .3rem 0 0; text-align: right; }
.err   { font-size: .84rem; color: #b02f2f; font-weight: 700; margin: .4rem 0 0; }

/* ---- file --------------------------------------------------------------- */
.drop {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  border: 2px dashed var(--border); border-radius: 16px;
  padding: 18px; background: var(--tint);
  transition: border-color .18s, background .18s;
}
.drop.over { border-color: var(--gold); background: rgba(240, 180, 41, .09); }
.drop input[type="file"] {
  position: absolute; width: 1px; height: 1px; padding: 0;
  margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.drop-btn { cursor: pointer; padding: .6rem 1.2rem; font-size: .9rem; }
.drop input[type="file"]:focus-visible + .drop-btn { outline: 3px solid var(--azure); outline-offset: 2px; }
.drop-or { font-size: .86rem; color: var(--muted); }

.preview {
  display: flex; align-items: center; gap: 14px;
  margin-top: 12px; padding: 12px;
  border: 1px solid var(--border); border-radius: 16px; background: var(--white);
}
.preview-thumb {
  width: 64px; height: 64px; flex: 0 0 64px;
  border-radius: 12px; background: var(--sky2) center/cover no-repeat;
  display: grid; place-items: center; font-size: 1.6rem;
}
.preview-meta { display: grid; gap: 2px; min-width: 0; flex: 1; }
.preview-name { font-weight: 700; font-size: .9rem; color: var(--heading); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-size { font-size: .78rem; color: var(--muted); }
.preview-x {
  border: 0; background: none; cursor: pointer;
  font-family: var(--body); font-weight: 800; font-size: .82rem;
  color: #b02f2f; text-decoration: underline; padding: .3rem;
}

/* ---- location ------------------------------------------------------------ */
.loc { display: flex; gap: 10px; flex-wrap: wrap; }
.loc-btn { flex: 0 0 auto; padding: .68rem 1.1rem; font-size: .88rem; cursor: pointer; }
.loc input[type="text"] { flex: 1 1 220px; }
.loc-status { font-size: .84rem; color: var(--teal); font-weight: 700; margin: .5rem 0 0; }
.loc-status.warn { color: var(--gold-dk); }

/* ---- consent ------------------------------------------------------------- */
.consent { background: var(--tint); border: 1px solid var(--border); border-radius: 16px; padding: 16px 18px; }
.check { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; font-weight: 600; font-size: .94rem; color: var(--text); }
.check input { width: 22px; height: 22px; flex: 0 0 22px; margin-top: 1px; accent-color: var(--azure); cursor: pointer; }

/* Honeypot: off-screen for people, still a real field for a form-filling bot. */
.nectar { position: absolute; left: -9999px; top: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---- actions ------------------------------------------------------------- */
.form-error {
  background: rgba(207, 74, 74, .1); border: 1px solid rgba(207, 74, 74, .35);
  border-radius: 14px; padding: .8rem 1rem; color: #8f2424; font-weight: 700; font-size: .92rem;
  margin-bottom: 1rem;
}
.dform-actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.dform-actions .btn { cursor: pointer; }
.dform-actions .btn[disabled] { opacity: .55; cursor: progress; transform: none; }
.progress { flex: 1 1 160px; height: 8px; border-radius: 100px; background: var(--sky2); overflow: hidden; min-width: 120px; }
.progress-bar { display: block; height: 100%; width: 0; border-radius: 100px; background: linear-gradient(90deg, var(--gold), var(--teal)); transition: width .25s ease; }

/* ---- success ------------------------------------------------------------- */
.dform-done { text-align: center; padding: 22px 0 8px; }
.done-star { font-size: 3rem; color: var(--gold); animation: wave 3.4s ease-in-out infinite; }
.dform-done h3 { font-size: 1.6rem; margin: .5rem 0; }
.dform-done p { margin: 0 auto 1rem; max-width: 46ch; color: var(--soft); }
.done-ref { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; color: var(--muted); letter-spacing: .04em; }
.done-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 1.1rem; }
.done-actions .btn { cursor: pointer; }

/* A location we guessed, rather than one the visitor gave us. */
.loc-status.guess { color: var(--muted); font-weight: 600; }

/* ---- language switcher (buttons, not links: no page reload) -------------- */
.langsel button.lang-btn {
  font-family: var(--body); font-size: .72rem; font-weight: 800; letter-spacing: .06em;
  color: #b09a76; background: none; border: 0; border-radius: 6px;
  padding: 3px 7px; cursor: pointer; transition: background .18s, color .18s;
}
.langsel button.lang-btn:hover { color: var(--heading); }
.langsel button.lang-btn.on { background: var(--bg-2); color: var(--heading); }
.langsel button.lang-btn:focus-visible { outline: 2px solid var(--azure); outline-offset: 2px; }

/* A pin standing for several dreams from one place carries their count. */
.pin .pin-count {
  position: absolute; top: -5px; right: -7px;
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 100px; border: 1.5px solid #fff;
  background: var(--azure-dk); color: #fff;
  font-family: var(--body); font-size: .62rem; font-weight: 900; line-height: 14px;
  text-align: center; box-shadow: 0 1px 3px rgba(20, 60, 110, .4);
}
.pin.cluster { z-index: 2; }
.popup .pp {
  display: block; margin-top: 6px;
  font-size: .68rem; font-weight: 800; letter-spacing: .08em;
  color: var(--moon-dim); text-transform: uppercase;
}
.map-note {
  max-width: 46ch; margin: 18px auto 0; text-align: center;
  font-size: .92rem; color: var(--moon-dim);
}
.map-arrived {
  max-width: 52ch; margin: 18px auto 0; padding: .7rem 1.2rem;
  display: flex; gap: 10px; justify-content: center; align-items: center;
  border-radius: 100px; text-align: center;
  background: rgba(240, 180, 41, .16); border: 1px solid rgba(240, 180, 41, .45);
  color: var(--gold-bright); font-weight: 800; font-size: .92rem;
}
@media (prefers-reduced-motion: no-preference) {
  .pin.arrived svg { animation: arrived 1.6s ease-in-out 4; }
}
@keyframes arrived {
  0%, 100% { filter: none; }
  50%      { filter: drop-shadow(0 0 12px rgba(246, 213, 138, .95)); }
}

/* Translations swap in after first paint; keep the layout from lurching. */
html.i18n-loading body { opacity: 0; }
html.i18n-ready body { opacity: 1; transition: opacity .18s ease; }

@media (prefers-reduced-motion: reduce) {
  .done-star { animation: none; }
  .progress-bar { transition: none; }
  html.i18n-ready body { transition: none; }
}

/* ---- media lightbox ------------------------------------------------------- */
.lightbox {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center; padding: 4vmin;
  background: rgba(11, 28, 69, .88);
}
.lightbox-figure { margin: 0; display: grid; gap: 14px; justify-items: center; max-width: 100%; }
.lightbox-stage {
  display: grid; place-items: center;
  max-width: min(1100px, 92vw); max-height: 78vh;
  border-radius: 16px; overflow: hidden;
  background: rgba(255, 255, 255, .06);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .45);
}
.lightbox-stage img,
.lightbox-stage video { display: block; max-width: min(1100px, 92vw); max-height: 78vh; }
.lightbox-cap {
  color: #eef2fb; font-size: .92rem; text-align: center; max-width: 62ch;
  text-shadow: 0 1px 6px rgba(0, 0, 0, .5);
}
.lightbox-cap b { color: var(--gold-bright); font-weight: 800; }
.lightbox-x {
  position: absolute; top: 14px; right: 18px;
  width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .3); background: rgba(255, 255, 255, .12);
  color: #fff; font-size: 1.6rem; line-height: 1; cursor: pointer;
}
.lightbox-x:hover { background: rgba(255, 255, 255, .24); }
.lightbox-x:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.lightbox-loading { color: #cfe0f5; font-size: .9rem; padding: 40px 60px; }

/* A dream with no place of its own drifts on the open sea. */
.pin.adrift svg { opacity: .82; }
.pin.adrift svg path { stroke: rgba(255, 255, 255, .85); stroke-width: 1.4; }

@media print { .portal, .lightbox, .map-zoom, .map-hint { display: none !important; } }
