/* Central theme stylesheet for static apps (modern + minimal + cafe brown).
  Keep overrides low-specificity so page styles can extend safely. */

:root {
  --safe-top: env(safe-area-inset-top);
  --safe-right: env(safe-area-inset-right);
  --safe-bottom: env(safe-area-inset-bottom);
  --safe-left: env(safe-area-inset-left);

  --color-background: #f7f4ef;
  --color-surface: #fcfaf6;
  --color-surface-elevated: #ffffff;
  --color-text-primary: #171513;
  --color-text-secondary: #706860;
  --color-text-muted: #968d85;
  --color-border: rgba(34, 28, 24, 0.1);
  --color-border-strong: rgba(34, 28, 24, 0.18);
  --color-coffee: #68452f;
  --color-coffee-dark: #422b1f;
  --color-coffee-light: #b99174;
  --color-sage: #aeb7a0;
  --color-terracotta: #b76e52;
  --color-butter: #d8bd75;
  --color-success: #54705b;
  --color-error: #9e4d43;
  --color-disabled: rgba(23, 21, 19, 0.38);

  --bg: var(--color-background);
  --surface: var(--color-surface);
  --surface-muted: #f2ece4;
  --surface-elevated: color-mix(in srgb, var(--color-surface-elevated) 92%, #f4ede4 8%);
  --text: var(--color-text-primary);
  --text-muted: var(--color-text-secondary);
  --border: var(--color-border);
  --border-subtle: rgba(34, 28, 24, 0.08);
  --shadow: rgba(30, 24, 20, 0.08);
  --brand: var(--color-coffee);
  --brand-700: var(--color-coffee-dark);
  --brand-press: #36231a;
  --brand-50: #efe5d8;
  --on-brand: #fffdfa;
  --danger: var(--color-error);
  --danger-bg: rgba(183, 110, 82, 0.12);
  --success: var(--color-success);
  --success-bg: rgba(84, 112, 91, 0.12);
  --info: #6c7f93;
  --info-bg: rgba(174, 183, 160, 0.16);

  --radius: 28px;
  --radius-sm: 18px;
  --radius-xs: 10px;
  --radius-md: 18px;
  --radius-lg: 28px;
  --radius-card: 22px;
  --radius-pill: 999px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --space-8: 64px;
  --space-9: 96px;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-xxl: 48px;

  --font-sans:
    "Geist", "Inter", "Manrope", system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  --font-display:
    "Geist", "Inter", "Manrope", system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-mono:
    ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;

  --font-size-display: clamp(3rem, 10vw, 5.5rem);
  --font-size-h1: clamp(2.5rem, 8vw, 4.5rem);
  --font-size-h2: clamp(2rem, 6vw, 3.25rem);
  --font-size-h3: clamp(1.5rem, 4.5vw, 2.25rem);
  --font-size-body-large: 1.25rem;
  --font-size-body: 1rem;
  --font-size-small: 0.875rem;
  --font-size-label: 0.75rem;

  --shadow-sm: 0 1px 2px rgba(30, 24, 20, 0.03);
  --shadow-md: 0 8px 24px rgba(30, 24, 20, 0.04);
  --shadow-lg: 0 18px 44px rgba(30, 24, 20, 0.08);
  --shadow-card:
    0 1px 2px rgba(30, 24, 20, 0.03),
    0 8px 24px rgba(30, 24, 20, 0.04);
  --shadow-card-hover:
    0 2px 8px rgba(30, 24, 20, 0.05),
    0 16px 32px rgba(30, 24, 20, 0.08);

  --focus: rgba(66, 43, 31, 0.14);
  --focus-ring: rgba(104, 69, 47, 0.22);
  --coffee-ink: var(--color-coffee);
  --coffee-ink-soft: var(--color-coffee-light);
  --coffee-paper: #f1e7da;
  --coffee-paper-deep: #e8d9c6;
  --coffee-line: rgba(104, 69, 47, 0.14);
  --soft-button-bg: rgba(255, 253, 250, 0.72);
  --soft-button-border: rgba(34, 28, 24, 0.1);
  --soft-button-text: var(--text);
  --soft-button-bg-hover: rgba(255, 255, 255, 0.92);
  --notice-surface: rgba(255, 253, 249, 0.82);

  --motion-fast: 120ms;
  --motion-normal: 200ms;
  --motion-slow: 300ms;
  --motion-ease: cubic-bezier(0.2, 0.8, 0.2, 1);

  --color-primary: var(--brand);
  --color-primary-hover: var(--brand-700);
  --color-primary-pressed: var(--brand-press);
  --color-border-subtle: var(--border-subtle);
}

/* Inverted (café) theme: same layout tokens, swapped canvas/ink */
.theme-invert {
  --bg: #211712;
  --surface: #2a1d18;
  --surface-muted: rgba(255, 248, 241, 0.05);

  --text: rgba(255, 247, 239, 0.94);
  --text-muted: rgba(242, 228, 216, 0.68);

  --border: rgba(255, 241, 233, 0.14);
  --focus: rgba(255, 244, 236, 0.14);

  --brand: #f5ecdf;
  --brand-700: #fff8f0;
  --brand-50: rgba(255, 248, 241, 0.08);
  --on-brand: #241812;
  --soft-button-bg: var(--coffee-paper);
  --soft-button-border: var(--coffee-line);
  --soft-button-text: #2b1c14;
  --soft-button-bg-hover: var(--coffee-paper-deep);
  --notice-surface: rgba(242, 230, 215, 0.94);
}

* {
  box-sizing: border-box;
}

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

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

.kk-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  text-decoration: none;
  color: inherit;
}

.kk-brand:hover {
  color: inherit;
}

.kk-brand:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--coffee-line) 72%, transparent);
  border-radius: 18px;
}

.kk-brandMark {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.58), rgba(255, 255, 255, 0) 54%),
    linear-gradient(180deg, var(--coffee-paper), var(--coffee-paper-deep));
  border: 1px solid var(--coffee-line);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.66) inset,
    0 -1px 0 rgba(72, 46, 30, 0.05) inset;
  display: grid;
  place-items: center;
  overflow: hidden;
  position: relative;
}

.kk-brandMark::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 24% 20%, rgba(255, 255, 255, 0.36), rgba(255, 255, 255, 0) 26%),
    repeating-linear-gradient(
      -18deg,
      rgba(107, 69, 44, 0.028) 0 1px,
      rgba(255, 255, 255, 0) 1px 7px
    );
  pointer-events: none;
  mix-blend-mode: multiply;
}

.kk-brandMark img {
  width: 100%;
  height: 100%;
  display: block;
}

.kk-brandText {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.kk-brandKicker {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.kk-brandWord {
  font-family: var(--font-display);
  font-size: clamp(22px, 3vw, 30px);
  line-height: 0.96;
  letter-spacing: -0.04em;
  color: var(--text);
}

.kk-brandSub {
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-muted);
}

.kk-brand.is-hero .kk-brandMark {
  width: 52px;
  height: 52px;
  border-radius: 18px;
}

.kk-brand.is-hero .kk-brandWord {
  font-size: clamp(30px, 4vw, 38px);
}

.kk-brand.is-hero .kk-brandKicker {
  font-size: 11px;
}

.theme-invert .kk-brandWord,
.theme-invert .kk-brandKicker,
.theme-invert .kk-brandSub {
  color: var(--text);
}

.theme-invert .kk-brandMark {
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.12) inset,
    0 -1px 0 rgba(0, 0, 0, 0.22) inset;
}

.theme-invert .kk-brandMark::after {
  background:
    radial-gradient(circle at 24% 20%, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0) 26%),
    repeating-linear-gradient(
      -18deg,
      rgba(255, 255, 255, 0.04) 0 1px,
      rgba(255, 255, 255, 0) 1px 7px
    );
}

/* Many legacy pages set a purple gradient on body. Force the theme background. */
body {
  background: var(--bg) !important;
}

a {
  color: var(--brand);
  text-underline-offset: 3px;
}

a:hover {
  color: var(--brand-700);
}

/* Common page container used across many static pages */
.card {
  /* Avoid “cards everywhere”: default to a simple section wrapper */
  background:
    linear-gradient(180deg, rgba(255, 252, 248, 0.96), rgba(245, 237, 228, 0.92));
  border: 1px solid rgba(17, 17, 17, 0.08);
  border-radius: var(--radius);
  box-shadow:
    0 18px 40px rgba(68, 41, 22, 0.08),
    0 1px 0 rgba(255, 255, 255, 0.74) inset;
  transition:
    transform var(--motion-normal) var(--motion-ease),
    box-shadow var(--motion-normal) var(--motion-ease),
    border-color var(--motion-normal) var(--motion-ease),
    background var(--motion-normal) var(--motion-ease);
}

h1,
h2,
h3 {
  color: var(--text);
  letter-spacing: -0.015em;
}

/* Legacy pages often use gradient text on headings; keep it simple. */
h1,
h2,
h3 {
  background: none !important;
  -webkit-text-fill-color: currentColor !important;
}

.subtitle {
  color: var(--text-muted);
}

label {
  color: var(--text);
}

small,
.small {
  color: var(--text-muted);
}

input,
select,
textarea {
  color: var(--text);
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(17, 17, 17, 0.1);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.66) inset,
    0 8px 18px rgba(68, 41, 22, 0.04);
  transition:
    border-color var(--motion-normal) var(--motion-ease),
    box-shadow var(--motion-normal) var(--motion-ease),
    background var(--motion-normal) var(--motion-ease),
    transform var(--motion-fast) var(--motion-ease);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: rgba(107, 69, 44, 0.42);
  box-shadow: 0 0 0 3px var(--focus);
}

button {
  background: var(--brand);
  color: var(--on-brand, #fff);
  border: 1px solid transparent;
  border-radius: 18px;
  padding: 12px 16px;
  font-weight: 700;
  letter-spacing: 0;
  transition:
    transform var(--motion-fast) var(--motion-ease),
    box-shadow var(--motion-normal) var(--motion-ease),
    background var(--motion-normal) var(--motion-ease),
    border-color var(--motion-normal) var(--motion-ease),
    opacity var(--motion-normal) var(--motion-ease);
}

/* Some legacy pages still have inline purple button backgrounds.
   Keep primary buttons on-brand, but allow explicit variants to override. */
button:not(.secondary):not(.ghost):not(.miniBtn):not(.passMain) {
  background: var(--brand) !important;
  box-shadow: none !important;
  text-transform: none;
}

button:not(.secondary):not(.ghost):not(.miniBtn):not(.passMain):hover {
  background: var(--brand-700) !important;
}

/* Common legacy accent colors */
[style*="#667eea"],
[style*="#764ba2"] {
  /* Minimal: don't try to parse; we override common components instead. */
}

/* Common legacy components */
.spinner {
  border-top-color: var(--brand) !important;
}

.scan-overlay {
  border-color: var(--brand) !important;
}

button.secondary,
button.ghost {
  background: var(--soft-button-bg) !important;
  color: var(--soft-button-text) !important;
  border: 1px solid var(--soft-button-border);
}

/* Modern utility + layout helpers */
.container {
  max-width: 920px;
  margin: 0 auto;
  padding: var(--space-5);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.row.wrap {
  flex-wrap: wrap;
}

.muted {
  color: var(--text-muted) !important;
}

.mono {
  font-family: var(--font-mono);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.56);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: auto;
  cursor: pointer;
  min-height: 52px;
  padding: 13px 18px;
  border-radius: 18px;
  border: 1px solid transparent;
  font-weight: 800;
  text-decoration: none;
  touch-action: manipulation;
  box-shadow:
    0 10px 22px rgba(68, 41, 22, 0.06),
    0 1px 0 rgba(255, 255, 255, 0.2) inset;
  transition:
    transform var(--motion-fast) var(--motion-ease),
    box-shadow var(--motion-normal) var(--motion-ease),
    background var(--motion-normal) var(--motion-ease),
    border-color var(--motion-normal) var(--motion-ease),
    color var(--motion-normal) var(--motion-ease),
    opacity var(--motion-normal) var(--motion-ease);
}

.btn.primary {
  background: var(--brand) !important;
  color: var(--on-brand, #fff);
}

.btn.secondary {
  background: var(--soft-button-bg) !important;
  color: var(--soft-button-text) !important;
  border: 1px solid var(--soft-button-border);
}

.btn-secondary,
button.btn-secondary {
  background: var(--soft-button-bg) !important;
  color: var(--soft-button-text) !important;
  border: 1px solid var(--soft-button-border) !important;
}

button.secondary:hover,
button.ghost:hover,
.btn.secondary:hover,
.btn-secondary:hover,
button.btn-secondary:hover {
  background: var(--soft-button-bg-hover) !important;
  color: var(--soft-button-text) !important;
}

button:hover,
.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-card-hover);
}

button:active,
.btn:active {
  transform: scale(0.98);
}

button:focus-visible,
.btn:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
a:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 3px;
  box-shadow: 0 0 0 4px rgba(107, 69, 44, 0.14);
}

button:disabled,
.btn:disabled,
.btn[aria-disabled="true"],
.btn[aria-busy="true"] {
  opacity: 0.58;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none;
}

/* Clean top navigation (Holm-like): text links on white */
.topbar {
  background: var(--bg);
}

/* Header should not look like boxed UI */
.topbar .btn,
.topbar a.btn,
.topbar button.btn {
  background: transparent !important;
  border: none !important;
  padding: 8px 0;
  min-height: auto;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text) !important;
}

.topbar .btn.secondary {
  color: var(--text-muted) !important;
}

.topbar .badge {
  border: none;
  background: transparent;
  padding: 0;
}

.topbar .nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 26px;
  flex-wrap: wrap;
}

.topbar .nav .btn {
  background: transparent !important;
  border: none !important;
}

.topbar .nav .btn.secondary {
  color: var(--text-muted) !important;
}

/* Many pages mark the current location by omitting `.secondary`. */
.topbar .nav .btn:not(.secondary) {
  border-bottom: 2px solid var(--text) !important;
}

/* Clean top menu (Holm-like): centered, uppercase, underline active
   Used by customer + cafe pages for consistent navigation. */
.topMenu {
  flex: 1 0 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 26px;
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: none;
}

.topMenuBtn {
  flex: 0 0 auto;
  width: auto;
  min-width: 0;
  display: inline-block;
  background: transparent !important;
  border: none !important;
  padding: 8px 0;
  cursor: pointer;
  touch-action: manipulation;
  color: var(--text) !important;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  box-shadow: none !important;
  text-decoration: none;
}

/* Global theme styles `button.ghost` with a border; ensure top menu is borderless. */
button.topMenuBtn.ghost {
  border: none !important;
}

/* Avoid horizontal overflow on small phones */
@media (max-width: 420px) {
  .topMenu {
    justify-content: center;
    gap: 18px;
    flex-wrap: wrap;
  }

  .topMenuBtn {
    width: auto;
    flex: 0 0 auto;
  }
}

.topMenuBtn .ico {
  display: none;
}

.topMenuBtn .lbl {
  display: block;
  text-align: left;
  font-size: inherit;
  font-weight: inherit;
  margin: 0;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topMenuBtn.active {
  border-bottom: 2px solid var(--text) !important;
}

.topMenuBtn:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 4px;
}

.topMenuBtn.active .lbl {
  color: var(--text);
}

.btn:active {
  transform: none;
}

.notice {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--notice-surface);
  box-shadow:
    0 12px 28px rgba(68, 41, 22, 0.08),
    0 1px 0 rgba(255, 255, 255, 0.58) inset;
  color: var(--text);
}

.notice.danger {
  background: var(--danger-bg);
  border-color: rgba(180, 35, 24, 0.25);
  color: var(--danger);
}

.notice.success {
  background: var(--success-bg);
  border-color: rgba(6, 118, 71, 0.25);
  color: var(--success);
}

.notice.info {
  background: var(--info-bg);
  border-color: rgba(23, 92, 211, 0.25);
  color: var(--info);
}

/* Utility: keep card pages centered nicely */
.page {
  min-height: 100vh;
  padding: 20px;
}

.page .card {
  max-width: 560px;
  margin: 40px auto;
  padding: 32px;
}

/* App layout primitives (keep names distinct to avoid page-specific collisions) */
.appTop {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.appGrid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
}

@media (min-width: 760px) {
  .appGrid.cols2 {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
}

.appPanel {
  padding: var(--space-5);
  border-radius: var(--radius);
  border: 1px solid rgba(17, 17, 17, 0.08);
  background:
    linear-gradient(180deg, rgba(255, 252, 248, 0.96), rgba(245, 237, 228, 0.92));
  box-shadow:
    0 18px 40px rgba(68, 41, 22, 0.08),
    0 1px 0 rgba(255, 255, 255, 0.74) inset;
}

.appCtas {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-top: var(--space-4);
}

.appCtas > a,
.appCtas > button {
  flex: 1;
  min-width: 180px;
}
