/* My Tree: the web tree pages (send-message.html, create-tree.html). A coloured page per tree type
   with white cards on it, in Poppins like site.css. */

@font-face { font-family: 'Poppins'; src: url('/assets/fonts/poppins-400.woff') format('woff'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Poppins'; src: url('/assets/fonts/poppins-600.woff') format('woff'); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: 'Poppins'; src: url('/assets/fonts/poppins-700.woff') format('woff'); font-weight: 700; font-style: normal; font-display: swap; }

:root {
  /* Page colour per tree type (tree-app.js sets data-occasion on <html>) */
  --page: linear-gradient(180deg, #e12a33 0%, #d11d32 50%, #b8102d 100%);
  --page-solid: #c8102e;
  --ink: #111113;
  --ink-2: #55555c;
  --ink-3: #6e6e76;
  --soft: #f4f2ee;
  --rule: #e7e4df;
  --red: #c8102e;
  --danger: #c8102e;
  --font: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --radius: 18px;
}
[data-occasion='birthday'] { --page: linear-gradient(180deg, #f59e0b 0%, #ea7a0c 55%, #d55b0b 100%); --page-solid: #d55b0b; }
[data-occasion='valentine'] { --page: linear-gradient(180deg, #ec4f8d 0%, #db2777 55%, #be185d 100%); --page-solid: #be185d; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--page-solid); }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  font-family: var(--font); font-size: 1rem; line-height: 1.55; color: #fff;
  background: var(--page) fixed; -webkit-font-smoothing: antialiased; overflow-x: hidden;
}
body.has-modal { overflow: hidden; }
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
[hidden] { display: none !important; }
.center { text-align: center; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Loading (until the strings arrive) ---------- */
body.is-loading main, body.is-loading .tp-footer { visibility: hidden; }
body.is-loading::after {
  content: ''; position: fixed; inset: 50% auto auto 50%; width: 40px; height: 40px; margin: -20px 0 0 -20px;
  border: 3px solid rgba(255, 255, 255, 0.35); border-top-color: #fff; border-radius: 50%; animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { width: 44px; height: 44px; margin: 0 auto 16px; border: 3px solid var(--rule); border-top-color: var(--ink); border-radius: 50%; animation: spin 0.9s linear infinite; }

/* ---------- Header ---------- */
.tp-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: min(100% - 28px, 1100px); margin: 0 auto; padding: 14px 0; }
.logo { display: inline-flex; align-items: center; gap: 10px; font-size: 1.2rem; font-weight: 700; letter-spacing: -0.02em; text-decoration: none; }
.logo img { width: 34px; height: 34px; border-radius: 10px; }
.header-actions { display: flex; align-items: center; gap: 10px; }

/* ---------- Layout ---------- */
main { flex: 1; width: min(100% - 28px, 540px); margin: 0 auto; padding: 6px 0 36px; }
.view.is-active { animation: rise 0.3s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.panel { position: relative; padding: clamp(22px, 5vw, 30px); border-radius: 28px; background: #fff; color: var(--ink); box-shadow: 0 24px 60px -30px rgba(40, 0, 10, 0.55); }
.panel + .panel { margin-top: 14px; }
.view-head { position: relative; margin-bottom: 18px; text-align: center; }
.view-head .back { position: absolute; inset-inline-start: 0; top: 0; }
/* Keep the title clear of the back button on narrow screens */
.view-head .back ~ .title { padding-inline: 46px; }
.eyebrow { margin: 0 0 4px; color: var(--ink-3); font-size: 0.86rem; font-weight: 600; }
.title { margin: 0; font-size: clamp(1.55rem, 1.2rem + 1.8vw, 2rem); font-weight: 700; line-height: 1.12; letter-spacing: -0.03em; text-wrap: balance; }
.title:focus { outline: none; }
.subtitle { margin: 8px 0 0; color: var(--ink-2); }
.fine-print { margin: 10px 0 0; color: var(--ink-3); font-size: 0.86rem; }
.big-emoji { margin: 0 0 8px; font-size: 3rem; line-height: 1; text-align: center; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 54px; padding: 0 24px;
  border: 0; border-radius: 999px; font-weight: 600; text-decoration: none; cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn[disabled] { opacity: 0.35; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #000; }
.btn-gold { background: var(--page-solid); color: #fff; }
.btn-gold:hover { filter: brightness(0.94); }
.btn-ghost { background: #fff; color: var(--ink); box-shadow: inset 0 0 0 2px var(--rule); }
.btn-ghost:hover { box-shadow: inset 0 0 0 2px var(--ink); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { min-height: 42px; padding: 0 16px; font-size: 0.92rem; }
.btn-row { display: flex; gap: 10px; }
.btn-row > .btn { flex: 1; }
.icon-btn { display: inline-grid; place-items: center; width: 42px; height: 42px; border: 0; border-radius: 50%; background: var(--soft); color: var(--ink); font-size: 1.1rem; cursor: pointer; }
.icon-btn:hover { background: var(--rule); }
[dir='rtl'] .icon-btn.back { transform: scaleX(-1); }
.link-btn { padding: 6px; border: 0; background: none; color: var(--ink-3); font-size: 0.88rem; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.link-btn:hover { color: var(--ink); }

/* ---------- Fields ---------- */
.field { display: grid; gap: 6px; margin-bottom: 14px; text-align: start; }
.field-label { color: var(--ink-2); font-size: 0.88rem; font-weight: 600; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.input, .textarea, .select {
  width: 100%; min-height: 54px; padding: 12px 18px; border: 2px solid transparent; border-radius: var(--radius);
  background: var(--soft); color: var(--ink); font-size: 1rem; outline: none; transition: border-color 0.15s;
}
.textarea { min-height: 130px; resize: vertical; line-height: 1.5; }
.select { appearance: none; cursor: pointer; }
.select option { color: #111; }
.input:focus, .textarea:focus, .select:focus { border-color: var(--ink); background: #fff; }
.input::placeholder, .textarea::placeholder { color: var(--ink-3); }
.input.is-invalid, .textarea.is-invalid { border-color: var(--danger); }
.code-input { font-size: 1.5rem; font-weight: 700; letter-spacing: 0.16em; text-align: center; text-transform: uppercase; }
.code-input::placeholder { font-size: 1.1rem; font-weight: 500; letter-spacing: 0.04em; text-transform: none; }
.counter { margin: -8px 0 12px; color: var(--ink-3); font-size: 0.78rem; text-align: end; }
.field-error { min-height: 1.2em; margin: 6px 0 0; color: var(--danger); font-size: 0.9rem; font-weight: 600; }
.field-error:empty { display: none; }

/* Switch */
.switch { display: flex; align-items: center; gap: 12px; margin: 6px 0 4px; color: var(--ink); cursor: pointer; text-align: start; }
.switch input { position: absolute; opacity: 0; }
.switch-track { position: relative; flex: none; width: 50px; height: 30px; border-radius: 999px; background: var(--rule); transition: background 0.2s; }
.switch-track::after { content: ''; position: absolute; top: 3px; inset-inline-start: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25); transition: transform 0.2s; }
.switch input:checked + .switch-track { background: var(--ink); }
.switch input:checked + .switch-track::after { transform: translateX(20px); }
[dir='rtl'] .switch input:checked + .switch-track::after { transform: translateX(-20px); }
.switch input:focus-visible + .switch-track { outline: 3px solid var(--ink); outline-offset: 3px; }
.notice { display: flex; gap: 8px; margin: 8px 0 0; padding: 10px 14px; border-radius: 14px; background: var(--soft); color: var(--ink-2); font-size: 0.88rem; text-align: start; }
.legal-notice { margin: 14px 0; color: var(--ink-3); font-size: 0.82rem; text-align: center; }
.legal-notice a { color: var(--ink); font-weight: 600; text-underline-offset: 3px; }

/* Checkboxes in dialogs */
.checks { display: grid; gap: 8px; margin: 14px 0; }
.check { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; background: var(--soft); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--ink); }

/* ---------- Tile grids (trees, toppers, gifts, tree types) ---------- */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 0 0 18px; padding: 0; list-style: none; }
.tiles-4 { grid-template-columns: repeat(4, 1fr); }
.tile {
  position: relative; display: grid; place-items: center; width: 100%; aspect-ratio: 1; padding: 8px; border: 2px solid transparent;
  border-radius: var(--radius); background: var(--soft); cursor: pointer; transition: transform 0.15s, border-color 0.15s;
}
.tile:active { transform: scale(0.96); }
.tile img { width: 100%; height: 100%; object-fit: contain; }
.tile[aria-pressed='true'] { border-color: var(--ink); background: #fff; }
.tile[aria-pressed='true']::after {
  content: '\2713'; position: absolute; top: -7px; inset-inline-end: -7px; display: grid; place-items: center; width: 24px; height: 24px;
  border-radius: 50%; background: var(--ink); color: #fff; font-size: 0.8rem; font-weight: 700;
}
.occasion-cards { display: grid; gap: 10px; margin: 0 0 18px; }
/* The gifts as one swipeable row above the letter (visitor page) */
.gift-strip { display: flex; gap: 10px; margin: 6px -4px 16px; padding: 8px 4px 10px; overflow-x: auto; list-style: none; scroll-snap-type: x proximity; scrollbar-width: thin; }
.gift-strip li { flex: none; width: 76px; scroll-snap-align: start; }
.gift-strip .tile { padding: 6px; border-radius: 16px; }

/* Email and password */
.password-field { position: relative; display: block; }
.password-field .input { width: 100%; padding-inline-end: 52px; }
.password-toggle {
  position: absolute; top: 50%; inset-inline-end: 6px; display: grid; place-items: center; width: 40px; height: 40px;
  border: 0; border-radius: 50%; background: none; font-size: 1.05rem; cursor: pointer; transform: translateY(-50%); opacity: 0.55;
}
.password-toggle[aria-pressed='true'], .password-toggle:hover { opacity: 1; }

/* An account's trees */
.tree-switch { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; padding: 0; list-style: none; }
.chip { padding: 8px 14px; border: 2px solid var(--rule); border-radius: 999px; background: #fff; color: var(--ink); font: inherit; font-size: 0.9rem; font-weight: 600; cursor: pointer; }
.chip[aria-pressed='true'] { border-color: var(--ink); background: var(--ink); color: #fff; }
.occasion-card { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px; border: 2px solid transparent; border-radius: 20px; background: var(--soft); color: var(--ink); cursor: pointer; text-align: start; }
.occasion-card img { width: 60px; height: 60px; flex: none; }
.occasion-card[aria-pressed='true'] { border-color: var(--ink); background: #fff; }
.occasion-card strong { display: block; font-size: 1.05rem; }
.occasion-card span { color: var(--ink-2); font-size: 0.9rem; }

/* ---------- Tree stage ---------- */
.stage { position: relative; width: min(100%, 340px); margin: 0 auto; aspect-ratio: 1 / 1.08; }
.stage-glow { display: none; }
.stage-tree { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; margin: 0 auto; }
.stage-topper { position: absolute; top: 0; left: 50%; z-index: 2; width: 30%; transform: translateX(-50%); }
.stage-gifts { position: absolute; inset: 0; z-index: 3; }
.stage-gift { position: absolute; width: 17%; transform: translate(-50%, -50%); animation: pop 0.35s ease-out both; }
.stage-gift img { width: 100%; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.25)); }
.stage-gift-name {
  position: absolute; top: 92%; left: 50%; max-width: 140%; padding: 1px 8px; overflow: hidden; transform: translateX(-50%);
  border-radius: 999px; background: var(--ink); color: #fff; font-size: 0.66rem; font-weight: 600; white-space: nowrap; text-overflow: ellipsis;
}
@keyframes pop { from { opacity: 0; transform: translate(-50%, -50%) scale(0.6); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } }
.stage-pages { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 6px 0 0; color: var(--ink-2); font-size: 0.9rem; }
.tree-name { margin: 14px 0 0; font-size: clamp(1.6rem, 1.2rem + 1.8vw, 2.1rem); font-weight: 700; line-height: 1.1; letter-spacing: -0.03em; text-align: center; overflow-wrap: anywhere; }
.tree-name:focus { outline: none; }
.tree-meta { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 10px 0 0; padding: 0; list-style: none; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--soft); color: var(--ink-2); font-size: 0.86rem; font-weight: 600; }
.pill-accent { background: var(--ink); color: #fff; }

/* ---------- Message card (write) ---------- */
.letter { position: relative; margin-top: 40px; padding: 48px 16px 16px; border-radius: 22px; background: var(--soft); }
.letter-gift { position: absolute; top: -38px; left: 50%; width: 76px; height: 76px; padding: 8px; transform: translateX(-50%); border-radius: 50%; background: #fff; box-shadow: 0 6px 16px -8px rgba(0, 0, 0, 0.4); }
.letter .input, .letter .textarea { background: #fff; }
.letter .input:focus, .letter .textarea:focus { border-color: var(--ink); }

/* ---------- Owner panel ---------- */
.share-box { display: grid; gap: 12px; }
.copy-row { display: flex; gap: 8px; }
.copy-value {
  flex: 1; min-width: 0; display: flex; align-items: center; min-height: 48px; padding: 0 16px; overflow: hidden;
  border-radius: 999px; background: var(--soft); white-space: nowrap; text-overflow: ellipsis;
}
.copy-value.is-code { justify-content: center; color: var(--ink); font-size: 1.3rem; font-weight: 700; letter-spacing: 0.16em; }
.copy-value.is-link { color: var(--ink-2); font-size: 0.86rem; direction: ltr; }
.inbox-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 0 0 12px; }
.inbox-head h2 { margin: 0; font-size: 1.4rem; letter-spacing: -0.02em; }
.messages { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.message { padding: 14px; border-radius: var(--radius); background: var(--soft); }
.message-top { display: flex; align-items: center; gap: 12px; }
.message-top img { width: 52px; height: 52px; flex: none; }
.message-from { min-width: 0; flex: 1; }
.message-from strong { display: block; overflow-wrap: anywhere; }
.badge { display: inline-flex; align-items: center; gap: 4px; margin-top: 2px; padding: 1px 8px; border-radius: 999px; background: #ffe9a8; color: #6b4f00; font-size: 0.74rem; font-weight: 700; }
.message-text { margin: 12px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.message-locked { margin: 12px 0 0; color: var(--ink-3); font-size: 0.9rem; }
.message-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.danger-zone { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--rule); }

/* ---------- Private link ---------- */
.private-link { border: 2px dashed var(--page-solid); }
.private-link h2 { margin: 0; font-size: 1.25rem; letter-spacing: -0.02em; }
.private-link .fine-print { margin: 6px 0 14px; }
.private-link.is-new { animation: private-link-glow 1.6s ease-in-out 3; }
@keyframes private-link-glow { 50% { box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.7), 0 24px 60px -30px rgba(40, 0, 10, 0.55); } }
@media (prefers-reduced-motion: reduce) { .private-link.is-new { animation: none; } }

/* ---------- Call to action ---------- */
.cta { display: grid; gap: 12px; text-align: center; }
.cta h2 { margin: 0; font-size: 1.35rem; letter-spacing: -0.02em; }
.cta p { margin: 0; color: var(--ink-2); }

/* ---------- Dialogs and toast ---------- */
.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(10, 10, 11, 0.6); animation: fade 0.2s ease; }
.modal { width: min(100%, 440px); max-height: calc(100vh - 32px); overflow-y: auto; padding: 24px; border-radius: 28px; background: #fff; color: var(--ink); box-shadow: 0 40px 90px -30px rgba(0, 0, 0, 0.7); animation: rise 0.25s ease-out; }
.modal-title { margin: 0 0 6px; font-size: 1.4rem; line-height: 1.2; letter-spacing: -0.02em; text-align: center; }
.modal-text { margin: 0 0 12px; color: var(--ink-2); text-align: center; }
.modal-emoji { margin: 0 0 6px; font-size: 2.6rem; line-height: 1; text-align: center; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions > .btn { flex: 1; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.toast {
  position: fixed; left: 50%; bottom: 20px; z-index: 60; width: max-content; max-width: calc(100% - 32px); padding: 12px 20px;
  transform: translate(-50%, 160%); border-radius: 999px; background: var(--ink); color: #fff; box-shadow: 0 16px 34px -12px rgba(0, 0, 0, 0.6);
  font-weight: 600; opacity: 0; transition: transform 0.3s ease, opacity 0.3s ease; pointer-events: none;
}
.toast.is-shown { transform: translate(-50%, 0); opacity: 1; }
.toast-error { background: #fff; color: var(--danger); }

/* ---------- Footer ---------- */
.tp-footer { width: min(100% - 28px, 1100px); margin: 0 auto; padding: 22px 0 30px; color: rgba(255, 255, 255, 0.82); font-size: 0.85rem; text-align: center; }
.tp-footer nav { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px; margin-bottom: 10px; }
.tp-footer nav a { color: #fff; font-weight: 600; text-decoration: none; }
.tp-footer nav a:hover { text-decoration: underline; }
.tp-footer p { margin: 4px 0; }

@media (max-width: 420px) {
  .tiles-4 { grid-template-columns: repeat(3, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
