/* Properstar kit: base styles and core components.
 * Uses only variables from tokens.css. Class names follow Bootstrap,
 * because Puzzle is built on Bootstrap and developers will recognise them.
 */

/* ---------- Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: var(--leading-body);
  color: var(--text-primary);
  background: var(--surface-page);
  -webkit-font-smoothing: antialiased;
}
img, svg, video { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- Type (headings are sentence case, never bold-styled on top) ---------- */
h1, h2, h3, h4, .display {
  font-family: var(--font-display);
  line-height: var(--leading-tight);
  color: var(--text-primary);
  letter-spacing: -0.01em;
  text-wrap: balance;
}
.display { font-size: clamp(36px, 6vw, var(--text-5xl)); font-weight: var(--weight-heavy); letter-spacing: -0.02em; }
h1 { font-size: clamp(30px, 4.5vw, var(--text-4xl)); font-weight: var(--weight-bold); }
h2 { font-size: clamp(24px, 3.2vw, var(--text-3xl)); font-weight: var(--weight-bold); }
h3 { font-size: var(--text-xl); font-weight: var(--weight-semibold); line-height: var(--leading-snug); }
h4 { font-size: var(--text-md); font-weight: var(--weight-semibold); line-height: var(--leading-snug); }
p { text-wrap: pretty; }
.lead { font-size: var(--text-lg); color: var(--text-secondary); }
.small, small { font-size: var(--text-sm); }
.muted { color: var(--text-muted); }
.text-brand { color: var(--properstar-500); }
.eyebrow {
  display: inline-block;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-brand);
}

/* PLZ text styles. Display headings grow at 768px and 1280px, like the Figma 320/768/1280 versions. */
.display-4, .display-6 { font-weight: var(--weight-heavy); letter-spacing: 0; color: var(--text-primary); }
.display-4 { font-size: 32px; line-height: 39px; }
.display-6 { font-size: 27px; line-height: 32px; }
@media (min-width: 768px) { .display-4 { font-size: 44px; line-height: 53px; } .display-6 { font-size: 34px; line-height: 40px; } }
@media (min-width: 1280px) { .display-4 { font-size: 56px; line-height: 67px; } .display-6 { font-size: 40px; line-height: 48px; } }
.h3 { font: var(--font-h3); } .h4 { font: var(--font-h4); } .h5 { font: var(--font-h5); }
.body-1 { font: var(--font-body-1); } .body-2 { font: var(--font-body-2); } .body-3 { font: var(--font-body-3); }
.caption { font: var(--font-caption); }

/* Links: default style only, never bold (PDS content rules) */
a { color: var(--link); text-decoration: underline; text-underline-offset: 2px; }
a:hover { color: var(--link-hover); }
:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: var(--radius-sm); }

/* ---------- Layout ---------- */
.container { width: 100%; max-width: var(--container); margin-inline: auto; padding-inline: var(--gutter); }
.section { padding-block: var(--space-8); }
.section-tight { padding-block: var(--space-7); }
.section-subtle { background: var(--surface-subtle); }
.section-brand { background: var(--surface-brand-soft); }
.section-dark { background: var(--surface-dark); color: var(--white); }
.section-dark h1, .section-dark h2, .section-dark h3 { color: var(--white); }
.stack > * + * { margin-top: var(--space-4); }
.grid { display: grid; gap: var(--space-5); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.center { text-align: center; }
.center .lead, .center p { margin-inline: auto; }
.measure { max-width: 60ch; }

/* ---------- Buttons (PLZ "Button": Inter Medium, 6px radius) ----------
 * Sizes: .btn-lg = Button 1 (48px, 20px text), default = Button 2 (40px, 16px), .btn-sm = Button 3 (31px, 14px).
 * Shapes: .btn-block, .btn-pill, .btn-icon (icon only, round). States: [disabled], .is-loading.
 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--spacing-md);
  min-width: 40px; height: 40px; padding: 0 var(--spacing-lg);
  border: 1px solid transparent; border-radius: var(--radius-3);
  font: var(--font-button-2); text-decoration: none; white-space: nowrap; cursor: pointer;
  background: var(--button-secondary); color: var(--text-primary);
  transition: background-color var(--duration) var(--ease-out), border-color var(--duration) var(--ease-out), color var(--duration) var(--ease-out);
}
.btn svg { width: 1.15em; height: 1.15em; flex: none; }
.btn-lg { height: 48px; padding: 0 var(--spacing-xl); font: var(--font-button-1); }
.btn-sm { height: 31px; min-width: 31px; padding: 0 var(--spacing-md); font: var(--font-button-3); gap: var(--spacing-sm); }
.btn-block { display: flex; width: 100%; }
.btn-pill { border-radius: var(--radius-pill); }
.btn-icon { width: 40px; padding: 0; border-radius: 50%; }
.btn-icon.btn-lg { width: 48px; }
.btn-icon.btn-sm { width: 31px; }
.btn:hover { text-decoration: none; }

.btn-primary { background: var(--button-primary); color: var(--text-on-brand); }
.btn-primary:hover { background: var(--button-primary-hover); color: var(--text-on-brand); }
.btn-primary:active { background: var(--button-primary-active); }
.btn-secondary { background: var(--button-secondary); color: var(--text-primary); }
.btn-secondary:hover { background: var(--button-secondary-hover); color: var(--text-primary); }
.btn-secondary:active { background: var(--button-secondary-active); }
.btn-outline { background: var(--white); color: var(--text-primary); border-color: var(--border-brand); }
.btn-outline:hover, .btn-outline.is-active { background: var(--button-active); color: var(--text-primary); }
.btn-link { background: none; color: var(--link); min-width: 0; padding-inline: var(--spacing-sm); }
.btn-link:hover { color: var(--link-hover); background: none; }
.btn-danger { background: var(--button-danger); color: var(--white); }
.btn-success { background: var(--button-success); color: var(--text-primary); }
.btn-favorite { background: var(--button-favorite); color: var(--white); }
.btn-info { background: var(--button-info); color: var(--white); }
.btn-warning { background: var(--button-warning); color: var(--yellow-900); }
.btn-purple { background: var(--button-purple); color: var(--white); }
.btn-white { background: var(--button-white); color: var(--text-primary); box-shadow: var(--shadow-button); }
.btn-dark { background: var(--button-dark); color: var(--white); }
.btn-danger:hover, .btn-success:hover, .btn-favorite:hover, .btn-info:hover, .btn-warning:hover, .btn-purple:hover, .btn-dark:hover { filter: brightness(0.92); }
.btn-white:hover { background: var(--grey-200); color: var(--text-primary); }
/* Outlined colour variants: white fill, coloured border and text */
.btn-outline-danger { background: var(--white); color: var(--text-danger); border-color: var(--border-red); }
.btn-outline-success { background: var(--white); color: var(--green-800); border-color: var(--green-800); }
.btn-outline-favorite { background: var(--white); color: var(--pink-500); border-color: var(--pink-500); }
.btn-outline-warning { background: var(--white); color: var(--yellow-800); border-color: var(--border-yellow); }
.btn-outline-purple { background: var(--white); color: var(--text-ai); border-color: var(--border-purple); }
.btn-soft-purple { background: var(--purple-50); color: var(--text-ai); border-color: var(--border-purple); }
.btn[disabled], .btn.is-disabled { background: var(--button-secondary); color: var(--text-disabled); border-color: transparent; box-shadow: none; filter: none; cursor: not-allowed; }
.btn-primary[disabled], .btn-primary.is-disabled { background: var(--button-primary-disabled); color: var(--white); }
.btn.is-loading { pointer-events: none; }
.btn.is-loading::before { content: ""; width: 1em; height: 1em; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Forms (PLZ "Input field": label, 40px field, helper text) ---------- */
.field { display: grid; gap: var(--spacing-sm); }
.field .label { font: var(--font-body-3); color: var(--text-secondary); }
.form-control {
  width: 100%; height: 40px; padding: 0 var(--spacing-lg);
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-3);
  font: var(--font-body-2); color: var(--text-primary);
  transition: border-color var(--duration) var(--ease-out);
}
.form-control-lg { height: 48px; font: var(--font-body-1); }
.form-control-sm { height: 31px; padding: 0 var(--spacing-md); font: var(--font-body-3); }
select.form-control { appearance: none; padding-right: 40px; background: var(--white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23333' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center / 18px; }
textarea.form-control { height: auto; min-height: 120px; padding-block: var(--spacing-md); }
.form-control::placeholder { color: var(--text-placeholder); }
.form-control:focus { outline: none; border-color: var(--border-brand); }
.form-control.is-invalid { border-color: var(--border-red); color: var(--text-danger); }
.form-control:disabled { background: var(--surface-subtle); color: var(--text-disabled); }
.hint { font: var(--font-body-3); color: var(--text-secondary); }
.hint.is-invalid { color: var(--text-danger); }

/* Checkbox, radio and toggle (PLZ "Checkbox", "Radio button", "Toggle") */
.check { display: inline-flex; align-items: center; gap: var(--spacing-md); font: var(--font-body-2); cursor: pointer; }
.check input { appearance: none; flex: none; width: 20px; height: 20px; margin: 0; border: 1px solid var(--border-strong); border-radius: var(--radius-1); background: var(--white); display: grid; place-items: center; cursor: pointer; }
.check input[type="radio"] { border-radius: 50%; }
.check input:checked { background: var(--button-primary); border-color: var(--button-primary); }
.check input[type="checkbox"]:checked::after { content: ""; width: 10px; height: 5px; border-left: 2px solid var(--white); border-bottom: 2px solid var(--white); transform: translateY(-1px) rotate(-45deg); }
.check input[type="radio"]:checked { background: var(--white); border: 6px solid var(--button-primary); }
.check input:disabled { background: var(--grey-200); border-color: var(--grey-300); cursor: not-allowed; }
.check input:disabled:checked { background: var(--grey-400); border-color: var(--grey-400); }
.toggle { display: inline-flex; align-items: center; gap: var(--spacing-md); font: var(--font-body-2); cursor: pointer; }
.toggle input { appearance: none; flex: none; position: relative; width: 50px; height: 30px; margin: 0; border-radius: var(--radius-pill); background: var(--grey-600); cursor: pointer; transition: background-color var(--duration) var(--ease-out); }
.toggle input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--white); transition: transform var(--duration) var(--ease-out); }
.toggle input:checked { background: var(--green-500); }
.toggle input:checked::after { transform: translateX(20px); }
.toggle input:disabled { opacity: 0.4; cursor: not-allowed; }
.toggle.toggle-sm input { width: 40px; height: 20px; }
.toggle.toggle-sm input::after { top: 2px; left: 2px; width: 16px; height: 16px; }
.toggle.toggle-sm input:checked::after { transform: translateX(20px); }

/* ---------- Cards ---------- */
.card {
  background: var(--white); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: var(--space-5); overflow: hidden;
}
.card-media { margin: calc(var(--space-5) * -1) calc(var(--space-5) * -1) var(--space-4); aspect-ratio: 16 / 10; background: var(--surface-muted); }
.card-media img { width: 100%; height: 100%; object-fit: cover; }
.card-title { font-size: var(--text-lg); font-weight: var(--weight-semibold); margin-bottom: var(--space-1); }
.card-icon {
  display: grid; place-items: center; width: 44px; height: 44px; margin-bottom: var(--space-4);
  border-radius: var(--radius-md); background: var(--surface-brand-soft); color: var(--properstar-700);
}
.card-icon svg { width: 22px; height: 22px; }
.card.is-featured { border: 2px solid var(--border-brand); }

/* ---------- Pills and tags (for PLZ "Badge" use .badge below) ---------- */
.pill {
  display: inline-flex; align-items: center; gap: var(--space-1);
  height: 28px; padding: 0 var(--space-3); border-radius: var(--radius-pill);
  font-size: var(--text-xs); font-weight: var(--weight-medium);
  background: var(--grey-200); color: var(--text-primary);
}
.pill-brand { background: var(--properstar-50); color: var(--properstar-900); }
.pill-success { background: var(--green-50); color: var(--green-900); }
.pill-warning { background: var(--yellow-50); color: var(--yellow-900); }
.pill-danger { background: var(--red-50); color: var(--red-800); }

/* ---------- Price (PDS: ISO 4217 code before the number, comma delimiter) ---------- */
.price { font-weight: var(--weight-bold); font-variant-numeric: tabular-nums; }

/* ---------- Top navigation ---------- */
.site-nav { position: sticky; top: 0; z-index: 10; background: var(--white); border-bottom: 1px solid var(--border); }
.site-nav .container { display: flex; align-items: center; justify-content: space-between; gap: var(--space-5); height: 64px; }
.site-nav .logo { display: inline-flex; height: 28px; }
.site-nav .logo img { height: 100%; width: auto; }
.nav-links { display: flex; gap: var(--space-5); list-style: none; padding: 0; }
.nav-links a { color: var(--text-primary); text-decoration: none; font-size: var(--text-sm); font-weight: var(--weight-medium); }
.nav-links a:hover { color: var(--link); }
@media (max-width: 760px) { .nav-links { display: none; } }

/* ---------- Footer ---------- */
.site-footer { background: var(--surface-dark); color: var(--grey-400); padding-block: var(--space-7) var(--space-5); font-size: var(--text-sm); }
.site-footer h4 { color: var(--white); margin-bottom: var(--space-3); font-size: var(--text-sm); }
.site-footer a { color: var(--grey-300); text-decoration: none; display: block; padding-block: 2px; }
.site-footer a:hover { color: var(--white); }
.site-footer .logo { height: 26px; margin-bottom: var(--space-4); }
.site-footer .legal { margin-top: var(--space-6); padding-top: var(--space-4); border-top: 1px solid var(--grey-700); display: flex; flex-wrap: wrap; justify-content: space-between; gap: var(--space-3); }

/* ---------- Motion helper: add .reveal, kit.js adds .is-visible on scroll ---------- */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity var(--duration-slow) var(--ease-out), transform var(--duration-slow) var(--ease-out); }
.reveal.is-visible { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; } }

/* ======================================================================
 * PLZ library "0 UI" components. Names match the Figma component sets.
 * ====================================================================== */

/* Badge/Default: Black, Danger, Grey, Info, Primary Properstar, Success, Warning */
.badge { display: inline-flex; align-items: center; gap: var(--spacing-sm); height: 20px; padding: 0 var(--spacing-sm); border-radius: var(--radius-1); font: var(--font-body-3); background: var(--grey-200); color: var(--grey-800); white-space: nowrap; }
.badge-grey { color: var(--grey-700); }
.badge-danger { background: var(--red-100); color: var(--red-800); }
.badge-info { background: var(--blue-100); color: var(--blue-700); }
.badge-primary { background: var(--properstar-50); color: var(--properstar-800); }
.badge-success { background: var(--green-100); color: var(--green-800); }
.badge-warning { background: var(--yellow-100); color: var(--yellow-800); }
.badge-ai { background: var(--purple-50); color: var(--text-ai); }

/* Status and Bullet: a 10px dot before a label */
.status { display: inline-flex; align-items: center; gap: var(--spacing-md); font: var(--font-body-3); color: var(--text-primary); }
.status::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--grey-400); flex: none; }
.status-success::before { background: var(--green-500); }
.status-warning::before { background: var(--yellow-500); }
.status-info::before { background: var(--blue-500); }
.status-danger::before { background: var(--red-500); }
.status-brand::before { background: var(--properstar-500); }

/* Counter: small number pill */
.counter { display: inline-grid; place-items: center; min-width: 20px; height: 19px; padding: 0 6px; border-radius: var(--radius-pill); font: 500 12px/1 var(--font-sans); background: var(--grey-200); color: var(--grey-800); }
.counter-brand { background: var(--properstar-700); color: var(--white); }
.counter-danger { background: var(--red-500); color: var(--white); }

/* Alert and toast: Danger, Info, Success, Warning. Toasts are bold and float with a shadow. */
.alert { display: flex; align-items: center; gap: var(--spacing-md); padding: var(--spacing-lg); border-radius: var(--radius-4); font: var(--font-body-2); background: var(--blue-50); color: var(--blue-800); }
.alert > svg { width: 20px; height: 20px; flex: none; }
.alert .close { margin-left: auto; display: grid; place-items: center; width: 20px; height: 20px; padding: 0; border: 0; background: none; color: inherit; cursor: pointer; }
.alert-danger { background: var(--red-100); color: var(--red-800); }
.alert-success { background: var(--green-100); color: var(--green-800); }
.alert-warning { background: var(--yellow-100); color: var(--yellow-800); }
.alert.toast { font-weight: var(--weight-bold); box-shadow: var(--shadow-content); }

/* Navs/Horizontal/Tabs: underline tabs, Body 2, active in brand */
.tabs { display: flex; gap: var(--spacing-xl); border-bottom: 1px solid var(--grey-300); overflow-x: auto; scrollbar-width: none; }
.tabs a, .tabs button { flex: none; display: inline-flex; align-items: center; height: 40px; padding: 0; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px; background: none; font: var(--font-body-2); color: var(--text-primary); text-decoration: none; cursor: pointer; }
.tabs [aria-selected="true"], .tabs .is-active { color: var(--text-brand); border-bottom-color: var(--border-brand); }
.tabs.tabs-block a, .tabs.tabs-block button { flex: 1; justify-content: center; }

/* Navs/Nav-link/Pill: Default, Active, On picture, Selected, Counter, Hover */
.nav-pill { display: inline-flex; align-items: center; gap: var(--spacing-sm); height: 31px; padding: 0 var(--spacing-md); border: 1px solid var(--border); border-radius: var(--radius-pill); background: var(--white); font: var(--font-button-3); color: var(--text-primary); text-decoration: none; cursor: pointer; }
.nav-pill svg { width: 16px; height: 16px; }
.nav-pill:hover { background: var(--button-secondary); color: var(--text-primary); }
.nav-pill.is-active { background: var(--button-active); border-color: var(--border-brand); }
.nav-pill.is-selected { background: var(--button-secondary-hover); border-color: var(--button-secondary-hover); }
.nav-pill.on-picture { border-color: transparent; box-shadow: var(--shadow-content); }

/* Separator, with or without OR */
.separator { display: flex; align-items: center; gap: var(--spacing-lg); font: var(--font-body-3); color: var(--text-secondary); }
.separator::before, .separator::after { content: ""; flex: 1; height: 1px; background: var(--grey-300); }
.separator:empty { gap: 0; }

/* Hero without search form: photo with a slanted bottom edge, white Display 4 title */
.hero-photo { position: relative; display: flex; align-items: center; min-height: 263px; padding: var(--spacing-2xl) var(--gutter) 64px; color: var(--white); background: var(--grey-700) center / cover no-repeat; clip-path: polygon(0 0, 100% 0, 100% 85%, 0 100%); }
.hero-photo::before { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0)); }
.hero-photo > * { position: relative; width: 100%; max-width: var(--container); margin-inline: auto; }
.hero-photo h1 { color: var(--white); }
.hero-photo p { font: var(--font-body-1); margin-top: var(--spacing-md); }
@media (min-width: 768px) { .hero-photo { min-height: 373px; } }

/* Hero, text in a box: white card over an illustration */
.hero-box { display: grid; align-items: center; padding: var(--spacing-lg) var(--gutter); }
.hero-box .media { aspect-ratio: 16 / 10; border-radius: var(--radius-6); background: var(--surface-muted) center / cover no-repeat; overflow: hidden; }
.hero-box .box { position: relative; margin: -32px var(--spacing-md) 0; padding: var(--spacing-lg) var(--spacing-md); background: var(--white); border-radius: var(--radius-4); box-shadow: var(--shadow-modal); display: grid; gap: var(--spacing-md); }
.hero-box .box p { font: var(--font-body-2); }
.hero-box .actions { display: grid; gap: var(--spacing-md); margin-top: var(--spacing-md); }
@media (min-width: 768px) {
  .hero-box { grid-template-columns: 5fr 7fr; max-width: var(--container); margin-inline: auto; }
  .hero-box .media { grid-column: 2; grid-row: 1; aspect-ratio: auto; height: 100%; min-height: 330px; }
  .hero-box .box { grid-column: 1 / span 1; grid-row: 1; margin: 0 -60px 0 0; padding: var(--spacing-xl); border-radius: var(--radius-6); z-index: 1; }
  .hero-box .box p { font: var(--font-body-1); }
  .hero-box .actions { display: flex; flex-wrap: wrap; }
}
