/* ── Love Letter — Styles (JKT48 Games theme) ──
   Mengikuti shared-layout.css jkt48.preset.id — pakai var --bg/--bg2/--card/--text/--accent/--border
   Body bg & font diatur di sini (shared-layout.css hanya header/footer vars). */

/* ── Page base (sama dgn games.html inline style) ── */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
  padding-bottom: 120px;
  color: var(--text);
  background: var(--bg);
}

/* ── Page shell ── */
.gh-wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 8px 20px 0;
}
.gh-hero {
  text-align: center;
  margin-bottom: 22px;
}
.gh-hero h1 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(30px, 5.5vw, 48px);
  font-weight: 400;
  letter-spacing: .04em;
  color: var(--text2);
}
.gh-hero p {
  color: var(--text2);
  font-size: 14px;
  line-height: 1.55;
  max-width: 560px;
  margin: 6px auto 0;
}

/* ── Layout: config + preview side by side ── */
.mo-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}
.mo-panel {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  margin-bottom: 0;
  min-width: 0;
}
.mo-preview {
  display: flex;
  justify-content: center;
  position: sticky;
  top: 12px;
}
.mo-carousel {
  display: none;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 460px;
}
.mo-carousel.show { display: flex; }
.carousel-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.carousel-badge {
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  padding: 3px 12px;
  border-radius: 999px;
}
.carousel-dots {
  display: flex;
  gap: 6px;
  align-items: center;
}
.carousel-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  border: none;
  background: var(--border);
  cursor: pointer;
  padding: 0;
  transition: all .15s;
}
.carousel-dot.active { background: var(--accent); width: 20px; }
.carousel-viewport {
  overflow: hidden;
  border-radius: 16px;
}
.carousel-track {
  display: flex;
  transition: transform .3s ease;
}
.carousel-slide {
  flex: 0 0 auto;
  /* preview-card width set via JS */
  border-radius: 16px;
  justify-content: flex-start; /* isi mulai dari atas, bukan tengah */
}
.preview-card.carousel-slide { padding-top: 3.5rem; justify-content: flex-start; /* isi mulai dari atas */ }
.carousel-nav {
  display: flex;
  justify-content: center;
  gap: 10px;
}
.carousel-btn {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--hover);
  color: var(--text2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all .15s;
}
.carousel-btn:hover:not(:disabled) { background: var(--border); }
.carousel-btn:disabled { opacity: .35; cursor: default; }

/* preview-card hidden saat carousel show */
.preview-card.hidden { display: none; }
.mo-step { margin-bottom: 18px; }
.mo-step:last-child { margin-bottom: 0; }

.mo-step label {
  display: block;
  font-weight: 700;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--text2);
}
.mo-opt { font-weight: 400; color: var(--text3); font-size: 12px; }

.mo-hashtag-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap; /* di HP: elemen turun ke baris baru */
}
.mo-hashtag-row .font-select { flex: 1; }
.mo-hashtag-row .mo-paging { white-space: nowrap; margin: 0; }

/* ── Hashtag grid (chips, kayak pilih oshi) ── */
.hashtag-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px;
  align-content: flex-start;
}
.hashtag-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: all .15s;
}
.hashtag-chip:hover { border-color: var(--accent); }
.hashtag-chip.selected {
  background: var(--active-soft);
  border-color: var(--accent);
  color: var(--active-text);
}
.hashtag-chip.off { opacity: .45; text-decoration: line-through; }
.hashtag-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--text2);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all .15s;
  align-self: center;
}
.hashtag-add:hover { border-color: var(--accent); color: var(--accent); }

.mo-step label { display: block; }

/* form tambah hashtag */
.hashtag-form {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  align-items: center;
}
.hashtag-form[hidden] { display: none; }
.hashtag-form .font-select { flex: 1; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

.mo-hint {
  color: var(--text3);
  font-size: 12.5px;
  margin: 14px 0 18px;
  line-height: 1.6;
  background: var(--hover);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
}

/* ── Oshi grid (nama aja — chips) ── */
.oshi-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 240px;
  overflow-y: auto;
  padding: 4px;
  align-content: flex-start;
}
.oshi-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: all .15s;
}
.oshi-chip:hover { border-color: var(--accent); }
.oshi-chip.selected {
  background: var(--active-soft);
  border-color: var(--accent);
  color: var(--active-text);
}

/* ── Template grid ── */
.template-grid { display: flex; gap: 10px; overflow-x: auto; padding: 4px; min-width: 0; max-width: 100%; }
.template-option {
  flex: 0 0 auto; /* jangan shrink — grid scroll horizontal */
  min-width: 88px;
  text-align: center;
  cursor: pointer;
  user-select: none;
}
.template-option .tpl-preview {
  width: 88px; height: 56px;
  border-radius: 10px;
  border: 2px solid var(--border);
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-size: 22px;
  color: var(--text3);
  transition: border-color .15s;
}
.template-option.selected .tpl-preview { border-color: var(--accent); }
.template-option .tpl-label { font-size: 11px; margin-top: 5px; color: var(--text3); font-weight: 600; }

/* ── Font select ── */
.font-select {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  cursor: pointer;
  transition: border-color .15s;
}
.font-select:focus { outline: none; border-color: var(--accent); }

/* ── Actions ── */
.mo-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.mo-paging {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--hover);
  color: var(--text2);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  transition: border-color .15s;
  white-space: nowrap;
}
.mo-paging small { color: var(--text3); font-weight: 500; }
.mo-paging:hover { border-color: var(--accent); }
.mo-paging input { accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer; }
.btn-primary, .btn-ghost {
  flex: 1;
  padding: 11px 18px;
  border-radius: 12px;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  transition: all .15s;
  border: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
}
.btn-primary {
  background: var(--accent);
  color: var(--accent-text, #fff);
}
.btn-primary:hover { opacity: .9; }
.btn-ghost {
  background: var(--hover);
  border: 1px solid var(--border);
  color: var(--text2);
}
.btn-ghost:hover { background: var(--border); }

/* ── Preview ── */
.mo-preview { display: flex; justify-content: center; margin-bottom: 20px; }
.preview-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 8px 32px var(--shadow);
  width: fit-content;   /* wrap selebar isi, bukan stretch */
  max-width: 100%;
}
.preview-card {
  width: 420px;
  min-height: 520px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem 1.8rem;
  border-radius: 20px;
  position: relative;
  overflow: hidden;
}

/* indikator halaman — pojok kanan bawah (preview + hasil export) */
.page-badge {
  position: absolute;
  right: 12px;
  bottom: 12px;
  color: currentColor;
  opacity: .55;
  font-family: Inter, sans-serif;
  font-size: 11px;
  font-weight: 500;
  line-height: 1;
  z-index: 5;
  pointer-events: none;
}

/* tanggal — pojok kanan atas */
.card-date {
  position: absolute;
  top: 14px;
  right: 16px;
  font-family: Inter, sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  color: #8a7a6a;
  opacity: .9;
  z-index: 10;
  pointer-events: none;
}

/* hashtag — pojok kiri bawah */
.card-hashtag {
  position: absolute;
  left: 16px;
  bottom: 14px;
  font-family: Inter, sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .03em;
  color: inherit;
  opacity: .75;
  z-index: 5;
  pointer-events: none;
}

/* ── Mini toolbar format teks ── */
.fmt-toolbar {
  position: fixed;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--bg2, #0e1016);
  border: 1px solid var(--border, rgba(255,255,255,.08));
  border-radius: 12px;
  padding: 5px 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
  z-index: 999;
  white-space: nowrap;
}
.fmt-toolbar[hidden] { display: none !important; }
.fmt-btn {
  background: transparent;
  border: none;
  color: var(--text, #e8eaef);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.fmt-btn:hover { background: var(--card, #12151d); }
.fmt-btn:active { background: var(--accent, #F31E4E); color: #fff; }
.fmt-btn.active { background: var(--accent, #F31E4E); color: #fff; }
.fmt-font {
  background: var(--card, #12151d);
  color: var(--text, #e8eaef);
  border: 1px solid var(--border, rgba(255,255,255,.08));
  border-radius: 8px;
  padding: 4px 6px;
  font-size: 12px;
  max-width: 130px;
  cursor: pointer;
}

/* ── Block editing ── */
.tpl-blocks {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0;
}
.block + .block, .block-spacer + .block { margin-top: 12px; }
/* footer lebih dempet */
.block[data-block="footer-words"] { margin-top: 6px; }
.block[data-block="footer-name"] { margin-top: 2px; }
.block {
  position: relative;
  width: 100%;
}
.block-ctrl {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  gap: 3px;
  opacity: 0;
  transition: opacity .15s;
  z-index: 5;
}
.block:hover .block-ctrl { opacity: 1; }
.block-ctrl button {
  background: rgba(255,255,255,.85);
  border: 1px solid rgba(0,0,0,.15);
  color: #666;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
}
.block-ctrl button:hover { background: #fff; color: #333; }
.block-ctrl .b-del { color: #e05a72; }
.block-ctrl .b-del:hover { background: #fff0f3; color: #d43d58; }

/* tombol tambah block */
.block-add {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 14px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--text2);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
}
.block-add:hover { border-color: var(--accent); color: var(--accent); }

.block-content {
  outline: none;
  border-radius: 4px;
  transition: box-shadow .15s, background .15s;
  cursor: text;
}
.block-content:hover { box-shadow: 0 0 0 2px var(--hover); }
.block-content:focus { box-shadow: 0 0 0 2px var(--accent); }

/* placeholder saat kosong */
.block-content.is-empty::before {
  content: attr(data-placeholder);
  color: #b0a89c;
  font-style: italic;
  opacity: .6;
}

/* ── Shared per-block typography (default, disesuaikan per template) ── */
.b-to {
  font-family: 'Playfair Display', serif;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: .02em;
}
.b-body {
  font-size: .95rem;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-word;
  text-align: left;
}
.b-footer-words {
  font-style: italic;
  font-size: .85rem;
}
.b-footer-name {
  font-style: normal;
  font-weight: 600;
  font-size: .85rem;
}

/* ── Template 1: Love Letter (cream + rose) ── */
.t-loveletter {
  background: #fdf6ee;
  color: #4a3f35;
  font-family: 'Playfair Display', serif;
  box-shadow: 0 12px 32px rgba(0,0,0,.25), inset 0 0 0 1px rgba(255,255,255,.8);
}
.t-loveletter::before {
  content: "❀";
  position: absolute;
  top: 10px; left: 16px;
  font-size: 2.2rem;
  color: #e3a8a0;
  opacity: .5;
  pointer-events: none;
}
.t-loveletter::after {
  content: "❀";
  position: absolute;
  bottom: 10px; right: 16px;
  font-size: 2.2rem;
  color: #e3a8a0;
  opacity: .5;
  transform: rotate(180deg);
  pointer-events: none;
}
.t-loveletter .b-to { color: #b0695f; }

/* ── Template 2: Rose Dust (pink dusty + floral border) ── */
.t-rosedust {
  background: #f8ecea;
  color: #5d4a48;
  font-family: 'Playfair Display', serif;
  box-shadow: 0 12px 32px rgba(0,0,0,.22);
  border: 3px solid #d9a8a2;
}
.t-rosedust::before {
  content: "✿";
  position: absolute;
  top: 8px; left: 50%;
  transform: translateX(-50%);
  font-size: 2rem;
  color: #c98a83;
  opacity: .6;
  pointer-events: none;
}
.t-rosedust::after {
  content: "✿";
  position: absolute;
  bottom: 8px; left: 50%;
  transform: translateX(-50%) rotate(180deg);
  font-size: 2rem;
  color: #c98a83;
  opacity: .6;
  pointer-events: none;
}
.t-rosedust .b-to { color: #b06d64; }

/* ── Template 3: Classic Serif (cream, thin line) ── */
.t-classic {
  background: #fbf7f0;
  color: #3f3a34;
  font-family: 'Playfair Display', serif;
  box-shadow: 0 10px 28px rgba(0,0,0,.2);
  border: 1px solid #e5dccf;
}
.t-classic::before {
  content: "";
  position: absolute;
  top: 26px; left: 50%;
  transform: translateX(-50%);
  width: 90px; height: 1px;
  background: #c9b89f;
  pointer-events: none;
}
.t-classic::after {
  content: "";
  position: absolute;
  bottom: 26px; left: 50%;
  transform: translateX(-50%);
  width: 90px; height: 1px;
  background: #c9b89f;
  pointer-events: none;
}
.t-classic .b-to { color: #6b5a45; letter-spacing: .06em; }

/* ── Template 4: Minimal Paper (white clean) ── */
.t-minimal {
  background: #ffffff;
  color: #2f2f2f;
  font-family: 'DM Serif Display', serif;
  box-shadow: 0 10px 30px rgba(0,0,0,.15);
}
.t-minimal .b-to { color: #555; letter-spacing: .04em; font-size: 1.1rem; }
.t-minimal .b-body { font-size: .9rem; line-height: 1.75; color: #444; }
.t-minimal .b-footer-words, .t-minimal .b-footer-name { color: #888; }

/* ── Template 5: Sakura Note (soft pink) ── */
.t-sakura {
  background: linear-gradient(160deg, #ffe9ee 0%, #ffdce5 100%);
  color: #6d4a52;
  font-family: 'Caveat', cursive;
  box-shadow: 0 12px 30px rgba(214, 90, 120, .25);
  border: 2px solid #ffc7d4;
}
.t-sakura::before {
  content: "🌸";
  position: absolute;
  top: 12px; left: 14px;
  font-size: 2rem;
  opacity: .5;
  pointer-events: none;
}
.t-sakura::after {
  content: "🌸";
  position: absolute;
  bottom: 12px; right: 14px;
  font-size: 2rem;
  opacity: .5;
  pointer-events: none;
}
.t-sakura .b-to { font-family: 'Caveat', cursive; font-size: 1.5rem; color: #c2547a; }
.t-sakura .b-body { font-size: 1.05rem; }
.t-sakura .b-footer-words, .t-sakura .b-footer-name { font-size: .95rem; }

/* ── Template 6: Candlelight (warm dark cream vintage) ── */
.t-candle {
  background: linear-gradient(150deg, #3d2f28 0%, #2e231d 100%);
  color: #f3e5d0;
  font-family: 'Playfair Display', serif;
  box-shadow: 0 12px 32px rgba(0,0,0,.4);
  border: 1px solid #5a4638;
}
.t-candle::before {
  content: "✦";
  position: absolute;
  top: 14px; right: 20px;
  font-size: 1.6rem;
  color: #d9a05b;
  opacity: .6;
  pointer-events: none;
}
.t-candle .b-to { color: #d9b98a; }
.t-candle .b-body { color: #f0e2cc; font-size: .92rem; }
.t-candle .b-footer-words, .t-candle .b-footer-name { color: #c9a87e; }

/* ── Modal preview export (mobile long-press save) ── */
.export-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .7);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 20px;
}
.export-modal.show { display: flex; }
.export-modal-box {
  background: var(--bg2);
  border-radius: 16px;
  padding: 18px;
  max-width: 420px;
  width: 100%;
  max-height: 90vh;
  overflow: auto;
  text-align: center;
  position: relative;
}
.export-modal-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: none;
  background: var(--hover);
  color: var(--text2);
  font-size: 15px;
  cursor: pointer;
  z-index: 2;
}
.export-modal-hint {
  font-size: 13px;
  color: var(--text2);
  margin-bottom: 12px;
  font-weight: 600;
}
.export-modal-img {
  width: 100%;
  height: auto;
  border-radius: 12px;
  display: block;
  -webkit-user-select: all;
  user-select: all;
  -webkit-touch-callout: default; /* iOS: izinkan long-press save */
}

/* responsive */
@media (max-width: 900px) {
  .mo-layout { grid-template-columns: 1fr; }
  .mo-preview { position: static; }
}
@media (max-width: 640px) {
  .preview-card { width: 100%; max-width: 340px; padding: 1.5rem; }
  .template-grid { gap: 6px; }
  .template-option { min-width: 74px; }
  .template-option .tpl-preview { width: 74px; height: 48px; }
  .mo-panel { padding: 16px; }
  /* preview full-width layar (bukan panel) biar card sebesar mungkin */
  .mo-preview {
    position: relative;
    left: 50%;
    right: 50%;
    width: 100vw;
    margin-left: -50vw;
    margin-right: -50vw;
  }
  .preview-wrap { width: 100%; max-width: 420px; }
}
