/* Arsenal: шрифт українського дизайнера Андрія Шевченка (ліцензія SIL OFL, файл fonts/OFL.txt).
   Файли лежать поруч зі сторінкою в папці fonts: кирилиця й латиниця, звичайний і жирний. */
@font-face {
  font-family: Arsenal; font-style: normal; font-weight: 400; font-display: swap;
  src: url(fonts/arsenal-400-cyrillic.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: Arsenal; font-style: normal; font-weight: 400; font-display: swap;
  src: url(fonts/arsenal-400-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: Arsenal; font-style: normal; font-weight: 700; font-display: swap;
  src: url(fonts/arsenal-700-cyrillic.woff2) format("woff2");
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: Arsenal; font-style: normal; font-weight: 700; font-display: swap;
  src: url(fonts/arsenal-700-latin.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Кольори. Тему задає атрибут data-theme у тегу html.
   Один акцент на тему: синій прапора у світлій, жовтий прапора в темній. */
:root {
  --bg: #F3F6FB;
  --backdrop: #E4EAF3;
  --surface: #FFFFFF;
  --ink: #0A1F44;
  --muted: #4B5B78;
  --line: #D9E0EB;
  --track: #E3E9F2;
  --accent: #0057B7;
  --on-accent: #FFFFFF;
  --tint: #E8F0FA;
  --hover: #F6F9FD;
  --pill-shadow: 0 1px 2px rgba(10, 31, 68, .14);
  --frame-shadow: 0 1px 2px rgba(10, 31, 68, .06), 0 28px 64px -28px rgba(10, 31, 68, .28);
  --scrim: rgba(8, 18, 38, .56);
  --flag-ring: rgba(10, 31, 68, .22);
  color-scheme: light;
}
html[data-theme="dark"] {
  --bg: #0A1220;
  --backdrop: #060B14;
  --surface: #111C30;
  --ink: #EDF1F7;
  --muted: #A1AEC4;
  --line: #22304A;
  --track: #162238;
  --accent: #F3CC45;
  --on-accent: #0A1220;
  --tint: rgba(243, 204, 69, .12);
  --hover: #16233B;
  --pill-shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --frame-shadow: 0 0 0 1px #1A2740, 0 28px 64px -28px rgba(0, 0, 0, .7);
  --scrim: rgba(2, 5, 10, .72);
  --flag-ring: rgba(255, 255, 255, .3);
  color-scheme: dark;
}

/* Скруглення: рамка на великому екрані 28, поверхні 20, кнопки й плитки 14, вкладене 10. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: Arsenal, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
a, button { -webkit-tap-highlight-color: transparent; }
.ic { display: block; flex: none; fill: currentColor; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

/* Обидві мови лежать у розмітці, показується одна. Без JavaScript це українська. */
html[data-lang="en"] .t-uk,
html:not([data-lang="en"]) .t-en { display: none !important; }

.page {
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  padding: 16px 20px 12px;
  padding-top: calc(16px + env(safe-area-inset-top));
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
}

/* Шапка: фото ліворуч, мова праворуч. Перемикач мови без JavaScript схований, бо не працює. */
.top { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; }
.seg { display: none; border-radius: 14px; background: var(--track); }
html.js .seg { display: flex; }
.seg button {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  height: 48px; margin: 0; padding: 0 12px;
  border: 0; border-radius: 14px; background: none; color: var(--muted);
}
.seg button + button { margin-left: -4px; }
.seg button::before {
  content: ""; position: absolute; top: 4px; right: 4px; bottom: 4px; left: 4px;
  border-radius: 10px; background: transparent;
  transition: background-color .2s ease;
}
.seg button > span { position: relative; display: flex; align-items: center; }
/* Прапори намальовано за офіційними пропорціями й кольорами: Україна, а для англійської навпіл США й Велика Британія. */
.flag {
  display: block; flex: none; width: 42px; height: 28px;
  border-radius: 5px; box-shadow: 0 0 0 1px var(--flag-ring);
  opacity: .5; transition: opacity .2s ease;
}
/* Обрана мова: прапор яскравий і на світлій підкладці, інша мова приглушена. */
html:not([data-lang="en"]) [data-set-lang="uk"] .flag,
html[data-lang="en"] [data-set-lang="en"] .flag { opacity: 1; }
html:not([data-lang="en"]) [data-set-lang="uk"]::before,
html[data-lang="en"] [data-set-lang="en"]::before { background: var(--surface); box-shadow: var(--pill-shadow); }

/* Хто це */
.photo {
  position: relative; flex: none; width: 120px; height: 120px;
  border-radius: 20px; overflow: hidden; background: var(--tint);
}
.photo-ini {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 40px; font-weight: 700; color: var(--accent);
}
.photo img { position: relative; display: block; width: 100%; height: 100%; object-fit: cover; }

.name { margin: 0; font-weight: 400; }
.name > span { display: block; }
.sur {
  display: block; font-weight: 700; letter-spacing: -.01em; line-height: 1.06;
  font-size: 34px;
  font-size: clamp(31px, 9.6vw, 40px);
}
.giv {
  display: block; line-height: 1.2;
  font-size: 22px;
  font-size: clamp(21px, 6.2vw, 25px);
}
.t-uk .giv { margin-top: 5px; }
.t-en .giv { margin-bottom: 3px; }
.role { margin: 16px 0 0; font-size: 18px; font-weight: 700; line-height: 1.3; }
.org { margin: 3px 0 0; font-size: 16px; line-height: 1.35; color: var(--muted); }

/* Головна дія */
.cta {
  display: flex; align-items: center; justify-content: center;
  min-height: 56px; margin-top: 22px; padding: 8px 20px;
  border-radius: 14px; background: var(--accent); color: var(--on-accent);
  font-size: 18px; font-weight: 700; line-height: 1.2;
  transition: transform .12s ease;
}
.cta .ic { width: 22px; height: 22px; margin-right: 10px; }

/* Телефон, пошта, сайт */
.list {
  margin: 14px 0 0; padding: 0; list-style: none;
  border: 1px solid var(--line); border-radius: 20px; background: var(--surface); overflow: hidden;
}
.list li + li { border-top: 1px solid var(--line); }
.row {
  display: flex; align-items: center; min-height: 68px; padding: 10px 14px;
  transition: transform .12s ease, background-color .15s ease;
}
.chip {
  flex: none; display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; margin-right: 12px;
  border-radius: 10px; background: var(--tint); color: var(--accent);
}
.chip .ic { width: 22px; height: 22px; }
.row-txt { flex: 1; min-width: 0; }
.row-lab { display: block; font-size: 14px; line-height: 1.3; color: var(--muted); }
.row-val { display: block; font-size: 17px; font-weight: 700; line-height: 1.3; word-wrap: break-word; overflow-wrap: anywhere; }
.row-val.nowrap { white-space: nowrap; }
.row .go { width: 18px; height: 18px; margin-left: 8px; color: var(--muted); }

/* Соцмережі: порядок як у нинішній візитці */
.h2 { margin: 26px 0 10px; font-size: 17px; font-weight: 700; line-height: 1.3; }
.tiles {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-gap: 8px; gap: 8px;
  margin: 0; padding: 0; list-style: none;
}
.tile {
  display: block; min-height: 104px; height: 100%; padding: 12px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface);
  transition: transform .12s ease, background-color .15s ease;
}
.tile .ic { width: 26px; height: 26px; }
.tile-name { display: block; margin-top: 14px; font-size: 16px; font-weight: 700; line-height: 1.2; }
.tile-kind { display: block; margin-top: 2px; font-size: 14px; line-height: 1.3; color: var(--muted); }

/* Поділитися й QR-код. Потрібен JavaScript, без нього сховані. */
.actions {
  display: none; grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-gap: 8px; gap: 8px; margin-top: 16px;
}
html.js .actions { display: grid; }
.btn {
  display: flex; align-items: center; justify-content: center;
  width: 100%; min-height: 52px; margin: 0; padding: 6px 10px;
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface);
  font-size: 16px; font-weight: 700; line-height: 1.2; color: var(--ink);
  transition: transform .12s ease, background-color .15s ease;
}
.btn .ic { width: 20px; height: 20px; margin-right: 8px; color: var(--accent); }

/* Підпис унизу: хто зробив сторінку. Українською веде на devorno.com.ua, англійською на devorno.com. */
.made { margin-top: 10px; text-align: center; }
.made a {
  display: inline-flex; align-items: center; min-height: 48px; padding: 0 14px;
  border-radius: 14px; font-size: 15px; line-height: 1.3; color: var(--muted);
}
.made b { margin-left: .3em; font-weight: 700; color: var(--ink); }

.cta:active, .row:active, .tile:active, .btn:active { transform: scale(.98); }
@media (hover: hover) {
  .row:hover, .tile:hover, .btn:hover { background: var(--hover); }
}

/* Вікно з QR-кодом */
.modal {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 20;
  display: none; align-items: center; justify-content: center;
  padding: 20px; background: var(--scrim);
}
.modal.open { display: flex; }
.sheet {
  position: relative; width: 100%; max-width: 360px; max-height: 100%; overflow: auto;
  padding: 20px; border: 1px solid var(--line); border-radius: 20px;
  background: var(--surface); color: var(--ink);
}
.sheet-title { margin: 0; padding-right: 44px; font-size: 20px; font-weight: 700; line-height: 1.25; }
.sheet-hint { margin: 4px 0 16px; padding-right: 44px; font-size: 16px; line-height: 1.35; color: var(--muted); }
.close {
  position: absolute; top: 8px; right: 8px;
  display: flex; align-items: center; justify-content: center;
  width: 48px; height: 48px; margin: 0; padding: 0;
  border: 0; border-radius: 14px; background: none; color: var(--muted);
}
.close .ic { width: 22px; height: 22px; }
/* QR-код завжди темний на білому, інакше камера його не читає. */
.qr { position: relative; border-radius: 14px; background: #FFFFFF; }
.qr::before { content: ""; display: block; padding-top: 100%; }
.qr-in { position: absolute; top: 14px; right: 14px; bottom: 14px; left: 14px; }
.qr-in img { display: block; width: 100%; height: 100%; }
.qr-wait { width: 100%; height: 100%; border-radius: 10px; background: #E6EBF2; }
.qr-err { display: none; margin: 0; font-size: 16px; line-height: 1.4; }
.modal.failed .qr { display: none; }
.modal.failed .qr-err { display: block; }
.qr-url {
  margin: 14px 0 12px; font-size: 14px; line-height: 1.4; color: var(--muted);
  word-break: break-all; -webkit-user-select: all; user-select: all;
}

/* Коротке повідомлення внизу екрана */
.toast {
  position: fixed; left: 20px; right: 20px; bottom: 24px; z-index: 30;
  display: flex; justify-content: center; pointer-events: none;
  opacity: 0; visibility: hidden; transform: translateY(8px);
  transition: opacity .2s ease, transform .2s ease, visibility 0s linear .2s;
}
.toast.show { opacity: 1; visibility: visible; transform: none; transition: opacity .2s ease, transform .2s ease; }
.toast span {
  display: block; max-width: 400px; padding: 12px 16px; border-radius: 14px;
  background: var(--ink); color: var(--bg); font-size: 16px; font-weight: 700; line-height: 1.3; text-align: center;
}

.sr {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap;
}

/* Вузькі телефони (320 px) */
@media (max-width: 359px) {
  .page { padding-left: 16px; padding-right: 16px; }
  .row { padding-left: 12px; padding-right: 12px; }
  .chip { margin-right: 10px; }
  .tile { padding: 10px; }
  .tile-name { font-size: 15px; }
  .btn { font-size: 15px; }
}

/* Планшет і комп'ютер: та сама картка в рамці по центру */
@media (min-width: 600px) {
  body { background: var(--backdrop); padding: 40px 20px; }
  .page {
    padding: 24px 28px 14px; border-radius: 28px;
    background: var(--bg); box-shadow: var(--frame-shadow);
  }
}

/* М'яка поява. Якщо в телефоні вимкнено анімації, її немає. */
@media (prefers-reduced-motion: no-preference) {
  .rise { animation: rise .5s cubic-bezier(.2, .7, .2, 1) both; }
  .d1 { animation-delay: .05s; }
  .d2 { animation-delay: .1s; }
  .d3 { animation-delay: .15s; }
  .d4 { animation-delay: .2s; }
  .d5 { animation-delay: .25s; }
  .qr-wait { animation: wait 1.2s ease-in-out infinite alternate; }
  @keyframes rise { from { opacity: 0; transform: translateY(8px); } }
  @keyframes wait { from { opacity: 1; } to { opacity: .45; } }
}
@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; }
}
