/* ==========================================================================
   Gayanasaran Buddhist Forest Monastery — Official Links
   Palette follows the main monastery site: parchment, earth brown,
   temple gold, deep navy (dark mode).
   ========================================================================== */

/* ---------- Tokens ---------- */

:root {
  color-scheme: light;

  --font-display: "Playfair Display", Georgia, "Times New Roman", serif;
  --font-body: "Philosopher", "Segoe UI", system-ui, sans-serif;

  --bg: #f8f6f0;
  --bg-glow: rgba(212, 175, 55, 0.16);
  --surface: #fffdf8;
  --surface-raised: #ffffff;
  --border: #e9e0cc;
  --border-strong: #d8c9a6;

  --text: #2c1810;
  --text-muted: #6f5b46;
  --text-faint: #8b7355;

  --gold: #b8941f;
  --gold-bright: #d4af37;
  --gold-soft: rgba(212, 175, 55, 0.14);
  --saffron: #c2410c;

  --btn-bg: #2c1810;
  --btn-bg-hover: #4a2c1c;
  --btn-text: #fbf7ee;
  --ghost-hover: rgba(44, 24, 16, 0.05);

  --qr-bg: #fffdf8;
  --qr-fg: #2c1810;

  --focus: #b8941f;

  --shadow-sm: 0 1px 2px rgba(44, 24, 16, 0.05);
  --shadow: 0 1px 2px rgba(44, 24, 16, 0.04), 0 12px 32px -16px rgba(44, 24, 16, 0.22);
  --shadow-hover: 0 2px 4px rgba(44, 24, 16, 0.05), 0 22px 44px -18px rgba(44, 24, 16, 0.3);

  --radius: 20px;
  --radius-sm: 12px;
  --ease: cubic-bezier(0.22, 0.7, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --bg: #001524;
    --bg-glow: rgba(212, 175, 55, 0.09);
    --surface: #08202f;
    --surface-raised: #0c2738;
    --border: rgba(218, 190, 149, 0.14);
    --border-strong: rgba(218, 190, 149, 0.28);

    --text: #f3ece0;
    --text-muted: #c4b59c;
    --text-faint: #9f8f76;

    --gold: #d4af37;
    --gold-bright: #e2c25a;
    --gold-soft: rgba(212, 175, 55, 0.12);
    --saffron: #f0884a;

    --btn-bg: #d4af37;
    --btn-bg-hover: #e2c25a;
    --btn-text: #1a1206;
    --ghost-hover: rgba(243, 236, 224, 0.06);

    --qr-bg: #f8f3e8;
    --qr-fg: #001524;

    --focus: #e2c25a;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 14px 36px -18px rgba(0, 0, 0, 0.6);
    --shadow-hover: 0 2px 4px rgba(0, 0, 0, 0.3), 0 24px 48px -18px rgba(0, 0, 0, 0.7);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #001524;
  --bg-glow: rgba(212, 175, 55, 0.09);
  --surface: #08202f;
  --surface-raised: #0c2738;
  --border: rgba(218, 190, 149, 0.14);
  --border-strong: rgba(218, 190, 149, 0.28);

  --text: #f3ece0;
  --text-muted: #c4b59c;
  --text-faint: #9f8f76;

  --gold: #d4af37;
  --gold-bright: #e2c25a;
  --gold-soft: rgba(212, 175, 55, 0.12);
  --saffron: #f0884a;

  --btn-bg: #d4af37;
  --btn-bg-hover: #e2c25a;
  --btn-text: #1a1206;
  --ghost-hover: rgba(243, 236, 224, 0.06);

  --qr-bg: #f8f3e8;
  --qr-fg: #001524;

  --focus: #e2c25a;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.25), 0 14px 36px -18px rgba(0, 0, 0, 0.6);
  --shadow-hover: 0 2px 4px rgba(0, 0, 0, 0.3), 0 24px 48px -18px rgba(0, 0, 0, 0.7);
}

/* ---------- Base ---------- */

*,
*::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;
  display: flex;
  flex-direction: column;
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -10%, var(--bg-glow), transparent 70%),
    radial-gradient(ellipse 60% 40% at 50% 110%, var(--gold-soft), transparent 70%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  transition: background-color 0.4s var(--ease), color 0.4s var(--ease);
}

img,
svg {
  display: block;
  max-width: 100%;
}

h1,
h2,
p,
figure,
ul {
  margin: 0;
}

::selection {
  background: var(--gold-soft);
  color: var(--text);
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 8px;
}

.icon {
  width: 1.15em;
  height: 1.15em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.skip-link {
  position: absolute;
  top: 0.75rem;
  left: 1rem;
  z-index: 20;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  background: var(--btn-bg);
  color: var(--btn-text);
  font-weight: 700;
  text-decoration: none;
  transform: translateY(-200%);
  transition: transform 0.2s var(--ease);
}

.skip-link:focus {
  transform: translateY(0);
}

/* ---------- Theme toggle ---------- */

.theme-toggle {
  position: absolute;
  top: clamp(1rem, 3vw, 1.5rem);
  right: clamp(1rem, 3vw, 1.5rem);
  z-index: 10;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-muted);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background-color 0.4s var(--ease), transform 0.3s var(--ease);
}

.theme-toggle:hover {
  color: var(--gold);
  border-color: var(--border-strong);
  transform: rotate(-12deg);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-toggle__sun {
  display: none !important;
}

:root[data-theme="dark"] .theme-toggle__sun {
  display: block !important;
}

:root[data-theme="dark"] .theme-toggle__moon {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle__sun {
    display: block !important;
  }

  :root:not([data-theme="light"]) .theme-toggle__moon {
    display: none;
  }
}

/* ---------- Hero ---------- */

.hero {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: clamp(4rem, 10vw, 6.5rem) 1rem clamp(2.5rem, 6vw, 3.5rem);
  text-align: center;
  animation: fade-up 0.9s var(--ease) both;
}

.hero__logo {
  width: clamp(72px, 14vw, 96px);
  height: auto;
  margin: 0 auto 1.5rem;
  filter: drop-shadow(0 8px 18px rgba(212, 56, 120, 0.22));
  animation: bloom 1.2s var(--ease) both;
}

.hero__eyebrow {
  margin-bottom: 0.75rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.hero__title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.9rem, 5.2vw, 3.1rem);
  line-height: 1.15;
  letter-spacing: 0.01em;
  color: var(--text);
  text-wrap: balance;
}

.ornament {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin: 1.5rem auto;
}

.ornament span {
  width: clamp(48px, 12vw, 84px);
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold));
}

.ornament span:last-child {
  background: linear-gradient(90deg, var(--gold), transparent);
}

.ornament i {
  width: 7px;
  height: 7px;
  border: 1px solid var(--gold);
  transform: rotate(45deg);
}

.hero__lead {
  max-width: 34rem;
  margin: 0 auto;
  font-size: clamp(1rem, 2.2vw, 1.125rem);
  color: var(--text-muted);
  text-wrap: pretty;
}

/* ---------- Directory grid ---------- */

.directory {
  flex: 1;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 clamp(1rem, 4vw, 2rem) clamp(3rem, 8vw, 5rem);
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  gap: clamp(1rem, 2.5vw, 1.75rem);
  padding: 0;
  list-style: none;
}

.cards:focus {
  outline: none;
}

.status {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
}

.status--error {
  color: var(--saffron);
  font-style: normal;
}

/* ---------- Card ---------- */

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.75rem 1.5rem 1.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
  overflow: hidden;
  animation: card-in 0.8s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 90ms + 250ms);
  transition:
    transform 0.4s var(--ease),
    box-shadow 0.4s var(--ease),
    border-color 0.4s var(--ease),
    background-color 0.4s var(--ease);
}

/* Fine gold line along the top edge */
.card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold-bright), transparent);
  opacity: 0;
  transition: opacity 0.4s var(--ease);
}

.card:hover {
  transform: translateY(-4px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-hover);
}

.card:hover::before,
.card:focus-within::before {
  opacity: 0.9;
}

.card__head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}

.card__icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--gold-soft);
  color: var(--gold);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--gold) 22%, transparent);
  transition: transform 0.5s var(--ease);
}

.card__icon .icon {
  width: 22px;
  height: 22px;
}

.card:hover .card__icon {
  transform: scale(1.06);
}

/* Photo variant: round image with the platform icon as a small badge */
.card__icon.has-avatar {
  position: relative;
  width: 76px;
  height: 76px;
  background: none;
  box-shadow: none;
}

.card__avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 3px var(--surface), 0 0 0 4px var(--border-strong);
  animation: fade-in 0.6s var(--ease) both;
}

.card__icon.has-avatar .icon {
  position: absolute;
  right: -4px;
  bottom: -4px;
  width: 28px;
  height: 28px;
  padding: 6px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

.card__platform {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.card__name {
  margin-top: 0.85rem;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 1.35rem;
  line-height: 1.25;
  color: var(--text);
  overflow-wrap: anywhere;
}

.card__host {
  margin-top: 0.25rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.card__desc {
  display: -webkit-box;
  max-width: 32ch;
  margin-top: 0.75rem;
  overflow: hidden;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--text-muted);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  animation: fade-in 0.6s var(--ease) both;
}

/* ---------- QR ---------- */

.card__qr {
  /* auto top margin pushes QR + buttons to the bottom, so they line up
     across a row even when cards have different amounts of text */
  margin: auto 0 1.5rem;
  padding: 12px 12px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--qr-bg);
  box-shadow: inset 0 0 0 4px var(--qr-bg), inset 0 0 0 5px color-mix(in srgb, var(--gold) 18%, transparent);
}

.card__qr-code {
  width: 136px;
  height: 136px;
  margin: 4px;
}

/* QRCode.js renders a canvas and an img and hides one of them inline. */
.card__qr-code canvas,
.card__qr-code img {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.card__qr figcaption {
  margin-top: 0.35rem;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #8b7355;
}

/* ---------- Buttons ---------- */

.card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  width: 100%;
  margin-top: auto;
}

/* Minimum gap between the text and the QR / buttons below it */
.card__host,
.card__desc {
  margin-bottom: 1.4rem;
}

.card__host:has(+ .card__desc) {
  margin-bottom: 0;
}

.card__qr + .card__actions {
  margin-top: 0;
}

.btn {
  flex: 1 1 8rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 46px;
  padding: 0.6rem 1.1rem;
  border: 1px solid transparent;
  border-radius: 999px;
  font-family: var(--font-body);
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color 0.25s var(--ease),
    border-color 0.25s var(--ease),
    color 0.25s var(--ease),
    transform 0.2s var(--ease);
}

.btn:active {
  transform: scale(0.97);
}

.btn--primary {
  background: var(--btn-bg);
  color: var(--btn-text);
}

.btn--primary:hover {
  background: var(--btn-bg-hover);
}

.btn--primary .icon {
  width: 1em;
  height: 1em;
  transition: transform 0.25s var(--ease);
}

.btn--primary:hover .icon {
  transform: translate(2px, -2px);
}

.btn--ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text);
}

.btn--ghost:hover {
  background: var(--ghost-hover);
  border-color: var(--gold);
}

.btn--ghost.is-copied {
  border-color: var(--gold);
  color: var(--gold);
}

.btn--ghost.is-copied .icon {
  animation: pop 0.35s var(--ease);
}

/* ---------- Footer ---------- */

.footer {
  padding: 2rem 1rem 2.5rem;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.footer__blessing em {
  font-family: var(--font-display);
  font-style: italic;
  color: var(--text);
}

.footer__meta {
  margin-top: 0.4rem;
  color: var(--text-faint);
  font-size: 0.82rem;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  z-index: 30;
  max-width: calc(100% - 2rem);
  padding: 0.7rem 1.25rem;
  border-radius: 999px;
  background: var(--btn-bg);
  color: var(--btn-text);
  font-size: 0.92rem;
  font-weight: 700;
  box-shadow: var(--shadow-hover);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
}

.toast:empty {
  display: none;
}

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

/* ---------- Animations ---------- */

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes bloom {
  from {
    opacity: 0;
    transform: scale(0.85) rotate(-8deg);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

@keyframes pop {
  50% {
    transform: scale(1.25);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
  }

  .card:hover {
    transform: none;
  }
}

/* ---------- Responsive ---------- */

@media (max-width: 480px) {
  .hero__eyebrow {
    letter-spacing: 0.22em;
  }

  .card {
    padding: 1.5rem 1.25rem 1.25rem;
  }

  .card__qr-code {
    width: 128px;
    height: 128px;
  }
}

@media (hover: none) {
  .card:hover {
    transform: none;
    box-shadow: var(--shadow);
  }
}

/* ---------- Print: a tidy sheet of QR codes ---------- */

@media print {
  body {
    background: #fff;
    color: #000;
  }

  .theme-toggle,
  .skip-link,
  .toast,
  .card__actions {
    display: none !important;
  }

  .hero {
    padding: 0 0 1.5rem;
  }

  .cards {
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
  }

  .card {
    box-shadow: none;
    border-color: #ccc;
    break-inside: avoid;
    animation: none;
  }
}
