/* ============================================================
   The Daily Strategist — styling
   ============================================================ */

:root {
  --bg: #f4ecdd;
  --bg-2: #efe5d2;
  --surface: #fbf6ec;
  --ink: #2c2620;
  --ink-soft: #5c5347;
  --ink-faint: #8a7f6f;
  --accent: #8a1c1c;
  --accent-soft: #b0432f;
  --gold: #b08431;
  --line: #ddd0b8;
  --shadow: 0 10px 40px -12px rgba(60, 45, 25, 0.35);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: "Avenir Next", "Segoe UI", system-ui, sans-serif;
}

[data-theme="dark"] {
  --bg: #15120e;
  --bg-2: #1c1813;
  --surface: #211c16;
  --ink: #ece3d2;
  --ink-soft: #b9ad98;
  --ink-faint: #8a7e69;
  --accent: #d98a5c;
  --accent-soft: #e0a074;
  --gold: #d8b25e;
  --line: #3a3127;
  --shadow: 0 14px 50px -10px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(1200px 600px at 50% -10%, var(--bg-2), transparent 70%),
    var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  -webkit-font-smoothing: antialiased;
  min-height: 100%;
}

.app {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  color: var(--accent);
  font-size: 26px;
  line-height: 1;
}
.brand-text h1 {
  font-size: 26px;
  margin: 0;
  letter-spacing: 0.3px;
  font-weight: 600;
}
.tagline {
  margin: 2px 0 0;
  font-family: var(--sans);
  font-size: 12.5px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.topbar-right { display: flex; align-items: center; gap: 14px; }

.streak {
  display: flex;
  align-items: baseline;
  gap: 5px;
  font-family: var(--sans);
  font-size: 12px;
  color: var(--ink-soft);
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 7px 12px;
  border-radius: 999px;
}
.streak-flame { color: var(--gold); font-size: 11px; }
.streak-count { font-weight: 700; font-size: 15px; color: var(--ink); font-family: var(--serif); }
.streak-label { text-transform: uppercase; letter-spacing: 0.5px; font-size: 10.5px; }

.icon-btn {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  width: 38px; height: 38px;
  border-radius: 50%;
  font-size: 17px;
  cursor: pointer;
  transition: transform .15s ease, color .2s ease;
}
.icon-btn:hover { color: var(--accent); transform: rotate(-12deg); }

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 26px;
}
.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 10px 16px;
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--ink-faint);
  cursor: pointer;
  transition: color .2s ease;
}
.tab:hover { color: var(--ink); }
.tab.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ---------- Views ---------- */
.view { display: none; animation: fade .4s ease; }
.view.is-active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.view-intro {
  font-family: var(--sans);
  font-size: 13.5px;
  color: var(--ink-soft);
  margin: 0 0 20px;
  line-height: 1.5;
}

/* ---------- Card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 34px 36px 28px;
  box-shadow: var(--shadow);
  position: relative;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.date {
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.badge {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 4px 11px;
  white-space: nowrap;
}
.numbering {
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 6px;
}
.entry-title {
  font-size: 30px;
  line-height: 1.18;
  margin: 0 0 14px;
  font-weight: 600;
  letter-spacing: 0.2px;
}
.essence {
  font-size: 18px;
  font-style: italic;
  color: var(--ink-soft);
  margin: 0 0 20px;
  line-height: 1.45;
}
.rule {
  height: 1px;
  background: linear-gradient(90deg, var(--accent), transparent);
  margin: 0 0 20px;
  opacity: 0.55;
}
.summary {
  font-size: 17.5px;
  line-height: 1.7;
  margin: 0 0 26px;
}
.reflection {
  background: var(--bg-2);
  border-left: 3px solid var(--gold);
  border-radius: 0 8px 8px 0;
  padding: 16px 20px;
  margin-bottom: 26px;
}
.reflection h3 {
  font-family: var(--sans);
  font-size: 11.5px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 8px;
}
.reflection p { margin: 0; font-size: 16.5px; line-height: 1.6; font-style: italic; }

/* ---------- Lineage (public-domain quote) ---------- */
.lineage {
  margin: -6px 0 26px;
  padding: 2px 0 0 18px;
  border-left: 2px solid var(--line);
}
.lineage-quote {
  display: block;
  font-style: italic;
  font-size: 15.5px;
  line-height: 1.55;
  color: var(--ink-soft);
}
.lineage-source {
  display: block;
  margin-top: 6px;
  font-family: var(--sans);
  font-size: 11.5px;
  letter-spacing: 0.4px;
  color: var(--ink-faint);
}

/* ---------- Notes ---------- */
.notes { margin-bottom: 24px; position: relative; }
.notes label {
  display: block;
  font-family: var(--sans);
  font-size: 11.5px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 8px;
}
.notes textarea {
  width: 100%;
  min-height: 84px;
  resize: vertical;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
}
.notes textarea:focus { outline: none; border-color: var(--accent); }
.note-saved {
  position: absolute;
  right: 4px;
  bottom: -18px;
  font-family: var(--sans);
  font-size: 11px;
  color: var(--gold);
  opacity: 0;
  transition: opacity .3s ease;
}
.note-saved.show { opacity: 1; }

/* ---------- Actions ---------- */
.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}
.btn {
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: 0.5px;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink-soft);
  cursor: pointer;
  transition: all .18s ease;
}
.btn:hover { color: var(--ink); border-color: var(--ink-faint); }
.btn.ghost { background: transparent; }
.fav-btn { border-color: var(--gold); color: var(--gold); }
.fav-btn:hover { background: var(--gold); color: var(--surface); border-color: var(--gold); }
.fav-btn.is-fav { background: var(--gold); color: var(--surface); }
.fav-btn .star { font-size: 15px; }

.link-btn {
  display: block;
  margin: 0 auto;
  background: none;
  border: none;
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.5px;
  color: var(--ink-faint);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.link-btn:hover { color: var(--accent); }
.link-btn.hidden { display: none; }

/* ---------- Library / Favorites lists ---------- */
.group-title {
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--gold);
  margin: 26px 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.group-title:first-child { margin-top: 0; }

.row {
  display: flex;
  align-items: baseline;
  gap: 14px;
  padding: 11px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s ease;
}
.row:hover { background: var(--surface); }
.row-num {
  font-family: var(--sans);
  font-size: 12px;
  color: var(--ink-faint);
  min-width: 24px;
  text-align: right;
}
.row-body { flex: 1; }
.row-title { font-size: 17px; line-height: 1.3; }
.row-essence {
  font-family: var(--sans);
  font-size: 12.5px;
  color: var(--ink-faint);
  margin-top: 2px;
  line-height: 1.4;
}
.row-star { color: var(--gold); font-size: 14px; opacity: 0; }
.row.faved .row-star { opacity: 1; }
.row.is-current { background: var(--surface); box-shadow: inset 3px 0 0 var(--accent); }

.empty {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ink-faint);
  text-align: center;
  padding: 40px 20px;
  font-style: italic;
}
.empty.hidden { display: none; }

/* ---------- Footer ---------- */
.foot {
  margin-top: 36px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.foot p {
  font-family: var(--sans);
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--ink-faint);
  margin: 0;
  text-align: center;
}

/* ---------- Paywall ---------- */
.unlock-pill {
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--surface);
  background: var(--gold);
  border: 1px solid var(--gold);
  border-radius: 999px;
  padding: 7px 15px;
  cursor: pointer;
  transition: transform .15s ease, filter .2s ease;
}
.unlock-pill:hover { filter: brightness(1.08); transform: translateY(-1px); }

.lockblock {
  text-align: center;
  padding: 26px 22px 22px;
  margin-bottom: 26px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.lock-ico { font-size: 30px; margin-bottom: 8px; filter: grayscale(0.2); }
.lock-msg {
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink-soft);
  margin: 0 auto 18px;
  max-width: 40ch;
}
.lock-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
.lock-foot {
  font-family: var(--sans);
  font-size: 11.5px;
  color: var(--ink-faint);
  margin: 14px 0 0;
}

.btn.primary {
  background: var(--gold);
  color: var(--surface);
  border-color: var(--gold);
  font-weight: 600;
}
.btn.primary:hover { filter: brightness(1.08); color: var(--surface); }
.btn.buy {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
.btn.buy:hover { filter: brightness(1.08); color: #fff; }
.btn.block { display: block; width: 100%; text-align: center; padding: 12px; }

/* library lock marker */
.row-lock { color: var(--ink-faint); font-size: 13px; display: none; }
.row.locked .row-lock { display: inline; }
.row.locked .row-title { opacity: 0.7; }
.row.locked:hover .row-title { opacity: 1; }

/* unlock modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 8, 5, 0.55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
  animation: fade .2s ease;
}
.modal-overlay[hidden] { display: none; }
.modal {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 30px 28px 24px;
  width: 100%;
  max-width: 400px;
}
.modal-close {
  position: absolute;
  top: 12px; right: 14px;
  background: none; border: none;
  font-size: 24px; line-height: 1;
  color: var(--ink-faint);
  cursor: pointer;
}
.modal-close:hover { color: var(--ink); }
.modal h2 { margin: 0 0 8px; font-size: 22px; }
.modal-sub { font-family: var(--sans); font-size: 13.5px; color: var(--ink-soft); line-height: 1.5; margin: 0 0 16px; }
#licenseInput {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 13px;
  font-family: var(--sans);
  font-size: 14px;
  letter-spacing: 0.5px;
  color: var(--ink);
  margin-bottom: 12px;
}
#licenseInput:focus { outline: none; border-color: var(--gold); }
.modal-status { font-family: var(--sans); font-size: 12.5px; min-height: 16px; margin: 10px 0 0; text-align: center; }
.modal-status.ok { color: #2e7d4f; }
.modal-status.err { color: var(--accent); }
[data-theme="dark"] .modal-status.ok { color: #6cc08b; }
.modal-foot { font-family: var(--sans); font-size: 12.5px; color: var(--ink-faint); text-align: center; margin: 16px 0 0; }
.modal-foot a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }

/* ---------- Responsive ---------- */
@media (max-width: 560px) {
  .app { padding: 20px 14px 50px; }
  .card { padding: 26px 22px 24px; }
  .entry-title { font-size: 25px; }
  .summary { font-size: 16.5px; }
  .streak-label { display: none; }
  .brand-text h1 { font-size: 22px; }
  .card-actions { justify-content: space-between; }
}
