/* ============================================================
   DIGITAL CARD — STYLES
   No colour is hard-coded here. card.js writes the profile's
   palette into the variables below, and every rule derives from
   them. Change a palette in data/profiles.js and the whole card
   follows — buttons, borders, glass, glows, share sheet.
   ============================================================ */

:root {
  /* Fallback palette (gold). Overwritten at runtime. */
  --bg: #080d16;
  --surface: #0e1b31;
  --accent: #c78f42;
  --accent-soft: #f0cd8e;
  --text: #f3ecdc;
  --muted: #9db0c9;
  --on-accent: #120c03;

  --font-serif: 'Cormorant Garamond', Georgia, serif;
  --font-sans: Montserrat, Helvetica, Arial, sans-serif;
  --font-arabic: Cairo, 'Noto Naskh Arabic', 'Segoe UI', Tahoma, sans-serif;

  --max-w: 430px;
  --hero-h: 300px;
  --hero-pos: center 30%;
  --hero-veil: 1;

  /* Derived from the accent so one palette value tints everything */
  --line: color-mix(in srgb, var(--accent) 22%, transparent);
  --line-strong: color-mix(in srgb, var(--accent) 72%, transparent);
  --accent-wash: color-mix(in srgb, var(--accent) 12%, transparent);
  --glass-top: rgba(255, 255, 255, .07);
  --glass-bottom: rgba(255, 255, 255, .02);
  --glass-edge: rgba(255, 255, 255, .06);
  --glass-shadow: rgba(0, 0, 0, .45);
}

/* Light palettes need the glass to go dark-on-light instead */
[data-mode="light"] {
  --glass-top: rgba(0, 0, 0, .035);
  --glass-bottom: rgba(0, 0, 0, .012);
  --glass-edge: rgba(255, 255, 255, .8);
  --glass-shadow: rgba(0, 0, 0, .09);
}

*,
*::before,
*::after { box-sizing: border-box; }

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
}

body {
  font-family: var(--font-sans);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  background-image:
    radial-gradient(500px 360px at 100% 55%, color-mix(in srgb, var(--accent) 10%, transparent), transparent 70%),
    radial-gradient(520px 420px at 0% 85%, color-mix(in srgb, var(--surface) 60%, transparent), transparent 70%);
  background-attachment: fixed;
}

html[lang="ar"] body,
html[lang="ar"] .serif {
  font-family: var(--font-arabic);
}

.serif { font-family: var(--font-serif); }
html[lang="ar"] .serif { font-family: var(--font-arabic); }

/* ------------------------------------------------------------
   Shell
   ------------------------------------------------------------ */
.card {
  position: relative;
  width: 100%;
  max-width: var(--max-w);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

/* ------------------------------------------------------------
   Hero — the part that changes per user
   ------------------------------------------------------------ */
.hero {
  position: relative;
  height: var(--hero-h);
  overflow: hidden;
  isolation: isolate;
}

.hero__img {
  position: absolute;
  inset: 0;
  background-image: var(--hero-url, none);
  background-size: cover;
  background-position: var(--hero-pos, center 30%);
  background-repeat: no-repeat;
  z-index: 0;
}

/* No photo supplied: build a hero out of the palette instead */
.hero--plain .hero__img {
  background-image:
    radial-gradient(420px 320px at 78% 18%, color-mix(in srgb, var(--accent) 38%, transparent), transparent 70%),
    radial-gradient(520px 380px at 12% 82%, color-mix(in srgb, var(--surface) 85%, transparent), transparent 72%),
    linear-gradient(150deg, var(--surface), var(--bg) 70%);
}

.hero__veil {
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: var(--hero-veil, 1);
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--bg) 62%, transparent) 0%,
    color-mix(in srgb, var(--bg) 38%, transparent) 34%,
    color-mix(in srgb, var(--bg) 78%, transparent) 60%,
    var(--bg) 72%,
    var(--bg) 100%
  );
}

.hero__bar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: max(1rem, env(safe-area-inset-top)) 18px 0;
}

/* Brand lockup: logo (or monogram) + company name + tagline */
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand__logo {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  object-fit: cover;
  flex: 0 0 auto;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .4);
}

.brand__mono {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 34px;
  letter-spacing: .04em;
  color: var(--accent-soft);
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  border: 1px solid var(--line-strong);
}

.brand__lockup {
  min-width: 0;
  padding-left: 12px;
  border-left: 1px solid var(--line-strong);
  line-height: 1;
}

.brand__name {
  font-family: var(--font-serif);
  font-weight: 600;
  /* Scales down on narrow phones so the wordmark never clips */
  font-size: clamp(26px, 8.4vw, 40px);
  letter-spacing: .04em;
  color: var(--accent-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand__tagline {
  margin-top: 7px;
  font-size: 8px;
  line-height: 1.4;
  font-weight: 600;
  letter-spacing: .085em;
  color: var(--accent-soft);
  text-shadow: 0 1px 6px color-mix(in srgb, var(--bg) 95%, transparent), 0 0 2px color-mix(in srgb, var(--bg) 85%, transparent);
  /* Wraps to a second line on narrow phones instead of clipping */
  white-space: normal;
  overflow-wrap: break-word;
}

.hero__actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex: 0 0 auto;
}

/* ------------------------------------------------------------
   Small glass pills (share / language)
   ------------------------------------------------------------ */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  color: var(--accent-soft);
  background: linear-gradient(145deg, var(--glass-top), var(--glass-bottom));
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: transform .15s ease, border-color .2s ease;
}

.pill--sm {
  font-size: 10.5px;
  font-weight: 600;
  padding: 6px 12px;
}

.pill svg {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
}

/* ------------------------------------------------------------
   Main column
   ------------------------------------------------------------ */
.main {
  position: relative;
  z-index: 3;
  margin-top: -96px;
  padding: 0 20px max(2rem, env(safe-area-inset-bottom));
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* ------------------------------------------------------------
   Identity block
   ------------------------------------------------------------ */
.identity { text-align: center; }

.identity__name {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 38px;
  line-height: 1.05;
  color: var(--text);
  text-wrap: balance;
}

.identity__position {
  margin: 12px 0 0;
  font-family: var(--font-serif);
  font-size: 21px;
  font-weight: 600;
  color: var(--accent-soft);
}

.identity__company {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 18.5px;
  color: color-mix(in srgb, var(--text) 82%, transparent);
}

.identity__motto {
  margin: 16px 0 0;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 18px;
  line-height: 1.35;
  color: var(--accent);
}

/* ------------------------------------------------------------
   Glass panel
   ------------------------------------------------------------ */
.glass {
  background: linear-gradient(145deg, var(--glass-top), var(--glass-bottom));
  border: 1px solid var(--line);
  border-radius: 16px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 10px 36px var(--glass-shadow), inset 0 1px 0 var(--glass-edge);
}

.bio {
  margin-top: 24px;
  padding: 16px 20px;
  text-align: center;
}

.bio p {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 18px;
  line-height: 1.55;
  color: color-mix(in srgb, var(--text) 90%, transparent);
}

/* ------------------------------------------------------------
   Buttons
   ------------------------------------------------------------ */
.btn-gold {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 0;
  border-radius: 999px;
  padding: 17px 20px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .1em;
  color: var(--on-accent);
  cursor: pointer;
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--accent-soft) 72%, #fff) 0%,
    var(--accent) 55%,
    color-mix(in srgb, var(--accent) 68%, #000) 100%);
  box-shadow: 0 12px 30px color-mix(in srgb, var(--accent) 30%, transparent),
              inset 0 1px 0 rgba(255, 255, 255, .5);
  transition: transform .15s ease, box-shadow .15s ease;
}

.btn-gold:active {
  transform: scale(.975);
  box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 25%, transparent);
}

.btn-gold svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 14px 10px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .08em;
  color: var(--accent-soft);
  text-decoration: none;
  background: transparent;
  transition: transform .15s ease, background .2s ease;
}

.btn-outline:active {
  transform: scale(.97);
  background: var(--accent-wash);
}

/* Icons must not inherit the SVG default size */
.btn-outline svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.btn-outline span { white-space: nowrap; }

/* ------------------------------------------------------------
   Grids
   ------------------------------------------------------------ */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.links {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.link-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 4px;
  border-radius: 16px;
  text-decoration: none;
  color: var(--text);
  transition: transform .15s ease, border-color .2s ease;
}

.link-tile span {
  font-size: 10.5px;
  letter-spacing: .04em;
  color: color-mix(in srgb, var(--text) 90%, transparent);
}

.link-tile svg {
  width: 22px;
  height: 22px;
  stroke: var(--accent-soft);
}

.link-tile:active { transform: scale(.96); }

/* ------------------------------------------------------------
   Headquarters
   ------------------------------------------------------------ */
.hq {
  margin-top: 12px;
  padding: 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  text-align: start;
}

.hq svg {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  margin-top: 2px;
  stroke: var(--accent-soft);
}

.hq__label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .18em;
  color: var(--accent);
}

.hq__address {
  display: block;
  margin-top: 4px;
  font-family: var(--font-serif);
  font-size: 18px;
  line-height: 1.35;
  color: var(--text);
  text-decoration: none;
}

.hq__tel {
  display: inline-block;
  margin-top: 8px;
  font-size: 12px;
  letter-spacing: .04em;
  color: var(--accent-soft);
  text-decoration: none;
}

/* ------------------------------------------------------------
   Activities
   ------------------------------------------------------------ */
.activities { margin-top: 28px; }

.activities__heading {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 20px;
  text-align: center;
  color: var(--accent-soft);
  text-wrap: balance;
}

.activities__list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.activities__list li {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 52px;
  padding: 12px 10px;
  border-radius: 12px;
  font-size: 11.5px;
  line-height: 1.3;
  color: color-mix(in srgb, var(--text) 90%, transparent);
}

/* One item alone shouldn't sit in a half-width box */
.activities__list li:only-child { grid-column: 1 / -1; }

/* ------------------------------------------------------------
   Footer
   ------------------------------------------------------------ */
.footer {
  margin-top: auto;
  padding-top: 32px;
  text-align: center;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: .18em;
  color: color-mix(in srgb, var(--accent) 80%, transparent);
}

/* ------------------------------------------------------------
   Share sheet
   ------------------------------------------------------------ */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet[hidden] { display: none; }

.sheet__backdrop {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--bg) 70%, #000);
  opacity: .72;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.sheet__panel {
  position: relative;
  width: 100%;
  max-width: var(--max-w);
  border-radius: 24px 24px 0 0;
  padding: 18px 16px max(18px, env(safe-area-inset-bottom));
  animation: sheet-in .22s ease-out;
}

@keyframes sheet-in {
  from { transform: translateY(24px); opacity: .4; }
  to   { transform: translateY(0); opacity: 1; }
}

.sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sheet__title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 600;
  color: var(--accent-soft);
}

.sheet__close {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: color-mix(in srgb, var(--text) 70%, transparent);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.sheet__note {
  margin: 4px 0 0;
  font-size: 11px;
  line-height: 1.4;
  color: var(--muted);
}

.sheet__options {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  margin-top: 16px;
}

.sheet-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 10px 2px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
  transition: transform .15s ease;
}

.sheet-opt:active { transform: scale(.94); }

.sheet-opt__icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sheet-opt__label {
  font-size: 10.5px;
  letter-spacing: .02em;
  color: color-mix(in srgb, var(--text) 90%, transparent);
}

/* ------------------------------------------------------------
   Save contact + QR
   ------------------------------------------------------------ */
.save-row {
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  margin-top: 20px;
}

.save-row .btn-gold {
  font-size: 13px;
  letter-spacing: .08em;
  padding: 17px 12px;
}

.save-row .btn-gold span,
.save-row .btn-outline span { white-space: nowrap; }

html[lang="ar"] .save-row .btn-gold {
  font-size: 12px;
  letter-spacing: 0;
}

/* QR panel: always white behind the code, whatever the palette */
.qr {
  display: grid;
  justify-items: center;
  gap: 14px;
  margin-top: 16px;
}

.qr__frame {
  background: #fff;
  padding: 14px;
  border-radius: 16px;
  box-shadow: 0 10px 30px var(--glass-shadow);
}

.qr__frame canvas {
  display: block;
  width: 220px;
  height: 220px;
}

.qr__url {
  max-width: 100%;
  font-size: 11px;
  line-height: 1.4;
  text-align: center;
  word-break: break-all;
  color: var(--muted);
  text-decoration: none;
}

.qr .btn-gold { width: 100%; }

/* ------------------------------------------------------------
   Toast
   ------------------------------------------------------------ */
.toast {
  position: fixed;
  left: 50%;
  bottom: max(1.5rem, env(safe-area-inset-bottom));
  z-index: 60;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 12.5px;
  color: var(--text);
  white-space: nowrap;
  transition: opacity .25s ease, transform .25s ease;
}

.toast.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

/* ------------------------------------------------------------
   Language / direction
   ------------------------------------------------------------ */
html[lang="ar"] .identity__name {
  font-size: 32px;
  line-height: 1.45;
}

html[lang="ar"] .identity__motto { font-style: normal; }

html[dir="rtl"] .brand__lockup {
  padding-left: 0;
  padding-right: 12px;
  border-left: 0;
  border-right: 1px solid var(--line-strong);
}

html[dir="rtl"] .hero__bar { direction: rtl; }

/* Arabic script must not be letter-spaced; that also keeps the
   tagline on one line next to the wordmark. */
html[lang="ar"] .brand__tagline {
  letter-spacing: 0;
  font-size: 9px;
  font-weight: 400;
}

/* ------------------------------------------------------------
   Focus + motion
   ------------------------------------------------------------ */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent-soft);
  outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}
