/* ==========================================================================
   cloudaStay — base comuna (gestor, administració, accés i guia)
   Marca filla de cloudacat (manual E32): Lexend + Geist Mono, tot arrodonit,
   gamma pròpia Mel: Palla #FCE8C3 · Mel #F0B44C · Ambre #7A4A00 · Llum #FBF7EF · Nit #1E160B.
   ========================================================================== */

@font-face { font-family: 'Lexend'; font-style: normal; font-weight: 300 600; font-display: swap; src: url('../fonts/lexend-latin.woff2') format('woff2'); }
@font-face { font-family: 'Geist Mono'; font-style: normal; font-weight: 400 500; font-display: swap; src: url('../fonts/geist-mono-latin.woff2') format('woff2'); }

:root {
  --font: 'Lexend', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'Geist Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --r-xs: 10px; --r-sm: 14px; --r-md: 20px; --r-lg: 28px; --r-xl: 36px; --r-pill: 999px;

  --palla: #fce8c3; --mel: #f0b44c; --ambre: #7a4a00; --llum: #fbf7ef; --nit: #1e160b;
  --bg: #fbf7ef;
  --bg-2: #f4ede0;
  --surface: #ffffff;
  --surface-2: #fdfaf4;
  --ink: #1e160b;
  --ink-2: #473a29;
  --ink-3: #685a47;
  --line: rgba(30, 22, 11, .08);
  --line-2: rgba(30, 22, 11, .14);
  --brand: #7a4a00;          /* accent (botons, enllaços) */
  --brand-ink: #7a4a00;      /* text de marca */
  --on-brand: #ffffff;
  --brand-soft: #fcefd6;
  --brand-soft-2: #f8e0b4;
  --ok: #1d6b4d; --ok-bg: #e2f2ea;
  --warn: #a4480c; --warn-bg: #fbe7d7;
  --bad: #b23a28; --bad-bg: #fbe5e1;
  --info: #3b5ea8; --info-bg: #e7edf9;

  /* Símbol: bombolles en multiplicar sobre clar */
  --sm-1: #fce8c3; --sm-2: #f0b44c; --sm-3: #7a4a00; --sm-o1: 1; --sm-o2: 1; --sm-o3: 1; --sm-blend: multiply;
  --wm-ink: var(--ink); --wm-stay: #7a4a00;

  --shadow-sm: 0 1px 2px rgba(30, 22, 11, .05), 0 4px 14px -6px rgba(30, 22, 11, .10);
  --shadow-md: 0 14px 34px -14px rgba(30, 22, 11, .24);
  --shadow-lg: 0 34px 70px -28px rgba(30, 22, 11, .34);
  --ease: cubic-bezier(.2, .7, .2, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  color-scheme: light;
}

[data-theme='dark'] {
  --bg: #120d06; --bg-2: #1a140a; --surface: #1d160c; --surface-2: #241b0f;
  --ink: #fbf7ef; --ink-2: #e8dcc9; --ink-3: #c2b29b;
  --line: rgba(251, 247, 239, .08); --line-2: rgba(251, 247, 239, .15);
  --brand: #f0b44c; --brand-ink: #f7c66b; --on-brand: #1e160b; --brand-soft: #2b200f; --brand-soft-2: #3a2a12;
  --ok: #8fe0bd; --ok-bg: rgba(29, 107, 77, .25); --warn: #f5a46e; --warn-bg: rgba(164, 72, 12, .25);
  --bad: #f2a596; --bad-bg: rgba(178, 58, 40, .25); --info: #a9c1f2; --info-bg: rgba(59, 94, 168, .25);
  --sm-1: #fce8c3; --sm-2: #f5c46a; --sm-3: #d98f1c; --sm-o2: .9; --sm-o3: .86; --sm-blend: normal;
  --wm-ink: #fff; --wm-stay: #fce8c3;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px -6px rgba(0, 0, 0, .45);
  --shadow-md: 0 14px 34px -14px rgba(0, 0, 0, .6);
  --shadow-lg: 0 34px 70px -28px rgba(0, 0, 0, .75);
  color-scheme: dark;
}
.on-dark { --sm-1: #fce8c3; --sm-2: #f5c46a; --sm-3: #d98f1c; --sm-o2: .9; --sm-o3: .86; --sm-blend: normal; --wm-ink: #fff; --wm-stay: #fce8c3; }

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 96px; overflow-x: clip; }
body { font-family: var(--font); font-size: 16px; font-weight: 300; line-height: 1.6; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; overflow-x: clip; }
img, svg, video { display: block; max-width: 100%; }
img { height: auto; }
a { color: var(--brand-ink); text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
ul, ol { list-style: none; }
h1, h2, h3, h4 { font-weight: 500; line-height: 1.15; letter-spacing: -.025em; }
strong, b { font-weight: 500; }
p { text-wrap: pretty; }
::selection { background: var(--palla); color: var(--nit); }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 3px; border-radius: var(--r-xs); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; left: 16px; top: -80px; z-index: 500; padding: 10px 18px; border-radius: var(--r-pill); background: var(--nit); color: #fff; font-weight: 500; text-decoration: none; transition: top .3s var(--ease); }
.skip-link:focus { top: 16px; }
.mono, .mono-label { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.mono-label { font-size: 11.5px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.muted { color: var(--ink-3); }
.small { font-size: 13.5px; }
.nowrap { white-space: nowrap; }
.inline-form { display: inline-flex; }

/* ---------- Marca ---------- */
.brand { display: inline-flex; align-items: center; gap: .45em; font-size: 22px; line-height: 1; color: var(--wm-ink); }
.brand .mark { width: 1.55em; height: 1.55em; flex: none; }
.mark .b1, .mark .b2, .mark .b3 { mix-blend-mode: var(--sm-blend); }
.mark .b1 { fill: var(--sm-1); fill-opacity: var(--sm-o1); }
.mark .b2 { fill: var(--sm-2); fill-opacity: var(--sm-o2); }
.mark .b3 { fill: var(--sm-3); fill-opacity: var(--sm-o3); }
.mark-g { isolation: isolate; }
.brand-word { font-weight: 450; letter-spacing: -.03em; }
.brand-stay { color: var(--wm-stay); }
.cc-seal { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); text-decoration: none; }
.cc-seal-w { font-family: var(--font); font-size: 12.5px; letter-spacing: -.02em; text-transform: none; color: var(--ink-2); }
.cc-seal-w span { color: #3b7628; }
[data-theme='dark'] .cc-seal-w span, .on-dark .cc-seal-w span { color: #c9ef7e; }
.cc-mark .cc1 { fill: #c9ef7e; } .cc-mark .cc2 { fill: #6fae4b; mix-blend-mode: multiply; } .cc-mark .cc3 { fill: #3b7628; mix-blend-mode: multiply; }
[data-theme='dark'] .cc-mark .cc2, .on-dark .cc-mark .cc2 { fill: #8cc95f; fill-opacity: .88; mix-blend-mode: normal; }
[data-theme='dark'] .cc-mark .cc3, .on-dark .cc-mark .cc3 { fill: #5f9d43; fill-opacity: .85; mix-blend-mode: normal; }
.cc-seal:hover .cc-seal-w { color: var(--ink); }

/* ---------- Botons ---------- */
.btn {
  --b-bg: var(--brand); --b-ink: var(--on-brand); --b-line: transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 20px; border-radius: var(--r-pill);
  background: var(--b-bg); color: var(--b-ink); border: 1px solid var(--b-line);
  font-weight: 500; font-size: 15px; line-height: 1.1; text-decoration: none; white-space: nowrap;
  transition: transform .45s var(--spring), background-color .25s, box-shadow .3s, color .2s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 12px 24px -14px color-mix(in srgb, var(--b-bg) 80%, transparent); }
.btn:active { transform: translateY(0) scale(.98); }
.btn[disabled], .btn.is-busy { opacity: .6; pointer-events: none; }
.btn-primary { --b-bg: var(--brand); --b-ink: var(--on-brand); }
.btn-dark { --b-bg: var(--nit); --b-ink: #fff; }
[data-theme='dark'] .btn-dark { --b-bg: #fbf7ef; --b-ink: var(--nit); }
.btn-soft { --b-bg: var(--brand-soft); --b-ink: var(--brand-ink); }
.btn-ghost { --b-bg: transparent; --b-ink: var(--ink-2); --b-line: var(--line-2); }
.btn-ghost:hover { --b-bg: var(--surface); box-shadow: var(--shadow-sm); }
.btn-danger { --b-bg: var(--bad-bg); --b-ink: var(--bad); }
.btn-whatsapp { --b-bg: #1f8f4e; --b-ink: #fff; }
.btn-sm { min-height: 36px; padding: 7px 14px; font-size: 14px; }
.btn-lg { min-height: 54px; padding: 14px 28px; font-size: 16.5px; }
.btn-block { width: 100%; }
.icon-btn { width: 42px; height: 42px; flex: none; display: inline-grid; place-items: center; border-radius: var(--r-pill); color: var(--ink-2); transition: background-color .2s, color .2s, transform .4s var(--spring); }
.icon-btn:hover { background: var(--bg-2); color: var(--ink); }
.icon-btn.sm { width: 34px; height: 34px; }
.link-btn { display: inline-flex; align-items: center; gap: 6px; color: var(--brand-ink); font-weight: 500; text-decoration: none; border-radius: var(--r-xs); }
.link-btn:hover { text-decoration: underline; }
.lang-switch { display: inline-flex; flex: none; gap: 2px; padding: 3px; border-radius: var(--r-pill); background: var(--ls-bg, var(--bg-2)); }
.lang-switch a { min-width: 36px; height: 32px; display: inline-grid; place-items: center; padding: 0 8px; border-radius: var(--r-pill); font-size: 12.5px; font-weight: 600; letter-spacing: .04em; color: var(--ls-ink, var(--ink-2)); text-decoration: none; transition: background-color .2s, color .2s; }
.lang-switch a:hover { color: var(--ls-ink-on, var(--ink)); }
.lang-switch a[aria-current] { background: var(--ls-on, var(--surface)); color: var(--ls-ink-on, var(--ink)); box-shadow: var(--shadow-sm); }
.lang-switch.on-dark { --ls-bg: rgba(255, 255, 255, .06); --ls-ink: rgba(246, 239, 226, .7); --ls-on: var(--palla); --ls-ink-on: var(--nit); }

/* ---------- Formularis ---------- */
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 14px; font-weight: 500; color: var(--ink-2); }
.req { color: var(--brand-ink); }
.field input, .field select, .field textarea, .input {
  width: 100%; min-height: 46px; padding: 11px 14px; border-radius: var(--r-sm);
  background: var(--surface); border: 1px solid var(--line-2); color: var(--ink);
  font-weight: 400; font-size: 15.5px; transition: border-color .2s, box-shadow .2s;
}
.field textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.field select { appearance: none; padding-right: 40px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b5560' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent); }
.field input[readonly] { background: var(--bg-2); }
.field input[type=color] { padding: 4px; height: 46px; width: 64px; }
.hint { font-size: 13px; color: var(--ink-3); }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.form { display: grid; gap: 16px; }
.form-sec { display: flex; align-items: center; gap: 8px; margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 13px; font-family: var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); }
.form-sec:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.form-foot { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 10px; padding-top: 6px; }
.check { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; }
.check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.check-box { flex: none; width: 24px; height: 24px; margin-top: 1px; display: grid; place-items: center; border-radius: 8px; border: 1.5px solid var(--line-2); background: var(--surface); color: transparent; transition: background-color .2s, border-color .2s, color .2s, transform .35s var(--spring); }
.check input:checked + .check-box { background: var(--brand); border-color: var(--brand); color: var(--on-brand); transform: scale(1.05); }
.check input:focus-visible + .check-box { outline: 3px solid var(--brand); outline-offset: 2px; }
.check > span:last-child { display: grid; font-weight: 400; }
.check small { color: var(--ink-3); font-size: 13px; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; }
.switch input { position: absolute; opacity: 0; }
.switch i { width: 40px; height: 24px; border-radius: 99px; background: var(--line-2); position: relative; transition: background-color .25s; }
.switch i::after { content: ''; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: transform .35s var(--spring); }
.switch input:checked + i { background: var(--brand); }
.switch input:checked + i::after { transform: translateX(16px); }
.switch input:focus-visible + i { outline: 3px solid var(--brand); outline-offset: 2px; }

/* ---------- Xips ---------- */
.chip { display: inline-flex; align-items: center; gap: 6px; flex: none; padding: 3px 10px; border-radius: var(--r-pill); font-size: 12.5px; font-weight: 500; line-height: 1.4; white-space: nowrap; }
.chip i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip-ok { background: var(--ok-bg); color: var(--ok); }
.chip-warn { background: var(--warn-bg); color: var(--warn); }
.chip-bad { background: var(--bad-bg); color: var(--bad); }
.chip-info { background: var(--info-bg); color: var(--info); }
.chip-brand { background: var(--brand-soft); color: var(--brand-ink); }
.chip-muted { background: var(--bg-2); color: var(--ink-3); }

/* ---------- Avisos ---------- */
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: var(--r-md); background: var(--brand-soft); color: var(--ink); font-size: 14.5px; }
.notice > .ico { flex: none; margin-top: 2px; color: var(--brand-ink); }
.notice.warn { background: var(--warn-bg); } .notice.warn > .ico { color: var(--warn); }
.notice.bad { background: var(--bad-bg); } .notice.bad > .ico { color: var(--bad); }
.notice.ok { background: var(--ok-bg); } .notice.ok > .ico { color: var(--ok); }
.notice p + p { margin-top: 4px; }

/* ---------- Toasts i diàleg ---------- */
.toasts { position: fixed; z-index: 600; right: 16px; bottom: 16px; display: grid; gap: 10px; width: min(420px, calc(100vw - 32px)); }
.toast { position: relative; overflow: hidden; display: flex; align-items: flex-start; gap: 12px; padding: 12px 12px 14px; border-radius: 20px; background: color-mix(in srgb, var(--surface) 92%, transparent); -webkit-backdrop-filter: blur(18px) saturate(180%); backdrop-filter: blur(18px) saturate(180%); border: 1px solid var(--line-2); box-shadow: var(--shadow-lg); font-size: 14.5px; font-weight: 400; animation: toastIn .6s var(--spring) both; }
.toast > span:nth-child(2) { flex: 1; padding-top: 5px; }
.toast-ico { width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: 11px; background: var(--brand-soft); color: var(--brand-ink); }
.toast.is-success .toast-ico { background: var(--ok-bg); color: var(--ok); }
.toast.is-error .toast-ico { background: var(--bad-bg); color: var(--bad); }
.toast::after { content: ''; position: absolute; left: 0; bottom: 0; height: 3px; width: 100%; background: var(--brand); transform-origin: left; animation: toastBar 7s linear forwards; }
.toast.is-error::after { background: var(--bad); }
.toast:hover::after { animation-play-state: paused; }
.toast.is-leaving { animation: toastOut .4s var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px) scale(.96); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(30px); } }
@keyframes toastBar { to { transform: scaleX(0); } }
.dialog { margin: auto; width: min(440px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line-2); border-radius: var(--r-lg); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); }
.dialog::backdrop { background: rgba(30, 22, 11, .45); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.dialog[open] { animation: toastIn .45s var(--spring); }
.dialog form, .dialog > div { display: grid; gap: 16px; padding: 24px; }
.dialog-ico { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 16px; background: var(--bad-bg); color: var(--bad); }
.btn-row { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }

/* ---------- Anell i barres ---------- */
.ring { position: relative; display: inline-grid; place-items: center; flex: none; }
.ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 5; }
.ring-bg { stroke: var(--bg-2); }
.ring-fg { stroke-linecap: round; transition: stroke-dashoffset 1s var(--ease); }
.ring-ok .ring-fg { stroke: var(--ok); } .ring-mid .ring-fg { stroke: var(--mel); } .ring-low .ring-fg { stroke: var(--warn); }
.ring b { font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; }
.bar { display: block; height: 8px; border-radius: 99px; background: var(--bg-2); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--mel), var(--brand)); }
.bar.ok > span { background: var(--ok); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
input[type=checkbox], input[type=radio] { accent-color: var(--brand); }

/* Mapa (map.js) */
.map-view { position: absolute; inset: 0; overflow: hidden; touch-action: none; cursor: grab; background: #e9e4dc; }
.map-view.is-drag { cursor: grabbing; }
.map-tiles { position: absolute; left: 0; top: 0; }
.map-tiles img { position: absolute; width: 256px; height: 256px; max-width: none; user-select: none; -webkit-user-drag: none; }
.map-pin { position: absolute; transform: translate(-50%, -100%); display: grid; place-items: center; width: 34px; height: 42px; padding: 0; color: #fff; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .3)); }
.map-pin svg { width: 34px; height: 42px; }
.map-pin.is-home { z-index: 3; }
.map-zoom { position: absolute; right: 10px; top: 10px; display: grid; gap: 6px; z-index: 5; }
.map-zoom button { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; background: #fff; color: #1e160b; box-shadow: 0 2px 8px rgba(0,0,0,.15); font-size: 20px; font-weight: 500; }
.map-attr { position: absolute; right: 6px; bottom: 4px; z-index: 5; padding: 1px 6px; border-radius: 6px; background: rgba(255, 255, 255, .85); color: #333; font-size: 10.5px; }
.map-tip { position: absolute; z-index: 6; transform: translate(-50%, calc(-100% - 46px)); max-width: 220px; padding: 8px 12px; border-radius: 12px; background: #fff; color: #1e160b; box-shadow: var(--shadow-md); font-size: 13.5px; font-weight: 500; text-align: center; }

svg.ico { display: inline-block; vertical-align: -0.2em; flex: none; }
