/* ==========================================================================
   Digital Rose — Handcrafted Experience by JJ
   Aesthetic: Boutique Indie iOS (Things 3 / Craft / Apple Notes)
   Typography: SF Mono & Editorial Serif (New York / Charter)
   Palette: Warm Porcelain, Velvety Ruby, Soft Coral, Botanical Greens
   ========================================================================== */

:root {
  /* Editorial Typography */
  --font-editorial: "New York", "Charter", "Iowan Old Style", Georgia, serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", sans-serif;
  --font-mono: "SF Mono", ui-monospace, "Cascadia Code", Menlo, Monaco, monospace;

  /* Warm Organic Palette */
  --bg-porcelain: #fbfbf9;
  --card-bg: rgba(255, 255, 255, 0.95);
  --card-border: rgba(0, 0, 0, 0.07);
  --subcard-bg: rgba(255, 255, 255, 0.82);

  --text-main: #1c1917;
  --text-secondary: #71717a;
  --text-muted: #a1a1aa;

  /* Handcrafted Accents */
  --accent-rose: #e11d48;
  --accent-rose-soft: #fff1f2;
  --accent-rose-border: #fecdd3;
  --accent-wine: #881337;
  --accent-green: #2b5329;
  --accent-green-soft: #f0fdf4;
  --accent-amber: #b45309;

  /* Curves & Tactile Physics */
  --radius-card: 26px;
  --radius-subcard: 16px;
  --radius-pill: 999px;
  --radius-btn: 14px;

  --ease-spring: cubic-bezier(0.22, 1, 0.36, 1);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.02), 0 14px 36px -8px rgba(0, 0, 0, 0.05);
  --shadow-bloom: 0 2px 6px rgba(225, 29, 72, 0.03), 0 18px 44px -8px rgba(225, 29, 72, 0.12);
}

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--bg-porcelain);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Page Layout */
body {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem 0.85rem;
  padding-top: calc(0.85rem + env(safe-area-inset-top, 0px));
  padding-bottom: calc(0.85rem + env(safe-area-inset-bottom, 0px));
  position: relative;
}

/* Warm Paper Atmosphere (Subtle vignette, zero artificial neon blobs) */
.ambient-canvas {
  position: fixed;
  inset: 0;
  background-color: var(--bg-porcelain);
  background-image: 
    radial-gradient(at 100% 0%, rgba(254, 205, 211, 0.22) 0px, transparent 50%),
    radial-gradient(at 0% 100%, rgba(224, 242, 254, 0.18) 0px, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* Container */
.app-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 410px;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  transition: opacity 0.3s ease;
}

/* ==========================================================================
   Handcrafted Card (Things 3 / Craft Indie Aesthetic)
   ========================================================================== */
.terminal-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow 0.6s var(--ease-spring), border-color 0.6s ease;
}

.terminal-card.bloomed {
  border-color: rgba(225, 29, 72, 0.25);
  box-shadow: var(--shadow-bloom);
}

/* Boutique Note Header */
.note-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.15rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-secondary);
  user-select: none;
}

.header-stamp {
  display: flex;
  align-items: center;
  gap: 7px;
}

.stamp-dot {
  width: 6.5px;
  height: 6.5px;
  border-radius: 50%;
  background-color: var(--accent-rose);
  box-shadow: 0 0 6px rgba(225, 29, 72, 0.5);
  animation: pulseDot 2.4s infinite ease-in-out;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.85); }
}

.stamp-text {
  letter-spacing: 0.02em;
  font-weight: 500;
}

.header-status {
  display: flex;
  align-items: center;
}

.status-badge {
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #15803d;
  background: var(--accent-green-soft);
  border: 1px solid rgba(34, 197, 94, 0.2);
  padding: 2px 7px;
  border-radius: var(--radius-pill);
}

/* ==========================================================================
   Story Stream Area & Pacing
   ========================================================================== */
.terminal-body {
  padding: 0.95rem 1.15rem 0.35rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.48;
  min-height: 135px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.terminal-lines {
  display: flex;
  flex-direction: column;
  gap: 0.24rem;
}

.log-line {
  display: flex;
  align-items: baseline;
  gap: 0.48rem;
  opacity: 0;
  transform: translateY(2px);
  animation: logEnter 0.22s forwards var(--ease-spring);
  word-break: break-word;
  transition: opacity 0.45s ease;
}

@keyframes logEnter {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.terminal-lines.compact .log-dimmed {
  opacity: 0.36;
}

.log-prefix {
  color: var(--text-muted);
  user-select: none;
  font-weight: 500;
  flex-shrink: 0;
}

.log-text {
  color: var(--text-main);
}

/* Thoughtful Syntax Styling */
.log-init {
  color: var(--accent-rose);
  font-weight: 600;
}

.log-warn {
  color: #b91c1c;
  font-weight: 600;
}

.log-dim {
  color: var(--text-secondary);
  font-style: italic;
}

.log-notice {
  color: var(--accent-amber);
  font-weight: 600;
}

.log-highlight {
  background: var(--accent-rose-soft);
  border: 1px solid var(--accent-rose-border);
  padding: 2px 8px;
  border-radius: 6px;
  display: inline-block;
  font-weight: 600;
  box-shadow: 0 1px 6px rgba(225, 29, 72, 0.08);
}

.log-highlight .name-val {
  color: var(--accent-rose);
  font-weight: 700;
}

.log-punchline {
  color: var(--text-main);
  font-weight: 600;
  margin-top: 0.1rem;
}

/* Prompt & Keystroke Cursor */
.terminal-prompt {
  display: flex;
  align-items: baseline;
  gap: 0.48rem;
  margin-top: 0.1rem;
  min-height: 1.4rem;
}

.prompt-symbol {
  color: var(--accent-rose);
  font-weight: 700;
}

.active-text {
  color: var(--text-main);
}

.terminal-cursor {
  display: inline-block;
  color: var(--accent-rose);
  font-weight: bold;
  animation: blinkCursor 0.9s infinite step-end;
  margin-left: 1px;
}

@keyframes blinkCursor {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ==========================================================================
   Handcrafted Botanical SVG Rose & Layered Unfurling
   ========================================================================== */
.rose-stage {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0.45rem 1rem 0;
  opacity: 0;
  transform: scale(0.96) translateY(6px);
  transition: opacity 0.7s var(--ease-spring), transform 0.7s var(--ease-spring);
  pointer-events: none;
  min-height: 0;
  height: 0;
  overflow: hidden;
}

.rose-stage.active {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
  min-height: 215px;
  max-height: 235px;
  height: auto;
}

.rose-svg {
  width: 100%;
  max-width: 210px;
  height: auto;
  overflow: visible;
}

/* Ambient Warm Backlight Aura */
.rose-ambient-aura {
  opacity: 0;
  transform-origin: 128px 94px;
  transform: scale(0.6);
  transition: opacity 1.4s ease 1.2s, transform 1.8s var(--ease-spring) 1.2s;
}

.rose-stage.active .rose-ambient-aura {
  opacity: 1;
  transform: scale(1);
}

/* Stem Drawing */
.rose-stem-main {
  stroke-dasharray: 180;
  stroke-dashoffset: 180;
  transition: stroke-dashoffset 1.1s cubic-bezier(0.33, 1, 0.68, 1) 0.1s;
}

.rose-stage.active .rose-stem-main {
  stroke-dashoffset: 0;
}

/* Thorns */
.rose-thorn {
  opacity: 0;
  transform-origin: center;
  transform: scale(0.2);
  transition: opacity 0.35s ease, transform 0.45s var(--ease-spring);
}

.rose-stage.active .thorn-1 {
  opacity: 1;
  transform: scale(1);
  transition-delay: 0.45s;
}

.rose-stage.active .thorn-2 {
  opacity: 1;
  transform: scale(1);
  transition-delay: 0.7s;
}

/* Foliage */
.rose-leaf {
  opacity: 0;
  transition: opacity 0.6s ease, transform 0.75s var(--ease-spring);
}

.rose-leaf.leaf-left {
  transform-origin: 128px 214px;
  transform: scale(0.2) rotate(-28deg);
  transition-delay: 0.6s;
}

.rose-leaf.leaf-right {
  transform-origin: 127px 165px;
  transform: scale(0.2) rotate(25deg);
  transition-delay: 0.8s;
}

.rose-stage.active .rose-leaf {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

/* Calyx */
.rose-hypanthium {
  opacity: 0;
  transform-origin: 130px 140px;
  transform: scale(0.4);
  transition: opacity 0.4s ease 0.85s, transform 0.5s var(--ease-spring) 0.85s;
}

.rose-sepal {
  opacity: 0;
  transition: opacity 0.5s ease, transform 0.65s var(--ease-spring);
}

.sepal-left   { transform-origin: 124px 137px; transform: rotate(35deg) scale(0.3); transition-delay: 0.9s; }
.sepal-right  { transform-origin: 136px 137px; transform: rotate(-35deg) scale(0.3); transition-delay: 0.95s; }
.sepal-center { transform-origin: 128px 138px; transform: scaleY(0.2); transition-delay: 1.0s; }

.rose-stage.active .rose-hypanthium,
.rose-stage.active .rose-sepal {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

/* Petals */
.petal-whorl {
  opacity: 0;
  transform-origin: 128px 90px;
  transition: opacity 0.7s ease, transform 0.95s var(--ease-spring);
}

.whorl-outer {
  transform: scale(0.4) translateY(12px);
  transition-delay: 0.95s;
}

.whorl-mid {
  transform: scale(0.35) translateY(8px) rotate(-4deg);
  transition-delay: 1.15s;
}

.whorl-core {
  transform: scale(0.3) translateY(5px);
  transition-delay: 1.35s;
}

.rose-stage.active .petal-whorl {
  opacity: 1;
  transform: scale(1) translateY(0) rotate(0deg);
}

.petal-curl {
  transition: opacity 0.5s ease 1.6s;
}

/* Dewdrops */
.rose-dewdrops {
  opacity: 0;
  transition: opacity 0.6s ease 1.7s;
}

.rose-stage.active .rose-dewdrops {
  opacity: 0.85;
}

/* ==========================================================================
   Closing Card
   ========================================================================== */
.closing-card {
  padding: 0.65rem 1.15rem 0.2rem;
  text-align: center;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.5s ease, transform 0.5s var(--ease-spring);
  pointer-events: none;
}

.closing-card.active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.closing-punchline {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
}

.closing-salutation {
  font-family: var(--font-editorial);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-main);
  letter-spacing: -0.015em;
}

.highlight-name {
  color: var(--accent-rose);
  font-weight: 700;
}

/* ==========================================================================
   Tactile Action Buttons
   ========================================================================== */
.terminal-actions {
  display: flex;
  gap: 0.65rem;
  padding: 0.95rem 1.15rem 1.15rem;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.4s ease, transform 0.4s var(--ease-spring);
  pointer-events: none;
}

.terminal-actions.active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.btn-tactile {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.68rem 0.85rem;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: var(--radius-btn);
  border: 1px solid transparent;
  cursor: pointer;
  outline: none;
  transition: transform 0.12s ease, opacity 0.12s ease, box-shadow 0.12s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn-tactile:active {
  transform: translateY(1px) scale(0.98);
  opacity: 0.88;
}

.btn-tactile:focus-visible {
  box-shadow: 0 0 0 3px rgba(225, 29, 72, 0.3);
}

.btn-secondary {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.08);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: rgba(0, 0, 0, 0.07);
}

.btn-primary {
  background: var(--accent-rose);
  border-color: var(--accent-rose);
  color: #ffffff;
  box-shadow: 0 3px 12px rgba(225, 29, 72, 0.22);
}

.btn-primary:hover {
  background: #be123c;
  box-shadow: 0 4px 16px rgba(225, 29, 72, 0.28);
}

.btn-icon {
  font-size: 1.02em;
}

/* ==========================================================================
   Shared Itinerary Note (Apple Notes / Things 3 Style)
   ========================================================================== */
.agenda-drawer {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  padding: 0.65rem 1.15rem 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  transition: max-height 0.45s var(--ease-spring), opacity 0.35s ease, transform 0.45s var(--ease-spring);
  transform: translateY(10px);
}

.agenda-drawer.open {
  max-height: 850px;
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

/* Scaled Rose Crest (Header emblem on Look-Back Mode) */
.itinerary-rose-crest {
  display: none;
}

.sheet-grabber-area {
  display: flex;
  justify-content: center;
  padding: 0.35rem 0 0.45rem;
  cursor: pointer;
}

.sheet-grabber-pill {
  width: 36px;
  height: 4.5px;
  border-radius: var(--radius-pill);
  background: rgba(0, 0, 0, 0.15);
}

.agenda-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  padding-bottom: 0.65rem;
}

.agenda-kicker {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent-rose);
  display: inline-block;
  margin-bottom: 0.1rem;
}

.agenda-title {
  font-family: var(--font-editorial);
  font-size: 1.32rem;
  font-weight: 600;
  color: var(--text-main);
  letter-spacing: -0.015em;
}

.agenda-subtitle {
  font-size: 0.74rem;
  color: var(--text-secondary);
  margin-top: 1px;
}

.btn-close-agenda {
  background: rgba(0, 0, 0, 0.05);
  border: none;
  color: var(--text-secondary);
  font-size: 0.85rem;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}

.btn-close-agenda:hover {
  background: rgba(0, 0, 0, 0.1);
  color: var(--text-main);
}

/* Timeline Cards */
.agenda-timeline {
  display: flex;
  flex-direction: column;
}

.plan-card {
  display: grid;
  grid-template-columns: 58px 1fr;
  padding: 0.7rem 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.plan-card:last-child {
  border-bottom: none;
}

.plan-time {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--text-secondary);
  padding-top: 1px;
}

.plan-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.plan-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
}

.plan-notes {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 2px;
  line-height: 1.4;
}

.plan-pill {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 1.5px 6px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.04);
  color: var(--text-secondary);
  flex-shrink: 0;
}

.pill-rose {
  background: var(--accent-rose-soft);
  color: var(--accent-rose);
  border: 1px solid var(--accent-rose-border);
}

.pill-emerald {
  background: var(--accent-green-soft);
  color: var(--accent-green);
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.pill-warm {
  background: #fefce8;
  color: #854d0e;
  border: 1px solid rgba(234, 179, 8, 0.25);
}

.agenda-return-actions {
  display: none;
}

.agenda-note-footer {
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  padding-top: 0.55rem;
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ==========================================================================
   LOOK-BACK / ITINERARY HERO MODE (When already viewed)
   ========================================================================== */
.app-container.itinerary-mode .terminal-card {
  display: none;
}

.app-container.itinerary-mode .agenda-drawer {
  max-height: none !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  transform: none !important;
  overflow: visible;
  padding-top: 1rem;
}

.app-container.itinerary-mode .sheet-grabber-area {
  display: none;
}

.app-container.itinerary-mode .btn-close-agenda {
  display: none;
}

.app-container.itinerary-mode .itinerary-rose-crest {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 0.5rem 0 0.85rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.crest-svg-box {
  width: 138px;
  height: 162px;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 8px 18px rgba(225, 29, 72, 0.16));
  overflow: visible;
}

.crest-rose-svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.crest-text-group {
  margin-top: 0.4rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.crest-kicker {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent-rose);
}

.crest-sub {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-style: italic;
}

.app-container.itinerary-mode .agenda-return-actions {
  display: flex;
  justify-content: center;
  padding-top: 0.5rem;
}

.btn-replay-story {
  max-width: 240px;
  font-size: 0.8rem;
  padding: 0.6rem 0.9rem;
}

/* ==========================================================================
   Handcrafted Signature Footer
   ========================================================================== */
.subtle-footer {
  text-align: center;
  padding: 0.4rem 0 0.2rem;
}

.made-by {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.made-by a {
  color: var(--accent-rose);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: opacity 0.15s ease;
}

.made-by a:hover {
  opacity: 0.75;
}

/* ==========================================================================
   Reduced Motion Accessibility
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .rose-stem-main {
    stroke-dashoffset: 0 !important;
  }

  .rose-stage,
  .petal-whorl,
  .rose-leaf,
  .rose-sepal,
  .rose-hypanthium,
  .rose-thorn,
  .rose-ambient-aura,
  .rose-dewdrops,
  .closing-card,
  .terminal-actions {
    opacity: 1 !important;
    transform: none !important;
  }
}
