/* KristianFisker frontend design system. Loaded after all page and plugin CSS. */
:root {
  --ds-brand: var(--kf-blue, #6fa0b4);
  --ds-brand-strong: var(--kf-blue-strong, #4f879e);
  --ds-brand-soft: var(--kf-soft, #dcecf2);
  --ds-accent: var(--kf-accent, #d79623);
  --ds-success: #2f7d55;
  --ds-warning: #9b6512;
  --ds-danger: #b84f4f;
  --ds-info: #397887;
  --ds-font-body: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ds-font-heading: Outfit, Inter, system-ui, sans-serif;
  --ds-text-xs: .75rem;
  --ds-text-sm: .875rem;
  --ds-text-base: 1rem;
  --ds-text-lg: 1.125rem;
  --ds-radius-sm: 6px;
  --ds-radius: 8px;
  --ds-radius-lg: 12px;
  --ds-radius-pill: 999px;
  --ds-space-1: 4px;
  --ds-space-2: 8px;
  --ds-space-3: 12px;
  --ds-space-4: 16px;
  --ds-space-5: 20px;
  --ds-space-6: 24px;
  --ds-space-8: 32px;
  --ds-space-10: 40px;
  --ds-control-height: 46px;
  --ds-content-width: 1180px;
  --ds-ease: 180ms ease;
  --ds-focus: var(--kf-blue, #8fc3d6);
  --ds-focus-ring: 0 0 0 4px color-mix(in srgb, var(--kf-blue, #6fa0b4) 28%, transparent);
}

html[data-theme="dark"] {
  --ds-page: var(--kf-ink, #071313);
  --ds-page-soft: var(--kf-ink-2, #0b1d1f);
  --ds-surface: var(--kf-ink-2, #0c1f24);
  --ds-surface-raised: color-mix(in srgb, var(--kf-ink-2, #0b1d1f) 88%, var(--kf-blue, #6fa0b4));
  --ds-surface-muted: rgba(255, 255, 255, .055);
  --ds-text: #f4f7f4;
  --ds-text-strong: #ffffff;
  --ds-text-muted: #b4c2c1;
  --ds-link: #9acbdd;
  --ds-link-hover: #c7e7f2;
  --ds-border: rgba(196, 224, 224, .18);
  --ds-border-strong: rgba(196, 224, 224, .32);
  --ds-field: #071719;
  --ds-field-text: #f4f7f4;
  --ds-placeholder: #94aaa8;
  --ds-shadow: 0 16px 38px rgba(0, 0, 0, .22);
  --ds-disabled: #73817f;
}

html[data-theme="light"] {
  --ds-page: var(--kf-paper, #f4f8f9);
  --ds-page-soft: var(--kf-soft, #eaf2f4);
  --ds-surface: #ffffff;
  --ds-surface-raised: #ffffff;
  --ds-surface-muted: var(--kf-soft, #edf4f6);
  --ds-text: var(--kf-text, #324b59);
  --ds-text-strong: var(--kf-text, #071c2c);
  --ds-text-muted: var(--kf-muted, #526875);
  --ds-link: #176b92;
  --ds-link-hover: #0f4f6d;
  --ds-border: rgba(9, 38, 53, .14);
  --ds-border-strong: rgba(9, 38, 53, .24);
  --ds-field: #ffffff;
  --ds-field-text: #102a39;
  --ds-placeholder: #71848d;
  --ds-shadow: 0 14px 34px rgba(8, 35, 49, .09);
  --ds-disabled: #7d8d95;
}

/* Modules consume the same semantic decisions while keeping their local API. */
html[data-theme="dark"] .hookup-shell {
  --hu-bg: var(--ds-page);
  --hu-panel: var(--ds-surface);
  --hu-panel-2: var(--ds-surface-raised);
  --hu-card: var(--ds-surface);
  --hu-line: var(--ds-border);
  --hu-border: var(--ds-border);
  --hu-text: var(--ds-text);
  --hu-muted: var(--ds-text-muted);
  --hu-blue: var(--ds-brand);
  --hu-blue-2: var(--ds-brand-strong);
  --hu-blue-text: #d8eef6;
  --hu-danger: var(--ds-danger);
}

html[data-theme="light"] .hookup-shell {
  --hu-bg: var(--ds-page);
  --hu-panel: var(--ds-surface);
  --hu-panel-2: var(--ds-surface-muted);
  --hu-card: var(--ds-surface);
  --hu-line: var(--ds-border);
  --hu-border: var(--ds-border);
  --hu-text: var(--ds-text-strong);
  --hu-muted: var(--ds-text-muted);
  --hu-blue: var(--ds-brand);
  --hu-blue-2: var(--ds-brand-strong);
  --hu-blue-text: #185f7f;
  --hu-danger: var(--ds-danger);
}

html[data-theme] body {
  font-family: var(--ds-font-body);
  text-rendering: optimizeLegibility;
}

html[data-theme] :is(h1, h2, h3, h4, h5, h6) { font-family: var(--ds-font-heading); }
html[data-theme] ::selection { background: var(--ds-brand); color: #071313; }

/* One accessible focus treatment across pages and plugins. */
html[data-theme] :where(a[href], button, input, select, textarea, summary, [role="button"], [tabindex]:not([tabindex="-1"])):focus-visible {
  outline: 3px solid var(--ds-focus);
  outline-offset: 3px;
  box-shadow: var(--ds-focus-ring);
}

/* Controls share sizing and interaction without replacing module layouts. */
html[data-theme] :where(input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
  min-height: var(--ds-control-height);
  border-radius: var(--ds-radius-sm);
  font: inherit;
  transition: border-color var(--ds-ease), box-shadow var(--ds-ease), background-color var(--ds-ease);
}

html[data-theme] :where(input, select, textarea):focus { border-color: var(--ds-brand); }
html[data-theme] :where(input, textarea)::placeholder { color: var(--ds-placeholder); opacity: 1; }
html[data-theme] :where(input[type="checkbox"], input[type="radio"]) { accent-color: var(--ds-brand-strong); }

html[data-theme] :where(button, input, select, textarea, a)[disabled],
html[data-theme] :where(button, input, select, textarea, a)[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: .58;
}

/* Existing button families keep their identity but feel like one family. */
html[data-theme] :where(.btn, .button, .hookup-btn, .new-front-btn, .cb-button, .legal-consent-button) {
  min-height: var(--ds-control-height);
  font-family: var(--ds-font-heading);
  line-height: 1.15;
  transition: color var(--ds-ease), background-color var(--ds-ease), border-color var(--ds-ease), box-shadow var(--ds-ease), transform var(--ds-ease);
}

@media (hover: hover) {
  html[data-theme] :where(.btn, .button, .hookup-btn, .new-front-btn):not([disabled]):hover { transform: translateY(-1px); }
}

/* Shared primitives for new and gradually migrated components. */
.kf-surface {
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius);
  background: var(--ds-surface);
  color: var(--ds-text);
}

.kf-surface--raised { background: var(--ds-surface-raised); box-shadow: var(--ds-shadow); }
.kf-surface--muted { background: var(--ds-surface-muted); }
.kf-text-muted { color: var(--ds-text-muted); }

.kf-status {
  display: flex;
  align-items: flex-start;
  gap: var(--ds-space-3);
  padding: var(--ds-space-4);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius);
  background: var(--ds-surface-muted);
  color: var(--ds-text);
}

.kf-status--success { border-left: 4px solid var(--ds-success); }
.kf-status--warning { border-left: 4px solid var(--ds-warning); }
.kf-status--danger { border-left: 4px solid var(--ds-danger); }
.kf-status--info { border-left: 4px solid var(--ds-info); }

/* Editorial links are identifiable without relying on colour alone. */
html[data-theme] :where(.richtext-content, .news-detail__body, .legal-content__body, .faq-page__answer) a {
  color: var(--ds-link);
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: .18em;
}

html[data-theme] :where(.richtext-content, .news-detail__body, .legal-content__body, .faq-page__answer) a:hover { color: var(--ds-link-hover); }

/* NyFisker uses the same light canvas / dark surface hierarchy as FAQ in dark mode. */
html[data-theme="dark"] .nyfisker {
  --nf-line: var(--ds-border);
  background: #eaf2f1;
  color: #102321;
}

html[data-theme="dark"] .nyfisker :is(.nyfisker-main, .nyfisker-inspiration, .nyfisker-resources) {
  background: #eaf2f1;
  color: #102321;
}

html[data-theme="dark"] .nyfisker .nyfisker-section-title h2,
html[data-theme="dark"] .nyfisker .nyfisker-detail-body :is(h1, h2, h3, h4, strong) {
  color: #102321;
}

html[data-theme="dark"] .nyfisker :is(.nyfisker-guide-card, .nyfisker-video, .nyfisker-resource-grid > div:not(.nyfisker-cta), .nyfisker-empty) {
  border-color: var(--ds-border);
  background: var(--ds-surface);
  color: var(--ds-text);
  box-shadow: var(--ds-shadow);
}

html[data-theme="dark"] .nyfisker :is(.nyfisker-guide-card, .nyfisker-video, .nyfisker-resource-grid > div:not(.nyfisker-cta)) :is(h2, h3, strong, a) {
  color: var(--ds-text-strong);
}

html[data-theme="dark"] .nyfisker :is(.nyfisker-video p, .nyfisker-resource-grid small, .nyfisker-empty) {
  color: var(--ds-text-muted);
}

html[data-theme="dark"] .nyfisker .nyfisker-video em,
html[data-theme="dark"] .nyfisker .nyfisker-resource-grid li,
html[data-theme="dark"] .nyfisker .nyfisker-facebook-list > li > a {
  border-color: var(--ds-border-strong);
}

html[data-theme="dark"] .nyfisker .nyfisker-resource-icon { color: var(--ds-link); }

/* Competition cards used the legacy ink token as both a surface and text. */
html[data-theme="light"] .competition-card :is(h2, h2 a, .competition-card__link, .competition-card__dates span) {
  color: var(--ds-text-strong);
}

html[data-theme="light"] .competition-card :is(p, .competition-card__dates small) {
  color: var(--ds-text-muted);
}

html[data-theme="light"] .competition-card__link {
  border-top-color: var(--ds-border);
}

html[data-theme="light"] .competitions-hero__intro > span,
html[data-theme="light"] .competitions-hero__intro strong {
  color: var(--ds-text-strong);
}

html[data-theme="light"] .news-archive__hero .eyebrow {
  border-color: var(--ds-border-strong) !important;
  background: var(--ds-brand-soft) !important;
  color: var(--ds-text-strong) !important;
}

html[data-theme] .longtail-hero h1 {
  color: #fff;
}

html[data-theme] .longtail-hero p {
  color: rgba(236, 246, 244, .76);
}

/* Dark mode keeps the calm light page canvas and turns content cards dark. */
html[data-theme="dark"] :is(
  .shop-card,
  .competition-card,
  .partner-card,
  .link-card,
  .events-archive-card,
  .store-card,
  .facebook-group-card:not(.is-featured)
) {
  border-color: var(--ds-border);
  background: var(--ds-surface);
  background-image: none;
  color: var(--ds-text);
  box-shadow: var(--ds-shadow);
}

html[data-theme="dark"] :is(
  .shop-card,
  .competition-card,
  .partner-card,
  .link-card,
  .events-archive-card,
  .store-card,
  .facebook-group-card:not(.is-featured)
) :where(h2, h3, h4, h2 a, h3 a, strong) {
  color: var(--ds-text-strong);
}

html[data-theme="dark"] :is(
  .shop-card,
  .competition-card,
  .partner-card,
  .link-card,
  .events-archive-card,
  .store-card,
  .facebook-group-card:not(.is-featured)
) :where(p, small, .richtext-content) {
  color: var(--ds-text-muted);
}

html[data-theme="dark"] .shop-card :is(.shop-card__actions, .shop-card__topline),
html[data-theme="dark"] .competition-card__link,
html[data-theme="dark"] .events-archive-card__meta,
html[data-theme="dark"] .facebook-group-card__actions {
  border-color: var(--ds-border);
}

html[data-theme="dark"] .shop-card :is(.shop-card__actions a, .shop-price, .shop-price span),
html[data-theme="dark"] .competition-card :is(.competition-card__link, .competition-card__dates span),
html[data-theme="dark"] .partner-card__link,
html[data-theme="dark"] .events-archive-card h2 a {
  color: var(--ds-text-strong);
}

html[data-theme="dark"] .partner-card__benefit {
  border-left-color: var(--ds-brand);
  background: var(--ds-surface-muted);
}

html[data-theme="dark"] .facebook-group-card:not(.is-featured) .facebook-group-card__stats span {
  background: var(--ds-surface-muted);
}

html[data-theme="dark"] .link-card > a {
  background: var(--ds-brand);
  color: #071313 !important;
}

/* Legal pages follow the same dark-card-on-light-canvas hierarchy. */
html[data-theme="dark"] .legal-page {
  background: var(--kf-soft, #e9f1f0);
}

html[data-theme="dark"] .legal-nav,
html[data-theme="dark"] .legal-content section {
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-lg);
  background: var(--ds-surface);
  color: var(--ds-text);
  box-shadow: var(--ds-shadow);
}

html[data-theme="dark"] .legal-nav {
  padding: 18px;
}

html[data-theme="dark"] .legal-nav strong,
html[data-theme="dark"] .legal-content :is(h2, h3, h4) {
  color: var(--ds-text-strong);
}

html[data-theme="dark"] .legal-nav a {
  border-bottom-color: var(--ds-border);
  color: var(--ds-text-muted);
}

html[data-theme="dark"] .legal-content section {
  padding: clamp(22px, 4vw, 34px);
}

html[data-theme="dark"] .legal-content section + section {
  margin-top: 18px;
  padding-top: clamp(22px, 4vw, 34px);
  border-top-color: var(--ds-border);
}

html[data-theme="dark"] .legal-content :is(p, li, td) {
  color: var(--ds-text-muted);
}

html[data-theme="dark"] .legal-updated,
html[data-theme="dark"] .legal-table th {
  background: var(--ds-surface-muted);
  color: var(--ds-text-strong);
}

html[data-theme="dark"] .legal-table-wrap,
html[data-theme="dark"] .legal-table :is(th, td) {
  border-color: var(--ds-border);
}

/* Keep the optional install prompt useful without covering mobile forms/content. */
@media (max-width: 680px) {
  .pwa-install {
    left: 10px;
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    gap: 10px;
    padding: 12px 14px;
    border-radius: 12px;
  }

  html[data-theme] .pwa-install strong {
    color: #fff !important;
  }

  .pwa-install > div:first-child {
    gap: 0;
  }

  .pwa-install span {
    display: none;
  }

  .pwa-install__actions {
    gap: 8px;
    justify-content: flex-start;
  }

  .pwa-install__actions .btn,
  .pwa-install__dismiss {
    min-height: 40px;
    padding: 8px 12px;
  }
}

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