/* =========================================
   GIAO PROJECT — TÂM GIAO · loinhhan.css
   Diary / Letter UI
========================================= */

/* Force correct Vietnamese rendering for Charm */
@supports (font-variant-ligatures: none) {
  .field-input, .field-textarea, .left-body, .field-label, .field-hint,
  .left-title, .left-tag, .cover-label, .form-page-num, .thanks-body {
    font-variant-ligatures: none;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
  }
}
:root {
  --cream:   #F5EDD4;
  --cream-d: #EAD9B4;
  --cream-dd:#D4C090;
  --yellow:  #F9C900;
  --blue:    #2B5CB8;
  --pink:    #E8347C;
  --orange:  #E86428;
  --red:     #DC3040;
  --dark:    #1A1A1A;
  --white:   #FFFFFF;

  --paper:      #FBF5E6;
  --paper-line: rgba(43,92,184,0.12);
  --ink:        #2a1f10;
  --ink-soft:   #5a4830;

  --font-display: 'Playfair Display', Georgia, serif;
  --font-body:    'Be Vietnam Pro', sans-serif;
  --font-hand:    'Charm', 'Be Vietnam Pro', sans-serif;  /* Vietnamese handwriting */
  --radius: 4px;
  --trans: 0.3s cubic-bezier(0.4,0,0.2,1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body { font-family: var(--font-body); background: var(--cream); color: var(--dark); overflow-x: hidden; min-height: 100vh; }
a { text-decoration: none; color: inherit; }
button { font-family: var(--font-body); cursor: pointer; }

.star { color: var(--yellow); }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 0.9rem; padding: 0.8rem 1.6rem; border-radius: 50px; border: 2px solid transparent; cursor: pointer; transition: var(--trans); }
.btn-dark { background: var(--dark); color: var(--white); border-color: var(--dark); }
.btn-dark:hover { background: var(--red); border-color: var(--red); }
.btn-yellow { background: var(--yellow); color: var(--dark); border-color: var(--yellow); }
.btn-yellow:hover { background: var(--orange); border-color: var(--orange); }

/* ── NAV ── */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 200;
  background: rgba(245,237,212,0.95); backdrop-filter: blur(12px);
  border-bottom: 2px solid rgba(200,180,80,0.25);
  transition: border-color var(--trans), box-shadow var(--trans);
}
.nav.scrolled { border-bottom-color: var(--yellow); box-shadow: 0 4px 20px rgba(0,0,0,0.07); }
.nav-inner { max-width: 1100px; margin: 0 auto; padding: 0 1.5rem; height: 62px; display: flex; align-items: center; gap: 0.75rem; }
.nav-logo { font-family: var(--font-display); font-size: 1.3rem; font-weight: 900; color: var(--blue); flex-shrink: 0; }
.nav-center { flex: 1; display: flex; align-items: center; gap: 0.5rem; }
.nav-sep { color: #c8b880; }
.nav-subtitle { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: #7a6a55; }
.nav-links { display: flex; gap: 0.2rem; align-items: center; list-style: none; }
.nav-links a { font-size: 0.82rem; font-weight: 600; padding: 0.4rem 0.8rem; border-radius: 50px; transition: var(--trans); white-space: nowrap; }
.nav-links a:hover { background: var(--yellow); }
.nav-mbti { background: var(--yellow) !important; color: var(--dark) !important; }
.nav-mbti:hover { background: var(--orange) !important; }
.nav-burger { display: none; flex-direction: column; gap: 5px; background: none; border: none; padding: 8px; flex-shrink: 0; }
.nav-burger span { display: block; width: 22px; height: 2px; background: var(--dark); border-radius: 2px; }
.nav-mobile { display: none; flex-direction: column; padding: 0.75rem 1.5rem 1rem; gap: 0.35rem; border-top: 1px solid rgba(0,0,0,0.08); background: rgba(245,237,212,0.98); }
.nav-mobile a { font-size: 0.95rem; font-weight: 600; padding: 0.6rem 1rem; border-radius: 6px; display: block; }
.nav-mobile a:hover { background: var(--yellow); }
.nav-mobile.open { display: flex; }

/* ── SCREENS ── */
.screen { display: none; }
.screen.active { display: block; }

/* ═══════════════════════════════
   LANDING SCREEN
═══════════════════════════════ */
.landing-wrap {
  min-height: 100vh;
  padding: 100px 1.5rem 4rem;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  background:
    radial-gradient(ellipse at 20% 30%, rgba(249,201,0,0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 70%, rgba(232,52,124,0.1) 0%, transparent 50%),
    var(--cream);
}
.landing-eyebrow { font-family: var(--font-hand); font-size: 1.1rem; font-weight: 600; letter-spacing: 0.18em; color: var(--red); margin-bottom: 0.75rem; }
.landing-title { font-family: var(--font-display); font-size: clamp(2.4rem,7vw,4.5rem); font-weight: 900; line-height: 1.05; letter-spacing: -0.025em; color: var(--dark); margin-bottom: 1.5rem; }
.landing-title em { font-style: italic; color: var(--red); }
.landing-sub { font-size: 1.05rem; line-height: 1.75; color: var(--ink-soft); max-width: 520px; margin: 0 auto 3rem; }

/* Closed book */
.book-closed-wrap { perspective: 1200px; margin-bottom: 2.5rem; }
.book-closed {
  width: 220px; height: 280px;
  position: relative;
  transform-style: preserve-3d;
  transform: rotateY(-20deg) rotateX(5deg);
  transition: transform 0.5s ease;
  cursor: pointer;
  filter: drop-shadow(12px 16px 24px rgba(0,0,0,0.25));
}
.book-closed:hover { transform: rotateY(-28deg) rotateX(8deg) scale(1.04); }
.book-cover {
  position: absolute; inset: 0;
  border-radius: 2px 12px 12px 2px;
  overflow: hidden;
}
.book-cover-inner {
  width: 100%; height: 100%;
  background: linear-gradient(145deg, #E8347C 0%, #c02060 60%, #9a1a50 100%);
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 1.5rem;
}
.cover-pattern {
  position: absolute; inset: 0;
  background-image:
    repeating-linear-gradient(0deg, rgba(255,255,255,0.04) 0, rgba(255,255,255,0.04) 1px, transparent 1px, transparent 18px),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.04) 0, rgba(255,255,255,0.04) 1px, transparent 1px, transparent 18px);
}
.cover-title-wrap { text-align: center; z-index: 1; position: relative; }
.cover-label { font-family: var(--font-hand); font-size: 1.5rem; font-weight: 700; color: var(--yellow); letter-spacing: 0.08em; line-height: 1.2; }
.cover-sub { font-family: var(--font-hand); font-size: 0.85rem; color: rgba(255,255,255,0.7); margin-top: 0.25rem; }
.cover-star { position: absolute; bottom: 1.5rem; right: 1.5rem; font-size: 1.5rem; color: rgba(249,201,0,0.6); }
.cover-ribbon { position: absolute; top: 0; left: 0; width: 0; height: 0; border-style: solid; border-width: 32px 32px 0 0; border-color: var(--yellow) transparent transparent transparent; }
.book-spine { position: absolute; left: -16px; top: 0; bottom: 0; width: 16px; background: linear-gradient(to right, #7a0a30, #c02060); border-radius: 2px 0 0 2px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.book-spine span { font-family: var(--font-hand); font-size: 0.6rem; color: rgba(255,255,255,0.6); writing-mode: vertical-rl; text-orientation: mixed; letter-spacing: 0.1em; white-space: nowrap; padding: 0.5rem 0; }
.book-pages-edge { position: absolute; right: -8px; top: 4px; bottom: 4px; width: 8px; display: flex; flex-direction: column; justify-content: space-evenly; }
.pe-line { height: 2px; background: linear-gradient(to right, var(--cream-d), var(--cream)); opacity: calc(1 - var(--i) * 0.15); margin: 1px 0; }

.open-btn {
  display: inline-flex; align-items: center; gap: 0.6rem;
  background: var(--dark); color: var(--white);
  font-family: var(--font-body); font-size: 1rem; font-weight: 700;
  padding: 1rem 2rem; border-radius: 50px; border: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  transition: all 0.3s ease; margin-bottom: 1rem;
}
.open-btn:hover { background: var(--red); transform: translateY(-3px); box-shadow: 0 12px 32px rgba(220,48,64,0.3); }
.open-btn-icon { font-size: 1.2rem; }
.landing-note { font-size: 0.75rem; color: var(--ink-soft); opacity: 0.6; letter-spacing: 0.08em; }

/* ═══════════════════════════════
   DIARY SCREEN
═══════════════════════════════ */
#screen-diary {
  min-height: 100vh;
  padding-top: 62px;
  background:
    radial-gradient(ellipse at 10% 20%, rgba(249,201,0,0.1) 0%, transparent 40%),
    radial-gradient(ellipse at 90% 80%, rgba(232,52,124,0.08) 0%, transparent 40%),
    #e8d8b0;
  display: flex; flex-direction: column; align-items: center;
  padding-bottom: 4rem;
}

.close-diary-btn {
  align-self: flex-end; margin: 1rem 2rem 0;
  background: none; border: 1.5px solid rgba(0,0,0,0.2);
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.1em;
  color: var(--ink-soft); padding: 0.4rem 0.9rem; border-radius: 50px;
  transition: var(--trans); flex-shrink: 0;
}
.close-diary-btn:hover { background: var(--dark); color: var(--white); border-color: var(--dark); }

/* Book scene */
.diary-scene {
  display: flex; align-items: stretch;
  gap: 0;
  width: min(960px, 96vw);
  margin: 1.5rem auto 0;
  filter: drop-shadow(0 24px 48px rgba(0,0,0,0.3));
  animation: bookOpen 0.7s cubic-bezier(0.4,0,0.2,1) both;
}

@keyframes bookOpen {
  from { opacity: 0; transform: scale(0.92) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* Pages */
.page {
  flex: 1;
  background: var(--paper);
  position: relative;
  overflow: hidden;
  /* min-height removed — height is now driven by the taller page */
}
.page-left  { border-radius: 6px 0 0 6px; box-shadow: -4px 0 12px rgba(0,0,0,0.1) inset; }
.page-right { border-radius: 0 6px 6px 0; }

/* Ruled lines */
.ruled-lines {
  position: absolute; inset: 0;
  padding-top: 68px;
  pointer-events: none;
}
.ruled-line {
  position: absolute;
  left: 0; right: 0;
  top: calc(68px + (var(--r) - 1) * 38px);
  height: 1px;
  background: var(--paper-line);
}
/* Red margin line */
.page-right .ruled-lines::before {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  left: 52px;
  width: 1.5px;
  background: rgba(220,48,64,0.18);
}

/* Spine center */
.book-center-spine {
  width: 14px;
  background: linear-gradient(to right, #c8a860, #e8c880, #c8a860);
  flex-shrink: 0;
  position: relative;
  box-shadow: 0 0 12px rgba(0,0,0,0.25);
}
.book-center-spine::before, .book-center-spine::after {
  content: '';
  position: absolute; left: 0; right: 0;
  height: 2px; background: rgba(0,0,0,0.15);
}
.book-center-spine::before { top: 20px; }
.book-center-spine::after  { bottom: 20px; }

/* Page inner padding */
.page-inner { padding: 2rem 1.75rem 2rem; height: 100%; position: relative; z-index: 1; }
.page-left  .page-inner { padding-left: 2rem; }
.page-right .page-inner { padding-left: 3.5rem; } /* account for margin line */

/* LEFT PAGE CONTENT */
.left-tag { font-family: var(--font-hand); font-size: 0.9rem; letter-spacing: 0.18em; color: var(--red); margin-bottom: 1rem; font-weight: 600; }
.left-title { font-family: var(--font-hand); font-size: clamp(1.6rem, 3.5vw, 2.4rem); font-weight: 700; color: var(--ink); line-height: 1.15; margin-bottom: 1.25rem; }
.left-divider { text-align: center; color: var(--orange); font-size: 0.9rem; letter-spacing: 0.3em; margin: 1.25rem 0; opacity: 0.7; }
.left-body { font-family: var(--font-hand); font-size: 1.05rem; line-height: 1.85; color: var(--ink-soft); margin-bottom: 1rem; }
.left-body strong { color: var(--ink); font-weight: 700; }
.left-body em { font-style: italic; color: var(--red); }
.left-seal { display: flex; justify-content: center; margin-top: 1.5rem; }
.seal-circle {
  width: 80px; height: 80px;
  border: 2px solid var(--red); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-hand); font-size: 0.62rem; font-weight: 700;
  letter-spacing: 0.06em; text-align: center; line-height: 1.5;
  color: var(--red); transform: rotate(-15deg);
  position: relative; opacity: 0.75;
}
.seal-circle::before { content: ''; position: absolute; inset: 5px; border: 1px solid var(--red); border-radius: 50%; }

/* RIGHT PAGE — FORM */
.form-page-num { font-family: var(--font-hand); font-size: 0.8rem; color: rgba(90,72,48,0.4); text-align: right; margin-bottom: 0.5rem; }

.field-group { margin-bottom: 1.5rem; }
.field-label {
  display: flex; align-items: flex-start; gap: 0.5rem;
  font-family: var(--font-hand); font-size: 1.05rem; font-weight: 700;
  color: var(--ink); line-height: 1.4; margin-bottom: 0.35rem;
}
.field-num { color: var(--red); font-size: 1.1rem; flex-shrink: 0; margin-top: -1px; }
.field-hint { font-family: var(--font-hand); font-size: 0.85rem; color: var(--ink-soft); opacity: 0.75; line-height: 1.5; margin-bottom: 0.5rem; font-style: italic; padding-left: 1.4rem; }

/* Inputs styled as handwritten lines */
.field-input, .field-textarea {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 2px solid rgba(43,92,184,0.2);
  outline: none;
  font-family: var(--font-hand);
  font-size: 1.1rem;
  color: var(--ink);
  padding: 0.4rem 0.25rem;
  transition: border-color 0.2s;
  line-height: 1.7;
  resize: none;
}
.field-input::placeholder, .field-textarea::placeholder { color: rgba(90,72,48,0.35); font-style: italic; }
.field-input:focus, .field-textarea:focus { border-bottom-color: var(--blue); }
.field-input.error, .field-textarea.error { border-bottom-color: var(--red); }
.field-textarea { display: block; border: 1.5px solid rgba(43,92,184,0.15); border-radius: 6px; padding: 0.6rem 0.5rem; background: rgba(255,252,240,0.5); }
.field-textarea:focus { border-color: var(--blue); background: rgba(255,252,240,0.8); }

.form-footer { margin-top: 1.5rem; display: flex; flex-direction: column; align-items: flex-start; gap: 0.5rem; }
.submit-btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  background: var(--dark); color: var(--white);
  font-family: var(--font-hand); font-size: 1.15rem; font-weight: 700;
  padding: 0.75rem 1.75rem; border-radius: 50px; border: none;
  box-shadow: 3px 3px 0 var(--blue);
  transition: all 0.25s ease;
}
.submit-btn:hover { background: var(--red); box-shadow: 3px 3px 0 #9a1a50; transform: translate(-1px,-1px); }
.submit-btn:active { transform: translate(1px,1px); box-shadow: none; }
.submit-btn:disabled { opacity: 0.6; cursor: wait; }
.form-note { font-family: var(--font-hand); font-size: 0.88rem; }

/* ═══════════════════════════════
   THANK YOU SCREEN
═══════════════════════════════ */
#screen-thanks {
  min-height: 100vh; padding: 80px 1.5rem 4rem;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(ellipse at 30% 40%, rgba(249,201,0,0.2) 0%, transparent 50%),
    radial-gradient(ellipse at 75% 65%, rgba(232,52,124,0.12) 0%, transparent 50%),
    var(--cream);
}
.thanks-wrap {
  max-width: 560px; text-align: center;
  animation: fadeUp 0.7s ease both;
}
.thanks-envelope { margin: 0 auto 1rem; position: relative; display: inline-block; }
.envelope-body { width: 100px; height: 70px; background: var(--yellow); border-radius: 4px 4px 8px 8px; position: relative; box-shadow: 4px 4px 0 var(--orange); overflow: hidden; display: flex; align-items: center; justify-content: center; }
.envelope-flap { position: absolute; top: 0; left: 0; right: 0; height: 0; border-left: 50px solid transparent; border-right: 50px solid transparent; border-top: 36px solid var(--orange); }
.envelope-letter { font-size: 2rem; z-index: 1; }
.thanks-stamp {
  display: inline-block;
  border: 2px solid var(--red); border-radius: 50%; width: 70px; height: 70px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-hand); font-size: 0.52rem; font-weight: 700; letter-spacing: 0.08em;
  text-align: center; line-height: 1.5; color: var(--red);
  transform: rotate(-12deg); margin: 0.5rem auto 1.5rem;
  position: relative; opacity: 0.8;
}
.thanks-stamp::before { content: ''; position: absolute; inset: 4px; border: 1px solid var(--red); border-radius: 50%; }
.thanks-title { font-family: var(--font-display); font-size: clamp(1.5rem,5vw,2.2rem); font-weight: 900; color: var(--dark); line-height: 1.2; margin-bottom: 1.25rem; letter-spacing: -0.015em; }
.thanks-body { font-family: var(--font-hand); font-size: 1.1rem; line-height: 1.8; color: var(--ink-soft); margin-bottom: 1rem; }
.thanks-body strong { color: var(--red); font-weight: 700; }
.thanks-actions { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; margin-top: 2rem; }

/* FOOTER */
.site-footer { background: var(--dark); border-top: 3px solid var(--yellow); padding: 1.25rem 1.5rem; }
.footer-inner { max-width: 1100px; margin: 0 auto; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.footer-logo { font-family: var(--font-display); font-size: 1.1rem; font-weight: 900; color: var(--yellow); }
.footer-note { font-size: 0.72rem; letter-spacing: 0.1em; color: rgba(255,255,255,0.35); }

/* Animations */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════
   RESPONSIVE — MOBILE
═══════════════════════════════ */
@media (max-width: 900px) {
  .nav-links { display: none; }
  .nav-burger { display: flex; }

  .landing-title { font-size: clamp(2rem, 8vw, 3rem); }
  .book-closed { width: 180px; height: 230px; }

  /* Stack pages vertically on mobile */
  .diary-scene { flex-direction: column; gap: 0; width: min(480px, 96vw); }
  .page { min-height: auto; }
  .page-left  { border-radius: 6px 6px 0 0; }
  .page-right { border-radius: 0 0 6px 6px; }
  .book-center-spine { width: 100%; min-height: 10px; height: 10px; background: linear-gradient(to bottom, #c8a860, #e8c880, #c8a860); }
  .book-center-spine::before { top: 2px; left: 20px; right: 20px; height: 1px; width: auto; }
  .book-center-spine::after  { bottom: 2px; left: 20px; right: 20px; height: 1px; width: auto; }

  .page-inner { padding: 1.5rem 1.25rem; }
  .page-right .page-inner { padding-left: 1.25rem; }
  .page-right .ruled-lines::before { display: none; }

  .left-title { font-size: 1.6rem; }
  .left-body  { font-size: 1rem; }
  .field-label, .field-input, .field-textarea { font-size: 1rem; }
  .close-diary-btn { margin: 0.75rem 1rem 0; }
  .thanks-actions { flex-direction: column; }
  .thanks-actions .btn { width: 100%; justify-content: center; }
}

@media (max-width: 480px) {
  .landing-wrap { padding: 90px 1rem 3rem; }
  .book-closed { width: 150px; height: 190px; }
  .open-btn { font-size: 0.9rem; padding: 0.85rem 1.5rem; }
}

/* ═══════════════════════════════
   INLINE THANKS — v7 design inside diary right page
═══════════════════════════════ */
.thanks-wrap-inline {
  text-align: center;
  padding: 1rem 0.5rem;
  animation: fadeInThanks 0.6s ease both;
}
@keyframes fadeInThanks {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Envelope graphic */
.thanks-envelope { margin: 0 auto 0.75rem; display: inline-block; }
.envelope-body {
  width: 86px; height: 60px;
  background: var(--yellow);
  border-radius: 4px 4px 8px 8px;
  position: relative;
  box-shadow: 3px 3px 0 var(--orange);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.envelope-flap {
  position: absolute; top: 0; left: 0; right: 0; height: 0;
  border-left: 43px solid transparent;
  border-right: 43px solid transparent;
  border-top: 30px solid var(--orange);
}
.envelope-letter { font-size: 1.6rem; z-index: 1; }

/* Stamp */
.thanks-stamp {
  width: 64px; height: 64px;
  border: 2px solid var(--red); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-hand); font-size: 0.5rem; font-weight: 700;
  letter-spacing: 0.08em; text-align: center; line-height: 1.5;
  color: var(--red); transform: rotate(-12deg);
  margin: 0.5rem auto 1.25rem;
  position: relative; opacity: 0.8;
}
.thanks-stamp::before {
  content: ''; position: absolute; inset: 4px;
  border: 1px solid var(--red); border-radius: 50%;
}

/* Title & body — same fonts as v7 */
.thanks-title {
  font-family: var(--font-display);
  font-size: clamp(1.1rem, 2.5vw, 1.5rem);
  font-weight: 900; color: var(--ink);
  line-height: 1.2; margin-bottom: 1rem;
  letter-spacing: -0.015em;
}
.thanks-body {
  font-family: var(--font-hand);
  font-size: 0.98rem; line-height: 1.8;
  color: var(--ink-soft); margin-bottom: 0.75rem;
}
.thanks-body strong { color: var(--red); font-weight: 700; }

/* Buttons */
.thanks-actions {
  display: flex; gap: 0.6rem;
  justify-content: center; flex-wrap: wrap;
  margin-top: 1.5rem;
}
.thanks-actions .btn { font-size: 0.85rem; padding: 0.7rem 1.25rem; }

/* Mobile */
@media (max-width: 900px) {
  .thanks-actions { flex-direction: column; }
  .thanks-actions .btn { width: 100%; justify-content: center; }
}
