/* ============================================================================
   Mantra Rumi — one genuine, sourced line of Rumi at a time.
   Dark, quiet, contemplative. A single warm accent: candle-gold (Shams = "sun").
   ========================================================================== */

:root {
  --bg:        #0B0D10;   /* near-black backdrop */
  --bg-lift:   #14120E;   /* faint warm lift for chips/cards */
  --ink:       #ECEAE3;   /* primary text, slightly warm */
  --ink-dim:   #8C8475;   /* secondary text */
  --ink-faint: #4E473B;   /* hairlines, idle glyphs */
  --accent:    #E0A24A;   /* candle-gold */
  --accent-dim:#7E5A24;
  --radius:    16px;
  --tap:       44px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-serif, Georgia, "Iowan Old Style", "Times New Roman", serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

/* A warm radial so the stage glows faintly, like candlelight. */
body {
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(224,162,74,0.07), transparent 60%),
    var(--bg);
}

/* View switching: show only the active view. */
[data-view-target] { display: none; }
html[data-view="now"]    [data-view-target="now"]    { display: flex; }
html[data-view="pinned"] [data-view-target="pinned"] { display: flex; }

/* ============================== NOW (the stage) ============================== */
.stage {
  flex-direction: column;
  min-height: 100%;
  padding:
    calc(var(--safe-t) + 24px)
    calc(var(--safe-r) + 22px)
    calc(var(--safe-b) + 18px)
    calc(var(--safe-l) + 22px);
}

.line {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 16px;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  text-align: left;
  cursor: pointer;
  font: inherit;
}

html[data-roll="1"] .line-text,
html[data-roll="1"] .line-source { opacity: 0; transition: opacity 140ms ease; }

.roll-dots { display: none; }
html[data-roll="1"] .roll-dots {
  display: flex;
  gap: 10px;
  position: absolute;
  left: 2px;
  top: 50%;
  transform: translateY(-50%);
}
.roll-dots i {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--accent-dim);
  animation: dotpulse 640ms infinite ease-in-out;
}
.roll-dots i:nth-child(2) { animation-delay: 130ms; }
.roll-dots i:nth-child(3) { animation-delay: 260ms; }
@keyframes dotpulse {
  0%, 100% { opacity: 0.25; transform: scale(0.8); }
  50%      { opacity: 1;    transform: scale(1.05); background: var(--accent); }
}

.help-btn {
  position: fixed;
  top: calc(var(--safe-t) + 14px);
  right: calc(var(--safe-r) + 16px);
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border: 1px solid var(--ink-faint);
  border-radius: 50%;
  background: var(--bg-lift);
  color: var(--ink-dim);
  font-size: 15px; font-weight: 600;
  cursor: pointer;
  z-index: 5;
}

.line-text {
  font-size: clamp(26px, 6.6vw, 40px);
  font-weight: 500;
  line-height: 1.26;
  letter-spacing: -0.005em;
  max-width: 20ch;
  animation: rise 360ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* The source citation under each line — small, candle-gold, every line has one. */
.line-source {
  font-style: normal;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0.85;
}
.line-source::before { content: "— "; color: var(--ink-faint); }

/* The sense: quiet explanatory text under the line, revealed by ⓘ. */
.line-meaning {
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--ink-dim);
  max-width: 36ch;
  padding-left: 12px;
  border-left: 2px solid var(--accent-dim);
  animation: rise 280ms cubic-bezier(0.22, 1, 0.36, 1);
}

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

.line::after {
  content: "tap for the next";
  position: fixed;
  left: 0; right: 0;
  bottom: calc(var(--safe-b) + 92px);
  text-align: center;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  pointer-events: none;
  opacity: 0;
}
html[data-hint="1"] .line::after { opacity: 1; transition: opacity 400ms; }

/* ------------------------------ controls ------------------------------ */
.controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.ctl {
  width: var(--tap); height: var(--tap);
  display: grid; place-items: center;
  border: 1px solid var(--ink-faint);
  border-radius: 50%;
  background: var(--bg-lift);
  color: var(--ink-dim);
  font-size: 18px;
  cursor: pointer;
  transition: transform 120ms, color 120ms, border-color 120ms;
}
.ctl:active { transform: scale(0.9); }
.ctl:disabled { opacity: 0.35; pointer-events: none; }
#why[aria-pressed="true"] { color: var(--accent); border-color: var(--accent-dim); }
#pin[aria-pressed="true"] { color: var(--accent); border-color: var(--accent-dim); }
#pin[aria-pressed="true"] .ctl-glyph { font-size: 0; }
#pin[aria-pressed="true"] .ctl-glyph::before { content: "★"; font-size: 18px; }

/* ------------------------------ themes (moods) ------------------------------ */
.moods { margin-top: 14px; }
.mood-bar { display: flex; align-items: center; gap: 8px; }

.mood-toggle {
  width: var(--tap); height: 34px;
  border: 1px solid var(--ink-faint);
  border-radius: 999px;
  background: var(--bg-lift);
  color: var(--ink-dim);
  font-size: 18px; line-height: 1;
  cursor: pointer;
}
.moods[data-open="true"] .mood-toggle { color: var(--accent); border-color: var(--accent-dim); }

.mood-row {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.moods[data-open="true"] .mood-row { display: flex; }

.chip {
  padding: 8px 14px;
  min-height: 34px;
  border: 1px solid var(--ink-faint);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-dim);
  font-size: 14px; font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  font-family: ui-sans-serif, -apple-system, system-ui, sans-serif;
  transition: color 120ms, border-color 120ms, background 120ms;
}
.chip[aria-pressed="true"] {
  color: var(--bg);
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}

/* ============================== LIBRARY ============================== */
.pinned {
  flex-direction: column;
  min-height: 100%;
  padding:
    calc(var(--safe-t) + 8px)
    calc(var(--safe-r) + 18px)
    calc(var(--safe-b) + 18px)
    calc(var(--safe-l) + 18px);
}
.pinned-head { display: flex; align-items: center; gap: 6px; height: 48px; }
.back {
  width: var(--tap); height: var(--tap);
  border: 0; background: none; color: var(--ink-dim);
  font-size: 30px; line-height: 1; cursor: pointer;
}

.lib-tabs { display: flex; gap: 8px; }
.lib-tab {
  padding: 7px 16px;
  min-height: 34px;
  border: 1px solid var(--ink-faint);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-dim);
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  font-family: ui-sans-serif, -apple-system, system-ui, sans-serif;
}
.lib-tab[aria-pressed="true"] {
  color: var(--bg);
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}

.pinned-list { list-style: none; margin: 8px 0 0; padding: 0; overflow-y: auto; }
.pinned-item {
  position: relative;
  padding: 18px 44px 18px 16px;
  margin-bottom: 10px;
  background: var(--bg-lift);
  border: 1px solid var(--ink-faint);
  border-radius: var(--radius);
  font-size: 18px; line-height: 1.34;
  cursor: pointer;
  transition: border-color 120ms;
}
.pinned-item:active { border-color: var(--accent-dim); }
.pinned-item .who {
  display: block; margin-top: 6px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase;
  color: var(--accent); opacity: 0.85;
  font-family: ui-sans-serif, -apple-system, system-ui, sans-serif;
}
.pinned-item .unpin {
  position: absolute; top: 10px; right: 10px;
  width: 30px; height: 30px;
  border: 0; border-radius: 50%;
  background: transparent; color: var(--ink-faint);
  font-size: 17px; cursor: pointer;
}
.pinned-item .unpin:active { color: var(--accent); }
.pinned-item .meta {
  display: block; margin-top: 6px;
  font-size: 12px; color: var(--ink-faint); letter-spacing: 0.03em;
  font-family: ui-sans-serif, -apple-system, system-ui, sans-serif;
}
.pinned-item .repin {
  position: absolute; top: 10px; right: 10px;
  width: 30px; height: 30px;
  border: 0; border-radius: 50%;
  background: transparent; color: var(--ink-faint);
  font-size: 17px; cursor: pointer;
}
.pinned-item .repin[aria-pressed="true"] { color: var(--accent); }

.pinned-empty {
  margin: 40px 20px; color: var(--ink-dim);
  font-size: 16px; line-height: 1.45; text-align: center;
}

/* ============================== HELP / ABOUT ============================== */
.help-overlay {
  position: fixed; inset: 0;
  z-index: 20;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: rgba(4, 4, 3, 0.84);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  cursor: pointer;
}
.help-overlay[hidden] { display: none; }
.help-card {
  width: 100%; max-width: 360px;
  padding: 22px 22px 16px;
  background: var(--bg-lift);
  border: 1px solid var(--ink-faint);
  border-radius: var(--radius);
  font-family: ui-sans-serif, -apple-system, system-ui, sans-serif;
}
.help-title {
  margin: 0 0 14px;
  font-size: 15px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--ink-dim);
}
.help-list { list-style: none; margin: 0; padding: 0; }
.help-list li {
  display: flex; align-items: baseline; gap: 12px;
  padding: 7px 0;
  font-size: 16px; line-height: 1.35;
}
.help-g {
  flex: 0 0 38px;
  text-align: center;
  color: var(--accent);
  font-weight: 600;
  font-size: 15px;
}
.help-note {
  margin: 14px 0 0; padding-top: 12px;
  border-top: 1px solid var(--ink-faint);
  font-size: 13px; line-height: 1.5; color: var(--ink-dim);
}
.help-note b { color: var(--ink); font-weight: 600; }
.help-dismiss {
  margin: 12px 0 0;
  font-size: 12px; letter-spacing: 0.05em;
  color: var(--ink-faint); text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .line-text, .line-meaning { animation: none; }
  .roll-dots i { animation: none; opacity: 0.7; }
  .ctl, .chip { transition: none; }
}
