/* Lumière — tone of typography.
 * Intimate, serif, slow. No pure white, no pure black.
 * Palette locked in Phase 2 per project prompt. */

:root {
  --cream:     #F5EFE6;
  --cream-2:   #EEE6D7;
  --gold:      #C9A96E;
  --charcoal:  #2C2826;
  --muted:     #7A706A;
  --hairline:  rgba(44, 40, 38, 0.08);
  --shadow:    0 1px 2px rgba(44, 40, 38, 0.04);

  --serif: "EB Garamond", "Crimson Pro", Cambria, Georgia, "Times New Roman",
    serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "SF Pro Text", sans-serif;

  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--cream);
  color: var(--charcoal);
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
}

.stage {
  max-width: 36rem;
  margin: 0 auto;
  padding: max(env(safe-area-inset-top), 3rem) 1.75rem
    max(env(safe-area-inset-bottom), 2rem);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 2.5rem;
  animation: fade 1200ms var(--ease);
}

@keyframes fade {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Date header ----------------------------------------------------------- */
.date {
  font-family: var(--sans);
  font-size: 0.7rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}

/* Fragment -------------------------------------------------------------- */
.fragment {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.prompt {
  font-size: clamp(1.9rem, 5.8vw, 2.6rem);
  line-height: 1.18;
  margin: 0;
  font-style: italic;
  font-weight: 400;
  letter-spacing: -0.005em;
  color: var(--charcoal);
  max-width: 28ch;
}

/* Flight card ----------------------------------------------------------- */
.flight-card {
  border: 1px solid var(--hairline);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  background: var(--cream-2);
  box-shadow: var(--shadow);
  font-family: var(--sans);
  animation: fadeUp 1400ms var(--ease);
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.flight-route {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  font-family: var(--serif);
  font-size: 1.25rem;
  color: var(--charcoal);
}

.arrow {
  color: var(--gold);
  font-size: 1rem;
  line-height: 1;
}

.flight-meta {
  margin-top: 0.25rem;
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.02em;
  text-transform: lowercase;
}

/* Actions --------------------------------------------------------------- */
.actions {
  display: flex;
  justify-content: flex-start;
}

.write-btn {
  all: unset;
  cursor: pointer;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.1rem;
  color: var(--gold);
  padding: 0.5rem 0;
  border-bottom: 1px solid transparent;
  transition: border-color 400ms var(--ease), opacity 400ms var(--ease);
}
.write-btn:hover,
.write-btn:focus-visible {
  border-bottom-color: var(--gold);
}

/* Milestone footer ------------------------------------------------------ */
.milestone {
  font-family: var(--sans);
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.04em;
  border-top: 1px solid var(--hairline);
  padding-top: 1rem;
  min-height: 1rem;
}

/* Write sheet (dialog) -------------------------------------------------- */
.sheet {
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  border: 0;
  background: var(--cream);
  color: var(--charcoal);
}
.sheet::backdrop { background: rgba(44, 40, 38, 0.2); }
.sheet[open] { animation: sheetIn 500ms var(--ease); }
@keyframes sheetIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.sheet-form {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: max(env(safe-area-inset-top), 1.2rem) 1.25rem
    max(env(safe-area-inset-bottom), 1.25rem);
  gap: 0.75rem;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--muted);
}
.sheet-hint {
  font-family: var(--serif);
  font-style: italic;
  color: var(--muted);
  max-width: 60%;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.sheet-close, .sheet-done {
  all: unset;
  cursor: pointer;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  font-family: var(--serif);
  font-size: 1.15rem;
  font-style: italic;
  color: var(--gold);
}

#write-text {
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  resize: none;
  font-family: var(--serif);
  font-size: 1.3rem;
  line-height: 1.5;
  color: var(--charcoal);
  padding: 1rem 0;
}

.sheet-status {
  font-family: var(--sans);
  font-size: 0.7rem;
  color: var(--muted);
  letter-spacing: 0.05em;
  text-align: right;
  min-height: 1rem;
}

/* Empty / loading state ------------------------------------------------- */
.loading .prompt { opacity: 0.3; }

/* Skip flight link ------------------------------------------------------ */
.skip-link {
  all: unset;
  cursor: pointer;
  display: block;
  margin-top: 0.85rem;
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.78rem;
  color: var(--muted);
  opacity: 0.7;
  letter-spacing: 0.02em;
  transition: opacity 400ms var(--ease);
}
.skip-link:hover,
.skip-link:focus-visible { opacity: 1; }
.skip-link[disabled] { opacity: 0.3; cursor: default; }

/* Bottom nav ------------------------------------------------------------ */
.bottom-nav {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1.4rem;
  margin-top: -0.5rem;
}
.bottom-nav button {
  all: unset;
  cursor: pointer;
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.74rem;
  color: var(--muted);
  opacity: 0.55;
  letter-spacing: 0.04em;
  padding: 0.5rem 0.2rem;
  border-bottom: 1px solid transparent;
  transition: opacity 400ms var(--ease), border-color 400ms var(--ease);
}
.bottom-nav button:hover,
.bottom-nav button:focus-visible {
  opacity: 1;
  border-bottom-color: var(--muted);
}

/* Readable sheets (archive, settings) ---------------------------------- */
.sheet-readable[open] {
  display: flex;
  flex-direction: column;
}
.sheet-readable .sheet-head {
  padding: max(env(safe-area-inset-top), 1.2rem) 1.25rem 0.75rem;
  border-bottom: 1px solid var(--hairline);
  flex-shrink: 0;
}
.sheet-title {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1rem;
  color: var(--charcoal);
  letter-spacing: 0.04em;
}
.sheet-spacer {
  width: 2rem;     /* mirrors the close button so title stays centred */
}

/* Archive --------------------------------------------------------------- */
.archive-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 1.5rem 1.5rem max(env(safe-area-inset-bottom), 2rem);
  max-width: 36rem;
  margin: 0 auto;
  width: 100%;
}
.archive-loading,
.archive-empty {
  text-align: center;
  margin-top: 4rem;
  font-family: var(--serif);
  font-style: italic;
  color: var(--muted);
  font-size: 1rem;
}
.archive-entry {
  padding: 1.5rem 0 1.75rem;
  border-bottom: 1px solid var(--hairline);
}
.archive-entry:last-child { border-bottom: 0; }
.archive-date {
  font-family: var(--sans);
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.6rem;
}
.archive-prompt {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1rem;
  color: var(--gold);
  margin-bottom: 0.85rem;
  line-height: 1.4;
}
.archive-flight {
  font-family: var(--sans);
  font-size: 0.7rem;
  color: var(--muted);
  margin-bottom: 0.85rem;
  letter-spacing: 0.02em;
  text-transform: lowercase;
}
.archive-content {
  font-family: var(--serif);
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--charcoal);
  white-space: pre-wrap;
  margin: 0;
}

/* Settings -------------------------------------------------------------- */
.settings-body {
  flex: 1;
  padding: 2rem 1.5rem max(env(safe-area-inset-bottom), 2rem);
  max-width: 32rem;
  margin: 0 auto;
  width: 100%;
}
.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 1rem 0;
  border-bottom: 1px solid var(--hairline);
}
.settings-label {
  font-family: var(--sans);
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}
.settings-value {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1rem;
  color: var(--charcoal);
}
.settings-action {
  all: unset;
  cursor: pointer;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1rem;
  color: var(--gold);
  border-bottom: 1px solid transparent;
  transition: border-color 400ms var(--ease);
}
.settings-action:hover,
.settings-action:focus-visible { border-bottom-color: var(--gold); }
.settings-note {
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--muted);
  margin-top: 2.5rem;
  text-align: center;
  line-height: 1.5;
  max-width: 24rem;
  margin-left: auto;
  margin-right: auto;
}

/* First-launch welcome -------------------------------------------------- */
.welcome {
  position: fixed;
  inset: 0;
  background: var(--cream);
  z-index: 100;
  overflow: hidden;
  animation: welcomeIn 1600ms var(--ease);
}
.welcome[hidden] { display: none; }
.welcome--leaving {
  opacity: 0;
  transition: opacity 900ms var(--ease);
  pointer-events: none;
}

@keyframes welcomeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Hide the stage while welcome is active. */
body.welcome-active .stage { display: none; }

.welcome-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 700ms var(--ease);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: max(env(safe-area-inset-top), 3rem) 1.75rem
    max(env(safe-area-inset-bottom), 2rem);
}
.welcome-screen[data-active="true"] {
  opacity: 1;
  pointer-events: auto;
}

.welcome-body {
  max-width: 30rem;
  margin: 0 auto;
  padding: 1rem 0 1.5rem;
  font-family: var(--serif);
  font-size: 1.05rem;
  line-height: 1.65;
  color: var(--charcoal);
  text-align: center;
}
.welcome-body p {
  margin: 0 0 1.35rem;
}
.welcome-body p:first-child {
  font-style: italic;
  font-size: 1.15rem;
  margin-bottom: 1.8rem;
  color: var(--charcoal);
}

.welcome-next {
  all: unset;
  cursor: pointer;
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--gold);
  padding: 1.1rem 1.8rem;
  margin: 0.5rem auto 1.5rem;
  letter-spacing: 0.04em;
  opacity: 0.75;
  transition: opacity 400ms var(--ease);
  text-align: center;
}
.welcome-next:hover,
.welcome-next:focus-visible { opacity: 1; }

.welcome-begin {
  all: unset;
  cursor: pointer;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.2rem;
  color: var(--gold);
  padding: 0.85rem 2.6rem;
  margin: 0.5rem auto 2rem;
  border: 1px solid var(--gold);
  border-radius: 999px;
  letter-spacing: 0.05em;
  transition: background 400ms var(--ease), color 400ms var(--ease);
  text-align: center;
}
.welcome-begin:hover,
.welcome-begin:focus-visible {
  background: var(--gold);
  color: var(--cream);
}
