/* ============================================================
   Lov Divaaa — link in bio
   iPhone-widget grid, dark brown & gold theme (same family as
   the AOPPA aromatherapist site), mobile-first
   ============================================================ */

:root {
  --bg-dark:    #241811; /* page background */
  --panel:      #6b4a35; /* card background */
  --panel-deep: #503524; /* inner boxes / buttons */
  --cream:      #f3e9dc; /* main text */
  --cream-dim:  #d9c7b2; /* secondary text */
  --gold:       #f2c14e; /* accent */
  --gold-soft:  #e8b96a;
  --radius:     22px;
  --font-head:  "Google Sans", "Sarabun", sans-serif;
  --font-body:  "Google Sans", "Sarabun", sans-serif;

  /* grid geometry: 3 columns inside a max 520px column */
  --page-max: 520px;
  --page-pad: 18px;
  --gap:      12px;
  --cols:     3;
  --unit: calc((min(100vw, var(--page-max)) - 2 * var(--page-pad) - (var(--cols) - 1) * var(--gap)) / var(--cols));
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  font-weight: 400;
  color: var(--cream);
  background:
    radial-gradient(ellipse at 20% 10%, rgba(107, 74, 53, 0.35), transparent 55%),
    radial-gradient(ellipse at 80% 80%, rgba(107, 74, 53, 0.22), transparent 55%),
    var(--bg-dark);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }
a   { color: var(--gold); text-decoration: none; }

/* ---------- Language toggle ---------- */
.lang-switch {
  position: fixed;
  top: 14px;
  right: 16px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  background: rgba(36, 24, 17, 0.75);
  border: 1px solid rgba(242, 193, 78, 0.25);
  border-radius: 999px;
  padding: 5px 14px;
  backdrop-filter: blur(6px);
}
.lang-switch span { color: var(--cream-dim); opacity: 0.5; }
.lang-switch a { color: var(--cream-dim); }
.lang-switch a.active { color: var(--gold); font-weight: 600; }

/* ---------- Page column ---------- */
.page {
  --page-top: 56px;
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: var(--page-top) var(--page-pad) 40px;
}

/* ---------- Profile ---------- */
.profile { text-align: center; }

/* hero photo header: full-bleed inside the page column, dissolves into bg.
   The photo is faded out with a mask (not a colour overlay), so whatever the
   page background is behind it shows through — no visible seam / band. */
.profile.has-hero .hero {
  margin: calc(var(--page-top) * -1) calc(var(--page-pad) * -1) 0;
  height: min(64vh, 500px);
  background-size: cover;
  background-position: center 18%;
  position: relative;
  /* vertical fade-out + soft side fade, combined */
  -webkit-mask-image:
    linear-gradient(to bottom, #000 0%, #000 40%, rgba(0,0,0,0.55) 66%, rgba(0,0,0,0.15) 84%, transparent 100%),
    linear-gradient(to right, transparent 0%, #000 10%, #000 90%, transparent 100%);
  -webkit-mask-composite: source-in;
          mask-image:
    linear-gradient(to bottom, #000 0%, #000 40%, rgba(0,0,0,0.55) 66%, rgba(0,0,0,0.15) 84%, transparent 100%),
    linear-gradient(to right, transparent 0%, #000 10%, #000 90%, transparent 100%);
          mask-composite: intersect;
}
/* gentle top scrim only — keeps the language toggle readable over the photo */
.profile.has-hero .hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom,
    rgba(36, 24, 17, 0.4) 0%,
    rgba(36, 24, 17, 0) 26%,
    rgba(36, 24, 17, 0) 100%);
}
.profile.has-hero .profile-name {
  position: relative;
  z-index: 1;
  margin-top: -64px;
  font-size: clamp(1.9rem, 8vw, 2.5rem);
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.55);
}

.avatar-wrap {
  width: 130px;
  height: 130px;
  margin: 0 auto;
  border-radius: 50%;
  padding: 3px;
  background: linear-gradient(135deg, var(--gold), rgba(242, 193, 78, 0.25));
  box-shadow: 0 6px 28px rgba(242, 193, 78, 0.22);
}
.avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--bg-dark);
}

.profile-name {
  margin-top: 14px;
  font-family: var(--font-head);
  font-size: 1.55rem;
  font-weight: 600;
  color: #fdf6ec;
  letter-spacing: 0.02em;
}

.profile-tagline {
  margin-top: 2px;
  font-size: 0.95rem;
  color: var(--cream-dim);
}

/* ---------- Social icon row ---------- */
.socials {
  margin-top: 18px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 26px;
}
.socials a {
  color: var(--cream);
  display: inline-flex;
  transition: color 0.18s, transform 0.18s;
}
.socials a:hover { color: var(--gold); transform: translateY(-2px); }
.socials .icon { width: 1.55em; height: 1.55em; }

.profile-notes {
  list-style: none;
  margin: 16px auto 0;
  display: inline-flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  font-size: 0.92rem;
}
.profile-notes li {
  display: flex;
  align-items: center;
  gap: 9px;
}
.profile-notes .icon { width: 1.2em; height: 1.2em; }
.note-warn span { color: var(--cream-dim); }

/* ---------- Icons (inline SVG) ---------- */
.icon {
  display: inline-flex;
  width: 1.3em;
  height: 1.3em;
  vertical-align: -0.28em;
  color: inherit;
  flex-shrink: 0;
}
.icon svg { width: 100%; height: 100%; }

/* ---------- Widget grid ---------- */
.grid {
  margin-top: 26px;
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  grid-auto-rows: var(--unit);
  grid-auto-flow: row;
  gap: var(--gap);
}

/* ---------- Blocks ---------- */
.block {
  /* size comes from inline --w / --h (server-clamped: w 1-3, h 1-20) */
  grid-column: span var(--w, 1);
  grid-row: span var(--h, 1);
  position: relative;
  display: flex;
  border-radius: var(--radius);
  overflow: hidden;
  background-color: var(--panel);
  background-size: cover;
  background-position: center;
  color: var(--cream);
  border: 1px solid rgba(243, 233, 220, 0.08);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}
.block:hover,
.block:focus-visible {
  transform: translateY(-3px) scale(1.015);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.42);
  filter: brightness(1.06);
}
.block:active { transform: scale(0.97); }

/* background image fills the widget rectangle exactly (matches grid W×H) */
.block-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
}

.block-shade {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(to top, rgba(20, 12, 7, 0.72), rgba(20, 12, 7, 0.12) 60%);
}

.block-inner {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  text-align: center;
  padding: 8px 10px;
  /* ไอคอน + ฟอนต์ อิงความสูงของ cell (แถว) ไม่ใช่ความกว้าง */
  --icon-size: min(42px, calc(var(--unit) * 0.4));
  --title-size: clamp(0.72rem, calc(var(--unit) * 0.135), 0.84rem);
  --sub-size: clamp(0.64rem, calc(var(--unit) * 0.115), 0.74rem);
}
.has-img .block-inner { justify-content: flex-end; }

/* ไอคอน SVG */
.block-icon {
  width: var(--icon-size);
  height: var(--icon-size);
  flex-shrink: 0;
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.block-icon svg {
  width: 90%;
  height: 90%;
}
/* รูปโปรไฟล์วงกลม — ใหญ่กว่าไอคอน SVG 25% */
.block-icon-photo {
  width: calc(var(--icon-size) * 1.25);
  height: calc(var(--icon-size) * 1.25);
  flex-shrink: 0;
  margin: 0;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}

.block-title {
  font-family: var(--font-head);
  font-weight: 600;
  font-size: var(--title-size);
  line-height: 1.2;
  overflow-wrap: anywhere;
  max-width: 100%;
}

.block-sub {
  font-size: var(--sub-size);
  font-weight: 400;
  opacity: 0.88;
  line-height: 1.25;
  max-width: 100%;
}

.block-badge {
  margin-top: 6px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: var(--sub-size);
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.25);
}

/* ขยายเมื่อ block สูง 2+ แถว (ไม่ใช่เมื่อกว้างอย่างเดียว) */
.block.h2 .block-inner {
  --icon-size: min(48px, calc(var(--unit) * 0.36));
  --title-size: clamp(0.78rem, calc(var(--unit) * 0.12), 0.92rem);
  --sub-size: clamp(0.68rem, calc(var(--unit) * 0.1), 0.8rem);
}
.block.h3 .block-inner,
.block.h4 .block-inner,
.block.h5 .block-inner {
  --icon-size: min(54px, calc(var(--unit) * 0.34));
  --title-size: clamp(0.82rem, calc(var(--unit) * 0.11), 1rem);
  --sub-size: clamp(0.7rem, calc(var(--unit) * 0.095), 0.84rem);
}

/* highlighted block (glow) */
.block.glow {
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.18),
    0 8px 34px rgba(42, 171, 238, 0.45),
    0 2px 60px rgba(42, 171, 238, 0.25);
}
.block.glow.st-gold, .block.glow.st-custom, .block.glow.st-red {
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.18),
    0 8px 34px rgba(242, 193, 78, 0.4),
    0 2px 60px rgba(242, 193, 78, 0.22);
}

/* ---------- Block style presets ---------- */
.st-gold {
  background: linear-gradient(135deg, #f2c14e, #d99b3a);
  color: #2c1c10;
}
.st-gold .block-badge { background: rgba(44, 28, 16, 0.18); border-color: rgba(44, 28, 16, 0.3); }

.st-brown  { background: linear-gradient(160deg, var(--panel), var(--panel-deep)); }
.st-cream  { background: linear-gradient(160deg, #f3e9dc, #e2d0b8); color: #3a2417; }
.st-black  { background: linear-gradient(160deg, #1d1d1f, #0d0d0e); color: #fff; }

.st-telegram  { background: linear-gradient(135deg, #2aabee, #1e88c7); color: #fff; }
.st-onlyfans  { background: linear-gradient(135deg, #00aff0, #0088cc); color: #fff; }
.st-fansly    { background: linear-gradient(160deg, #ffffff, #eef4fb); color: #1e6fd9; }
.st-fansly .block-sub { color: #4a5a6a; }
.st-instagram {
  background: linear-gradient(45deg, #f9ce34, #ee2a7b 55%, #6228d7);
  color: #fff;
}
.st-tiktok {
  background:
    radial-gradient(ellipse at 85% 15%, rgba(37, 244, 238, 0.35), transparent 50%),
    radial-gradient(ellipse at 15% 85%, rgba(254, 44, 85, 0.35), transparent 50%),
    #101010;
  color: #fff;
}
.st-line { background: linear-gradient(135deg, #06c755, #04a344); color: #fff; }
.st-red  { background: linear-gradient(135deg, #c62828, #8e1616); color: #fff; }

.st-custom { background: linear-gradient(135deg, var(--c-from, #6b4a35), var(--c-to, #503524)); }

/* image background wins over preset gradient */
.block.has-img {
  background-color: var(--panel-deep);
  background-image: none;
}

/* ---------- Gallery (before footer) ---------- */
.gallery {
  margin-top: var(--gap);
  background: linear-gradient(160deg, rgba(107, 74, 53, 0.5), rgba(80, 53, 36, 0.45));
  border: 1px solid rgba(243, 233, 220, 0.08);
  border-radius: var(--radius);
  padding: 14px 14px 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}
.gallery-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  padding: 0 2px;
}
.gallery-title {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-head);
  font-weight: 600;
  font-size: 0.98rem;
}
.gallery-title .icon { width: 1.25em; height: 1.25em; color: var(--gold-soft); }
.gallery-more {
  font-size: 0.82rem;
  color: var(--gold);
  white-space: nowrap;
}
.gallery.no-head { padding: 10px; }
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.gallery-grid a { display: block; }
.gallery-grid img {
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: 12px;
  transition: transform 0.18s ease, filter 0.18s ease;
}
.gallery-grid a:hover img { transform: scale(1.03); filter: brightness(1.08); }

/* a tweet block hints it opens a popup */
.block.has-tweet { cursor: pointer; }

/* big tweet block: show the tweet content inline as a white card widget */
.block.tweet-inline {
  background: #fff;
  color: #0f1419;
  padding: 0;
  text-align: left;
  align-items: stretch;
}
.block.tweet-inline .tweet {
  flex: 1;
  min-width: 0;
  border: none;
  border-radius: inherit;
  display: flex;
  flex-direction: column;
  font-size: 0.95rem;
}
.block.tweet-inline .tweet-text {
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.block.tweet-inline .tweet-media {
  flex: 1;
  min-height: 60px;
  object-fit: cover;
  margin-top: 12px;
}
.block.tweet-inline .tweet-date { display: none; }
/* only 1 image wide (w2/h2+) — keep text a touch smaller so more shows */
.block.tweet-inline.w2 .tweet { font-size: 0.9rem; }

/* native X embed inside a large widget block */
.block.tweet-embed-inline {
  background: #fff;
  color: #0f1419;
  padding: 0;
  text-align: left;
  align-items: stretch;
  cursor: default;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}
.block.tweet-embed-inline:hover,
.block.tweet-embed-inline:focus-visible {
  transform: none;
  filter: none;
}
.tweet-embed-wrap {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 10px 8px;
  overflow: auto;
}
.tweet-embed-wrap .twitter-tweet {
  margin: 0 !important;
  max-width: 100% !important;
}

/* ---------- Tweet modal ---------- */
.modal[hidden] { display: none; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(12, 8, 5, 0.72);
  backdrop-filter: blur(4px);
}
.modal-box {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: #ececf0;
  border-radius: 22px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  animation: modal-in 0.22s ease;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}
.modal-head {
  text-align: center;
  padding: 16px 20px 12px;
  color: #0f1419;
}
.modal-title { font-family: var(--font-head); font-weight: 700; font-size: 1.15rem; }
.modal-sub {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
  font-size: 0.85rem;
  color: #536471;
}
.modal-sub .icon { width: 0.95em; height: 0.95em; }
.modal-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 14px;
}
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px 16px;
}
.view-on-x {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #0f1419;
  color: #fff;
  font-weight: 600;
  font-size: 0.92rem;
  padding: 11px 22px;
  border-radius: 999px;
}
.view-on-x .icon { width: 1.05em; height: 1.05em; }
.view-on-x:hover { background: #272c30; }
.modal-close {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: #fff;
  color: #0f1419;
  font-size: 1.05rem;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}
.modal-close:hover { background: #e3e3e6; }

/* ---------- Tweet card (inside modal) ---------- */
.tweet {
  background: #fff;
  border: 1px solid #eff3f4;
  border-radius: 16px;
  padding: 16px;
  color: #0f1419;
  font-size: 0.98rem;
  line-height: 1.45;
}
.tweet-head { display: flex; align-items: flex-start; gap: 11px; }
.tweet-avatar {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.tweet-avatar-ph { background: #cfd9de; display: block; }
.tweet-id { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; flex: 1; }
.tweet-author {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 700;
}
.tweet-author .icon { width: 1.05em; height: 1.05em; }
.tweet-handle { color: #536471; font-size: 0.92rem; }
.tweet-x { color: #0f1419; flex-shrink: 0; }
.tweet-x .icon { width: 1.25em; height: 1.25em; }
.tweet-text { margin-top: 12px; white-space: normal; overflow-wrap: anywhere; }
.tweet-text a { color: #1d9bf0; }
.tweet-media {
  width: 100%;
  margin-top: 12px;
  border-radius: 14px;
  border: 1px solid #eff3f4;
  display: block;
}
video.tweet-media { background: #000; }
.tweet-date { margin-top: 12px; color: #536471; font-size: 0.85rem; }

/* a gate block hints it opens a popup */
.block.has-gate { cursor: pointer; }

/* ---------- Gate modal (consent → QR → send slip) ---------- */
.gate-box .modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 18px 8px;
}
.gate-box .modal-title { font-size: 1.1rem; }
.gate-box .gate-close { position: static; }
.gate-body { padding: 4px 18px 20px; }

.gate { color: #0f1419; }
.gate-step { display: flex; flex-direction: column; align-items: center; }
.gate-step[hidden] { display: none; }

.gate-text {
  font-size: 1rem;
  line-height: 1.6;
  color: #26313a;
  white-space: normal;
  align-self: stretch;
  margin-bottom: 18px;
}
.gate-text a { color: #1d9bf0; }
.gate-text.rich-text u { text-decoration: underline; }
.gate-text.rich-text b,
.gate-text.rich-text strong { font-weight: 700; }

.gate-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  font: inherit;
  font-weight: 600;
  font-size: 1rem;
  padding: 13px 22px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
}
.gate-accept { background: #0f1419; color: #fff; }
.gate-accept:hover { background: #272c30; }

.gate-qr {
  width: min(240px, 72vw);
  height: auto;
  border-radius: 14px;
  border: 1px solid #e6e9ea;
  background: #fff;
}
.gate-qr-note {
  margin: 14px 0 16px;
  text-align: center;
  font-size: 0.92rem;
  color: #536471;
  line-height: 1.5;
}
.gate-slip { background: #06c755; color: #fff; text-decoration: none; }
.gate-slip:hover { background: #05a648; }
.gate-slip .icon { width: 1.1em; height: 1.1em; }

/* ---------- Footer ---------- */
.footer {
  margin-top: 34px;
  text-align: center;
  font-size: 0.82rem;
  color: var(--cream-dim);
  opacity: 0.75;
}

/* ---------- Larger screens ---------- */
@media (min-width: 560px) {
  .page { --page-top: 72px; }
}
