/* Roofloop design system: tokens, base and core components.
 * Taken from the Roofloop app (app.roofloop.eu) so the website looks like the same product.
 * Use the tokens (var(--…)) instead of raw values; dark mode only redefines tokens, never components. */

@font-face {
  font-family: "Geist";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("./fonts/geist-latin-wght.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("./fonts/inter-latin-wght.woff2") format("woff2");
}

/* Day and night in one place: every colour is light-dark(day, night). Night is
   chosen with the day/night switch (html[data-theme="dark"]), or the device is
   dark and nothing was chosen (data-theme="light" keeps the day).
   --inverse-scheme is the other one: a component with color-scheme: var(--inverse-scheme)
   gets every token's other half (dark shop tiles by day, light ones at night). */
:root { color-scheme: light dark; --page-scheme: light dark; --inverse-scheme: dark; }
@media (prefers-color-scheme: dark) { :root { --inverse-scheme: light; } }
:root[data-theme="light"] { color-scheme: light; --page-scheme: light; --inverse-scheme: dark; }
:root[data-theme="dark"] { color-scheme: dark; --page-scheme: dark; --inverse-scheme: light; }

:root {
  /* Type */
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-brand: "Geist", var(--font);
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --text-2xs: 11px;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 14px;
  --text-md: 15px;
  --text-lg: 16px;
  --text-xl: 20px;
  --text-2xl: 24px;
  --text-3xl: 30px;

  /* Spacing (4px steps; --s-1h and --s-2h are the half steps for tight spots) */
  --s-px: 2px;
  --s-1: 4px;
  --s-1h: 6px;
  --s-2: 8px;
  --s-2h: 10px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;

  /* Shape */
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 12px;
  --r-xl: 16px;
  --r-full: 999px;
  --control: 36px;
  --control-sm: 30px;
  --control-lg: 44px;
  --control-xl: 50px;
  --tile-h: 136px; /* every product tile is this high, so the rows line up */

  /* Motion */
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --bounce: cubic-bezier(0.3, 1.6, 0.5, 1);
  --fast: 0.15s;
  --slow: 0.45s;

  /* Layout */
  --sidebar-w: 248px;
  --topbar-h: 60px;

  /* Surfaces and text */
  --bg: light-dark(#f6f5fb, #1f1c36);
  --surface: light-dark(#ffffff, #272444);
  --surface-2: light-dark(#f1effa, #2f2b50);
  --surface-3: light-dark(#e6e3f5, #39345f);
  --border: light-dark(#e4e1f2, #3b3762);
  --border-strong: light-dark(#cfcbe6, #4f4a7d);
  --text: light-dark(#1d1a33, #f2f0fb);
  --muted: light-dark(#5d5a78, #b8b4d6);
  --subtle: light-dark(#8c89a6, #8d89b0);
  /* Always white: text on a solid colour, and pictures that bring their own design (shop logos, emails). */
  --white: #ffffff;
  --paper: #ffffff;

  /* Accent: a deeper purple. */
  --accent: light-dark(#4f41c4, #bcb5ff);
  --accent-solid: light-dark(#5a4bd1, #6d5fe6);
  --accent-hover: light-dark(#4a3cbf, #7d70f0);
  --accent-soft: light-dark(#eeecfe, #332e66);
  --on-accent: var(--white);

  /* States: red only for errors. */
  --success: light-dark(#15803d, #4ade80);
  --success-solid: #16a34a;
  --success-soft: light-dark(#e7f6ec, #12291b);
  --warning: light-dark(#92600a, #f5c35b);
  --warning-solid: #e0a100;
  --warning-soft: light-dark(#fdf3dc, #33280f);
  --danger: light-dark(#c8302c, #f87171);
  --danger-solid: #dc2626;
  --danger-soft: light-dark(#fdeceb, #3a1a1b);
  --kid: light-dark(#7c3aed, #c4b5fd);
  --kid-soft: light-dark(#f1ebfe, #2b2045);
  --heart: #e05d7c;
  --sun: #e08a4f;
  --sk: light-dark(#e8eaee, #2f2b50);
  --sk-hi: light-dark(#f4f5f7, #39345f);

  /* The palette: periwinkle, lavender, lavender white, cream, peach. */
  --brand-1: #9285f5;
  --brand-2: #bdbbf9;
  --brand-3: #f6f5fb;
  --brand-4: #fbeee0;
  --brand-5: #f8d9c2;
  --logo-petal: light-dark(#3d3399, #f2f0fb);
  --logo-accent: light-dark(#e9a07a, #f8d9c2);
  /* "You are here": peach with deep purple text. */
  --highlight: var(--brand-5);
  --highlight-ink: #1f1a4d;
  /* Neutral labels: lavender. */
  --plum: light-dark(#4b4592, #d3cff5);
  --plum-soft: light-dark(#ecebfd, #332f5a);
  /* A colour of their own for people without a drawing (initials), and the kids' confetti. */
  --person-0: #4f46e5;
  --person-1: #16a34a;
  --person-2: #c2410c;
  --person-3: #9333ea;
  --person-4: #db2777;
  --person-5: #0e7490;
  --person-6: #a16207;
  --confetti-1: #ffd166;
  --confetti-2: #ff7aa2;
  --confetti-3: #6ee7b7;

  /* The sidebar (and sign-in and loading screens): a deep purple gradient, darker than the page
     in both day and night, with a periwinkle glow at the top and a peach glow at the bottom. */
  --side-1: light-dark(#2e2770, #1b1745);
  --side-2: light-dark(#1f1a4d, #120f33);
  --side-3: light-dark(#130f32, #0a0820);
  --glow-top: rgba(146, 133, 245, 0.42);
  --glow-bottom: rgba(248, 217, 194, 0.2);
  --topbar-bg: light-dark(#eeebfd, #29254a); /* a very light purple over the page */
  --page-band-bg: light-dark(#fcfbff, #24213f); /* the page's title and tabs, a shade off the page */
  --dark-backdrop: linear-gradient(160deg, var(--side-1), var(--side-2) 55%, var(--side-3));

  /* Depth */
  --backdrop: light-dark(rgba(17, 19, 24, 0.45), rgba(0, 0, 0, 0.6));
  --shadow-xs: 0 1px 2px light-dark(rgba(16, 24, 40, 0.05), transparent);
  --shadow-sm: 0 1px 2px light-dark(rgba(16, 24, 40, 0.04), rgba(0, 0, 0, 0.3)), 0 1px 3px light-dark(rgba(16, 24, 40, 0.06), transparent);
  --shadow-md: 0 4px 6px -2px light-dark(rgba(16, 24, 40, 0.05), transparent), 0 12px 24px -4px light-dark(rgba(16, 24, 40, 0.12), rgba(0, 0, 0, 0.5));
  --shadow-lg: 0 24px 48px -12px light-dark(rgba(16, 24, 40, 0.28), rgba(0, 0, 0, 0.65));
  --shadow-knob: 0 1px 3px rgba(16, 24, 40, 0.25);
  --shadow-float: 0 30px 60px -20px rgba(3, 2, 20, 0.55); /* a card on the deep purple */
  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent);
}

/* ==== Base ==== */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: var(--text-base)/1.5 var(--font);
  font-feature-settings: "cv11", "ss01";
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1 { font-size: var(--text-2xl); font-weight: 650; line-height: 1.25; margin: 0 0 var(--s-1); letter-spacing: -0.02em; }
h2 { font-size: var(--text-md); font-weight: 600; margin: 0; letter-spacing: -0.01em; }
h3 { font-size: var(--text-md); font-weight: 600; }
p { margin: 0 0 var(--s-3); }
code { font: var(--text-sm) var(--font-mono); background: var(--surface-2); padding: 1px 5px; border-radius: var(--r-sm); border: 1px solid var(--border); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--accent) 25%, transparent); }
.muted { color: var(--muted); }
/* A quiet line of extra information. */
.note { color: var(--muted); font-size: var(--text-sm); }
/* A small uppercase label over a group (sidebar sections, filters, statistics). */
.overline { font-size: var(--text-2xs); font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--subtle); }
.icon { width: 18px; height: 18px; fill: currentColor; flex: none; }

/* ==== Brand: the word mark and the flower ==== */
.brand { display: flex; align-items: center; gap: var(--s-2h); font-family: var(--font-brand); font-weight: 600; font-size: 17px; letter-spacing: -0.025em; color: var(--text); }
.brand:hover { text-decoration: none; }
.logo-mark { width: 28px; height: 28px; flex: none; }
.logo-mark .petal { fill: var(--logo-petal); }
.logo-mark .petal-accent { fill: var(--logo-accent); }
/* On the deep purple (hero, footer, dark sections): a white flower with a peach petal. */
.on-dark { --logo-petal: var(--white); --logo-accent: var(--highlight); color: var(--white); background: var(--dark-backdrop); }

/* ==== Buttons ==== */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-1h);
  height: var(--control); padding: 0 var(--s-3); margin: 0;
  font: inherit; font-weight: 550; color: var(--text); white-space: nowrap; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-md);
  box-shadow: var(--shadow-xs);
  transition: background-color var(--fast), border-color var(--fast), box-shadow var(--fast), color var(--fast);
}
.button:hover { background: var(--surface-2); text-decoration: none; }
.button:active { background: var(--surface-3); }
.button:focus-visible { outline: none; box-shadow: var(--ring); }
.button.primary { background: var(--accent-solid); border-color: transparent; color: var(--on-accent); box-shadow: var(--shadow-xs), inset 0 1px 0 rgba(255, 255, 255, 0.12); }
.button.primary:hover { background: var(--accent-hover); }
.button.danger { color: var(--danger); }
/* Adding something (a family member): green, with a plus. */
.button.success { background: var(--success-solid); border-color: transparent; color: var(--white); box-shadow: var(--shadow-xs), inset 0 1px 0 rgba(255, 255, 255, 0.14); }
.button.success:hover { background: color-mix(in srgb, var(--success-solid) 88%, black); }
.button .icon { width: 16px; height: 16px; fill: currentColor; flex: none; }
.button.danger:hover { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.button.small { height: var(--control-sm); padding: 0 var(--s-2h); font-size: var(--text-sm); border-radius: var(--r-sm); }
.button.block { width: 100%; }
.button[disabled] { opacity: 0.5; cursor: not-allowed; }
.button .caret { font-size: var(--text-2xs); opacity: 0.85; margin-left: 2px; }

.icon-button {
  display: inline-flex; align-items: center; justify-content: center;
  width: var(--control); height: var(--control); border-radius: var(--r-md); cursor: pointer; color: var(--text);
}
button.icon-button { background: transparent; border: 0; padding: 0; font: inherit; }
.icon-button:hover { background: var(--surface-2); text-decoration: none; }
.link-button { border: 0; background: none; padding: 0; font: inherit; font-size: var(--text-sm); color: var(--accent); cursor: pointer; }
.link-button:hover { text-decoration: underline; }
.button-row { display: flex; gap: var(--s-2); }

/* Busy: a spinner in a button whose request is on its way. */
.button.is-busy { position: relative; pointer-events: none; color: transparent !important; --spin: var(--text); }
.button.is-busy > * { visibility: hidden; }
.button.is-busy::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--spin) 25%, transparent); border-top-color: var(--spin);
  animation: spin 0.7s linear infinite;
}
.button.small.is-busy::after { width: 13px; height: 13px; }
.button.primary.is-busy { --spin: var(--on-accent); }
.button.danger.is-busy { --spin: var(--danger); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ==== Fields ==== */
.field { display: flex; flex-direction: column; gap: var(--s-1h); }
.field-row { display: flex; gap: var(--s-3); }
.field-row .field { flex: 1; min-width: 0; }
.field-label { font-weight: 550; font-size: var(--text-sm); }
.field-hint { color: var(--muted); font-size: var(--text-xs); }

input, select, textarea {
  font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-md);
  box-shadow: var(--shadow-xs); transition: border-color var(--fast), box-shadow var(--fast);
}
input, select { height: var(--control); padding: 0 11px; }
textarea { padding: var(--s-2) 11px; }
input::placeholder, textarea::placeholder { color: var(--subtle); }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--border-strong) 60%, var(--muted)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
input[readonly] { background: var(--surface-2); color: var(--muted); }
input[type="checkbox"], input[type="radio"] { height: auto; padding: 0; box-shadow: none; accent-color: var(--accent-solid); }
input[type="checkbox"]:focus, input[type="radio"]:focus { box-shadow: none; }
input[type="file"] { height: auto; padding: var(--s-1h); }

/* ==== Segmented control (a choice between a few options) ==== */
.seg { display: inline-flex; padding: 3px; gap: 2px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); box-shadow: var(--shadow-xs); }
.seg-btn {
  appearance: none; margin: 0; border: 0; background: transparent; box-shadow: none;
  display: inline-flex; align-items: center; gap: var(--s-1h); height: calc(var(--control) - 8px); padding: 0 var(--s-3); border-radius: var(--r-sm);
  font: inherit; font-size: var(--text-sm); font-weight: 550; color: var(--muted); cursor: pointer;
  transition: background-color var(--fast), color var(--fast);
}
.seg-btn:hover { background: var(--surface-2); color: var(--text); }
.seg-btn[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.seg-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ==== Badges ==== */
.badge {
  display: inline-flex; align-items: center; gap: var(--s-1); padding: 1px var(--s-2); border-radius: var(--r-full);
  font-size: var(--text-xs); font-weight: 550; line-height: 18px; white-space: nowrap;
  background: var(--plum-soft); color: var(--plum);
}
.badge-green { background: var(--success-soft); color: var(--success); }
.badge-red { background: var(--danger-soft); color: var(--danger); }
.badge-amber { background: var(--warning-soft); color: var(--warning); }
.badge-kid { background: var(--kid-soft); color: var(--kid); }

/* ==== Cards ==== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); margin-bottom: var(--s-5); }
.card.narrow { max-width: 640px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--border); }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-3) var(--s-5); border-top: 1px solid var(--border); }
.pad { padding: var(--s-5); }
.card .pad.muted { margin: 0; }
.stack { display: flex; flex-direction: column; gap: var(--s-5); }
.stack > .card { margin-bottom: 0; }

/* ==== The flower, moving ==== */

/* Inline the flower as six <g transform="rotate(deg 32 32)"><ellipse class="petal" …/></g>, add class "bloom bloom-unfold"
   (opens once) or "bloom bloom-loop" (a loading pulse). */
.bloom { overflow: visible; }
.bloom .petal { transform-box: view-box; transform-origin: 32px 32px; }
.bloom g:nth-child(1) .petal { --i: 5; } .bloom g:nth-child(2) .petal { --i: 0; } .bloom g:nth-child(3) .petal { --i: 1; }
.bloom g:nth-child(4) .petal { --i: 2; } .bloom g:nth-child(5) .petal { --i: 3; } .bloom g:nth-child(6) .petal { --i: 4; }
.bloom-unfold { animation: logo-turn 1s cubic-bezier(0.3, 1.2, 0.5, 1) both; }
@keyframes logo-turn { from { rotate: -60deg; } }
.bloom-unfold .petal { animation: petal-open 0.5s cubic-bezier(0.3, 1.5, 0.5, 1) calc(0.1s + var(--i) * 0.09s) both; }
@keyframes petal-open { from { transform: scale(0); opacity: 0; } }
.bloom-loop .petal { animation: petal-pulse 1.2s ease-in-out calc(var(--i) * 0.2s - 1.2s) infinite; }
@keyframes petal-pulse { 0%, 100% { opacity: 0.3; transform: scale(0.88); } 30% { opacity: 1; transform: none; } }

/* A logo that turns a little every nine seconds, and a slowly drifting glow behind a dark section.
   Only transform and opacity move (cheap for the processor). */
.logo-nudge { will-change: transform; animation: logo-nudge 9s cubic-bezier(0.3, 1.4, 0.5, 1) 3s infinite; }
@keyframes logo-nudge {
  0%, 84%, 100% { transform: none; }
  88% { transform: rotate(-14deg) scale(1.06); }
  93% { transform: rotate(8deg) scale(1.03); }
}
/* A dark section's glow (add class "glow" next to "on-dark"): a soft light drifts slowly over the
   gradient (25 s there, 25 s back). */
.glow { position: relative; overflow: hidden; isolation: isolate; }
.glow::before {
  content: ""; position: absolute; inset: -25%; z-index: -1; pointer-events: none;
  background:
    radial-gradient(35% 30% at 30% 35%, var(--glow-top), transparent 70%),
    radial-gradient(30% 28% at 72% 70%, var(--glow-bottom), transparent 70%);
  will-change: transform, opacity;
  animation: auth-glow 25s ease-in-out infinite alternate;
}
@keyframes auth-glow {
  0% { transform: translate3d(-6%, -4%, 0) scale(1); opacity: 0.55; }
  50% { opacity: 1; }
  100% { transform: translate3d(6%, 5%, 0) scale(1.15); opacity: 0.7; }
}

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