/* Karvelo deep link site. Visual language of karvelo.com: Inter headings,
   royal blue actions, black store badges, soft blue tiles, floating cards.
   Mobile-first. No inline styles anywhere (CSP style-src 'self'). */

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

:root {
  --royal: #0066FF;
  --royal-deep: #0052CC;
  --sky: #0FB9FB;            /* logo blue */
  --navy: #0B1D4F;
  --ink: #0F172A;
  --text: #334155;
  --muted: #64748B;
  --tile: #EAF2FF;
  --line: #E2E8F0;
  --ok: #16A34A;
  --ok-tile: #E8F7EE;
  --warn-bg: #FFF5E0;
  --warn-ink: #92400E;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* kept for the admin styles below */
  --brand: var(--sky);
  --brand-ink: #04293A;
  --brand-soft: #E3F6FE;
  --border: var(--line);
  --card: #FFFFFF;
  --bg: #FFFFFF;
  --radius: 14px;
  --focus: var(--royal);
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: #fff; color: var(--text); font: 16px/1.55 var(--font); }
h1 { color: var(--ink); font-weight: 800; letter-spacing: -0.022em; line-height: 1.15; font-size: 30px; margin: 0 0 8px; }
h2 { color: var(--ink); font-size: 17px; line-height: 1.3; margin: 0 0 6px; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }

/* ----------------------------------------------------------------- Page shell */
.page { max-width: 480px; margin: 0 auto; padding: 0 16px 24px; min-height: 100vh; display: flex; flex-direction: column; }
.site-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 4px; }
.brand { display: inline-block; border-radius: 8px; text-decoration: none; }
.brand-logo { display: block; width: 116px; height: auto; }
.brand-text { font-size: 24px; font-weight: 800; color: var(--ink); }
.official { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px;
            background: var(--ok-tile); color: var(--ok); font-size: 12.5px; font-weight: 600; }
.official svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.site-footer { margin-top: auto; padding-top: 24px; text-align: center; color: var(--muted); font-size: 13px; }
.site-footer p { margin: 0; }

.lead { margin: 0 0 18px; }
.hint { color: var(--muted); font-size: 13.5px; margin: 14px 2px 0; }
.error-code { margin: 0; font-size: 56px; font-weight: 800; color: var(--royal); line-height: 1; letter-spacing: -0.03em; }

/* Generic white card (home, 404, admin) */
.card { background: #fff; border-radius: 24px; padding: 24px 20px; box-shadow: 0 24px 50px -32px rgba(11, 29, 79, 0.45), 0 0 0 1px rgba(11, 29, 79, 0.05); }

/* -------------------------------------------------------------------- Buttons */
.btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 54px; padding: 14px 22px;
       margin: 0 0 12px; border: 2px solid transparent; border-radius: 16px; font: 700 16px/1.2 var(--font);
       text-decoration: none; cursor: pointer; transition: transform 0.15s ease, background-color 0.15s ease; }
.btn:focus-visible, .store-badge:focus-visible, .brand:focus-visible, .copy-input:focus-visible, .route-list a:focus-visible {
  outline: 3px solid var(--sky); outline-offset: 3px; }
.btn:active, .store-badge:active { transform: scale(0.98); }
.btn-primary { background: var(--royal); color: #fff; box-shadow: 0 10px 22px -10px rgba(0, 102, 255, 0.65); }
.btn-primary:hover { background: var(--royal-deep); }
.btn-secondary { background: #fff; color: var(--royal-deep); border-color: #BFD5FF; }
.btn-secondary:hover { background: var(--tile); }
.btn-small { width: auto; min-height: 44px; margin: 0; padding: 8px 16px; font-size: 14.5px; border-radius: 12px; flex: none; }

/* Store badges: black, two-line label */
.store-badges { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.store-badge { display: flex; align-items: center; gap: 10px; min-height: 54px; padding: 8px 14px; border-radius: 14px;
         background: #0A0A0A; color: #fff; text-decoration: none; transition: transform 0.15s ease; }
.store-badge svg { width: 22px; height: 22px; flex: none; }
.store-badge small { display: block; font-size: 10.5px; line-height: 1.1; opacity: 0.85; }
.store-badge b { display: block; font-size: 15px; line-height: 1.2; font-weight: 650; }

/* ------------------------------------------------------------- Landing (HP) */
.landing { display: flex; flex-direction: column; }

/* Stage: soft blue wash, drifting circle, dot grid, floating phone + chips */
.stage { position: relative; height: 372px; margin: 0 -16px; overflow: hidden; background: linear-gradient(180deg, #F2F7FF 0%, #FFFFFF 100%); }
.stage::before { content: ""; position: absolute; width: 260px; height: 260px; border-radius: 50%; right: -90px; top: -70px;
                 background: #DDE9FF; animation: drift 14s ease-in-out infinite; }
.stage::after { content: ""; position: absolute; left: 14px; bottom: 34px; width: 120px; height: 84px; opacity: 0.55;
                background: radial-gradient(#9DBDFF 1.3px, transparent 1.6px) 0 0 / 14px 14px; }

.phone { position: absolute; left: 50%; top: 26px; z-index: 2; width: 182px; height: 364px; margin-left: -91px; padding: 8px;
         border-radius: 34px; background: var(--ink); box-shadow: 0 30px 50px -24px rgba(11, 29, 79, 0.55);
         animation: rise 0.7s cubic-bezier(0.2, 0.8, 0.2, 1) both; }
.screen { position: relative; height: 100%; overflow: hidden; border-radius: 27px; background: linear-gradient(165deg, var(--royal), var(--sky)); }
.notch { position: absolute; z-index: 3; left: 50%; top: 0; width: 64px; height: 18px; margin-left: -32px; border-radius: 0 0 12px 12px; background: var(--ink); }
.screen-shot { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top; }
.screen-splash { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 20px; }
.screen-store, .screen-qr { position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; align-items: center; justify-content: center;
                            gap: 10px; padding: 24px 14px; text-align: center; }
.screen-store { color: #fff; background: linear-gradient(165deg, rgba(0, 102, 255, 0.94), rgba(15, 185, 251, 0.94)); opacity: 0; transition: opacity 0.35s ease; }
.screen-store b { font-size: 17px; font-weight: 750; }
.screen-store small { font-size: 11.5px; line-height: 1.35; opacity: 0.92; }
.screen-store-icon { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; background: rgba(255, 255, 255, 0.2); }
.screen-store-icon svg { width: 26px; height: 26px; }
.screen-qr { display: none; background: #fff; color: var(--muted); }
.screen-qr small { font-size: 11.5px; line-height: 1.35; }

/* Floating info chips */
.chip { position: absolute; z-index: 3; display: flex; align-items: center; gap: 9px; padding: 8px 12px 8px 8px; border-radius: 14px;
        background: #fff; box-shadow: 0 14px 28px -14px rgba(15, 23, 42, 0.35); color: var(--muted); font-size: 11.5px; line-height: 1.25;
        max-width: 176px; animation: popIn 0.45s cubic-bezier(0.2, 0.8, 0.2, 1.2) backwards, float 5.5s ease-in-out infinite; }
.chip b { display: block; color: var(--ink); font-size: 13px; font-weight: 700; overflow-wrap: anywhere; }
.chip > span:last-child { min-width: 0; }
.tile { width: 30px; height: 30px; flex: none; border-radius: 9px; display: grid; place-items: center; background: var(--tile); color: var(--royal); }
.tile-ok { background: var(--ok-tile); color: var(--ok); }
.chip-1 { left: 12px; top: 58px; animation-delay: 0.45s, 1s; }
.chip-2 { right: 10px; top: 104px; animation-delay: 0.6s, 2.2s; }
.chip-3 { left: 16px; top: 292px; animation-delay: 0.75s, 1.6s; }

/* Text and actions */
.content { padding: 6px 6px 0; }
.status { display: flex; align-items: center; gap: 6px; min-height: 48px; padding: 10px 14px; margin: 0 0 14px; border-radius: 14px;
          background: var(--tile); color: var(--royal-deep); font-weight: 600; font-size: 15px; }
.dots { display: inline-flex; gap: 4px; margin-left: 4px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.25; animation: blink 1.1s infinite; }
.dots i:nth-child(2) { animation-delay: 0.18s; }
.dots i:nth-child(3) { animation-delay: 0.36s; }

.notice { display: flex; gap: 12px; padding: 14px; margin: 0 0 14px; border-radius: 16px; background: var(--warn-bg); color: #713F12; font-size: 14.5px; }
.notice .tile { width: 36px; height: 36px; border-radius: 11px; background: #fff; color: var(--warn-ink); }
.notice h2 { color: #422006; font-size: 15px; margin: 0 0 2px; }
.notice p { margin: 0 0 6px; }
.notice ol { margin: 0 0 10px; padding-left: 20px; }

.desktop-block { margin: 0 0 14px; }
.desktop-block p { margin: 0 0 12px; }
.copy-row { display: flex; gap: 8px; margin: 0 0 12px; }
.copy-input { flex: 1; min-width: 0; min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px;
              font: 14px var(--font); color: var(--text); background: #F8FAFC; }

/* States set by landing.js */
.landing[data-phase="store"] .screen-store { opacity: 1; }
.landing[data-phase="store"] .status { background: var(--warn-bg); color: var(--warn-ink); }
.landing[data-action="in-app"] .status, .landing[data-action="desktop"] .status { display: none; }
.landing[data-action="desktop"] .screen-qr { display: flex; }

.qr { display: block; width: 220px; height: 220px; margin: 0 auto 12px; image-rendering: pixelated; border: 1px solid var(--line); border-radius: 8px; }
.screen-qr .qr { width: 138px; height: 138px; margin: 0; border: 0; border-radius: 0; }

/* Desktop / wide screens: text left, phone right */
@media (min-width: 900px) {
  .page-landing { max-width: 1120px; padding: 0 40px 32px; }
  .page-landing .site-header { padding: 22px 0; }
  .landing { display: grid; grid-template-columns: 1fr 520px; gap: 40px; align-items: center; }
  .landing .content { order: 1; padding: 0; max-width: 520px; }
  .landing .stage { order: 2; height: 520px; margin: 0; border-radius: 32px; }
  .landing .phone { top: 60px; animation-name: riseLarge; }
  .chip-1 { left: 40px; top: 110px; } .chip-2 { right: 36px; top: 250px; } .chip-3 { left: 56px; top: 380px; }
  .landing h1 { font-size: 50px; line-height: 1.08; }
  .landing .lead { font-size: 18px; }
}

/* --------------------------------------------------------------- Home / 404 */
.page > .card { margin-top: 8px; }
.route-list { margin-top: 18px; text-align: left; }
.route-list h2 { font-size: 16px; }
.route-list ul { list-style: none; margin: 0; padding: 0; }
.route-list li { border-top: 1px solid var(--line); }
.route-list a { display: flex; align-items: center; justify-content: space-between; min-height: 50px; padding: 8px 4px;
                color: var(--ink); font-weight: 600; text-decoration: none; }
.route-list a::after { content: "\203A"; color: var(--royal); font-size: 22px; }

/* Off-screen helpers (no inline styles allowed by CSP) */
.visually-hidden, .clipboard-buffer { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden;
                                      clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* ------------------------------------------------------------------ Motion */
@keyframes drift { 50% { transform: translate(-24px, 18px) scale(1.06); } }
@keyframes rise { from { opacity: 0; transform: translateY(26px); } }
@keyframes riseLarge { from { opacity: 0; transform: translateY(26px) scale(1.12); } to { transform: scale(1.12); } }
@keyframes popIn { from { opacity: 0; transform: translateY(10px) scale(0.92); } }
@keyframes float { 50% { transform: translateY(-7px); } }
@keyframes blink { 40% { opacity: 1; transform: translateY(-2px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (prefers-reduced-motion: reduce) and (min-width: 900px) {
  .landing .phone { transform: scale(1.12); }
}

/* ------------------------------------------------------------------ Admin */
.page-wide { max-width: 960px; }
.card.admin { text-align: left; }
.admin-nav { margin: 0 0 16px; color: var(--muted); }
.admin-nav a { color: var(--brand-ink); font-weight: 600; }
.admin-section { border-top: 1px solid var(--border); padding: 16px 0 8px; }
.admin-section h2 { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.admin-section h3 { font-size: 15px; margin: 16px 0 6px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: 0.3px; }
.badge-ok { background: #DCFCE7; color: #14532D; }
.badge-fail { background: #FEE2E2; color: #7F1D1D; }
.badge-warn { background: #FEF3C7; color: #78350F; }
.alert { border-radius: var(--radius); padding: 12px 16px; margin: 0 0 12px; }
.alert ul { margin: 6px 0; padding-left: 20px; }
.alert-error { background: #FEF2F2; border: 1px solid #FCA5A5; color: #7F1D1D; }
.alert-warn { background: #FFF8E6; border: 1px solid #F5D68A; color: #78350F; }
.kv { width: 100%; border-collapse: collapse; margin: 0 0 12px; font-size: 14px; }
.kv th, .kv td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.kv th { width: 40%; color: var(--muted); font-weight: 600; }
.kv code, .cmd code { overflow-wrap: anywhere; }
.issues { list-style: none; padding: 0; margin: 0 0 12px; font-size: 14px; }
.issues li { padding: 6px 0; border-bottom: 1px solid var(--border); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.cmd { display: flex; gap: 8px; align-items: center; background: #F8FBFD; border: 1px solid var(--border); border-radius: 8px; padding: 6px 6px 6px 12px; margin: 0 0 8px; }
.cmd code { flex: 1; min-width: 0; }
.builder-form { display: grid; gap: 6px; margin: 0 0 16px; }
.builder-form label { font-weight: 600; font-size: 14px; margin-top: 6px; }
.builder-form input, .builder-form select { min-height: 44px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font: inherit; background: #FFFFFF; color: var(--text); }
.builder-form input:focus-visible, .builder-form select:focus-visible, .admin-nav a:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.builder-form .btn { margin-top: 12px; }
.builder-result .qr { margin: 0; }
details { border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 12px; margin: 0 0 12px; }
summary { cursor: pointer; font-weight: 700; min-height: 32px; }
