/* ---- Feel-Good Focus Timer ------------------------------------------- */
/* Brand palette. Three themes share these tokens, remapped per data-theme. */

:root {
  --serif: "Garamond", "EB Garamond", "Cormorant Garamond", "Hoefler Text",
           "Apple Garamond", "Georgia", "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  /* brand constants */
  --rose: #c6b1ac;
  --rose-deep: #a98f88;
  --sage: #666c68;
  --tan: #c8bdab;
  --slate: #484d53;
  --cream: #ebe7e1;
  --dark: #222924;
  --white: #fffefe;

  --ring-anim: 280ms linear;
}

/* Dark Moody */
html[data-theme="dark"] {
  --bg: #222924;
  --bg-2: #1c221e;
  --surface: #2b322d;
  --surface-2: #333b34;
  --text: #ebe7e1;
  --text-soft: #a9b0a6;
  --accent: #c6b1ac;
  --accent-soft: #8f7f7a;
  --track: #3a423b;
  --cloth: #2c332e;
  --frame: #171c18;
}
/* Clean Light — a dusty slate-blue sky (a light tint of brand slate #484d53) */
html[data-theme="light"] {
  --bg: #d4dcdf;
  --bg-2: #c3d0d3;
  --surface: #fbfcfc;
  --surface-2: #edf1f2;
  --text: #2b3439;
  --text-soft: #6e7a7e;
  --accent: #9a8580;
  --accent-soft: #bcaba6;
  --track: #c1cdd0;
  --cloth: #e6e0d6;
  --frame: #e5ebec;
}
/* Bubbly (dusty rose forward) */
html[data-theme="bubbly"] {
  --bg: #f1e6e3;
  --bg-2: #ecdfdb;
  --surface: #fffdfc;
  --surface-2: #f8ece9;
  --text: #4a3d3a;
  --text-soft: #97817b;
  --accent: #b98f86;
  --accent-soft: #cbb2ac;
  --track: #e7d5d0;
  --cloth: #efe1dd;
  --frame: #e2cec8;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }

/* subtle full-page botanical print, swapped per theme by JS */
#bg-print {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  opacity: var(--print-opacity, .5);
  transition: opacity .5s ease;
}
#bg-print svg { width: 100%; height: 100%; display: block; }
body {
  margin: 0;
  font-family: var(--sans);
  background: radial-gradient(120% 90% at 50% 0%, var(--bg) 0%, var(--bg-2) 100%);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  transition: background .5s ease, color .5s ease;
  overflow-x: hidden;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  padding: max(14px, env(safe-area-inset-top)) 18px max(14px, env(safe-area-inset-bottom));
}

/* ---- topbar ---------------------------------------------------------- */
.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 8px;
  padding: 4px 0 10px;
}
.wordmark {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  gap: 3px;
}
.wordmark-title {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 1.22rem;
  letter-spacing: .3px;
  margin: 0;
  color: var(--text);
}
.wordmark-by {
  font-size: .56rem;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--text-soft);
}
.stats { display: flex; gap: 14px; }
.stat { display: flex; flex-direction: column; line-height: 1; }
.stat-num { font-family: var(--serif); font-size: 1.4rem; color: var(--accent); }
.stat-label { font-size: .58rem; letter-spacing: .1em; text-transform: uppercase; color: var(--text-soft); margin-top: 3px; }
.icon-btn {
  justify-self: end;
  background: none; border: none; color: var(--text-soft);
  cursor: pointer; padding: 6px; border-radius: 10px; display: inline-flex;
  transition: color .2s, background .2s;
}
.icon-btn:hover { color: var(--text); background: var(--surface); }
.topbar-actions { justify-self: end; display: flex; align-items: center; gap: 2px; }
.icon-btn.active { color: var(--accent); background: var(--surface); }

/* placeholder shown in the main window while the timer floats in PiP */
.pip-placeholder { text-align: center; padding: 48px 18px; color: var(--text-soft); }
.pip-placeholder p { font-family: var(--serif); font-style: italic; margin: 0 0 8px; line-height: 1.5; }

/* compact, vertical layout inside the floating PiP window (timer over art) */
.pip-body { margin: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: flex-start; gap: 10px; min-height: 100vh; padding: 12px; overflow-y: auto; }
.pip-body .timer-card { padding: 0; width: 100%; }
.pip-body .phase-pill { margin-bottom: 6px; }
.pip-body .task-input { margin: 0 0 8px; font-size: .86rem; width: min(80%, 240px); }
.pip-body .ring-wrap { width: min(50vw, 148px); }
.pip-body .time { font-size: clamp(1.9rem, 13vw, 2.5rem); }
.pip-body .round-dots { margin-top: 8px; }
.pip-body .primary-btn { margin-top: 10px; padding: 9px 24px; font-size: .95rem; }
.pip-body .encourage { min-height: 1.8em; margin-top: 8px; font-size: .8rem; }
.pip-body .distraction-open { display: none; }
.pip-body .art-card { width: 100%; padding: 10px; }
.pip-body #art-canvas { max-width: 188px; }
.pip-body .collection { display: none; }   /* hide the 15-dot row in the small window */
.pip-body .art-meta { margin-top: 8px; }
.pip-resize {
  position: fixed; top: 8px; right: 8px; z-index: 5;
  width: 30px; height: 30px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--track); background: var(--surface);
  color: var(--text-soft); cursor: pointer; transition: color .2s, background .2s;
}
.pip-resize:hover { color: var(--text); background: var(--surface-2); }

/* ---- stage ----------------------------------------------------------- */
.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
  justify-content: flex-start;
  align-items: stretch;
}

/* ---- timer ----------------------------------------------------------- */
.timer-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 6px 0 4px;
}
.phase-pill {
  font-size: .72rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--text-soft);
  padding: 5px 14px;
  border: 1px solid var(--track);
  border-radius: 999px;
  margin-bottom: 14px;
}
.phase-pill.break { color: var(--accent); border-color: var(--accent-soft); }

.ring-wrap { position: relative; width: min(74vw, 300px); aspect-ratio: 1; }
.ring { width: 100%; height: 100%; }
.ring-track { fill: none; stroke: var(--track); stroke-width: 8; }
.ring-fill {
  fill: none; stroke: var(--accent); stroke-width: 8; stroke-linecap: round;
  stroke-dasharray: 691.15; stroke-dashoffset: 691.15;
  transition: stroke-dashoffset var(--ring-anim), stroke .4s ease;
}
.ring-center {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.time {
  font-family: var(--serif);
  font-size: clamp(3rem, 15vw, 4.4rem);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--text);
}
.round-dots { display: flex; gap: 6px; margin-top: 12px; }
.round-dots i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--track); display: block;
  transition: background .3s;
}
.round-dots i.on { background: var(--accent); }

.primary-btn {
  margin-top: 22px;
  font-family: var(--serif);
  font-size: 1.14rem;
  letter-spacing: .3px;
  color: var(--bg);
  background: var(--accent);
  border: none;
  padding: 15px 42px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 6px 22px -10px var(--accent);
  transition: transform .15s ease, filter .2s ease, background .3s;
}
.primary-btn:hover { filter: brightness(1.05); }
.primary-btn:active { transform: translateY(1px) scale(.99); }
.primary-btn.running {
  background: transparent; color: var(--text);
  border: 1px solid var(--track); box-shadow: none;
}

.ghost-link, .danger-link {
  margin-top: 12px; background: none; border: none;
  color: var(--text-soft); font-size: .82rem; cursor: pointer;
  letter-spacing: .04em; padding: 6px 10px; border-radius: 8px;
}
.ghost-link:hover { color: var(--text); }
.danger-link { color: var(--accent-soft); }
.danger-link:hover { color: var(--rose-deep); }

.encourage {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.02rem;
  line-height: 1.5;
  color: var(--text-soft);
  max-width: 30ch;
  min-height: 3em;
  margin: 18px auto 0;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .6s ease, transform .6s ease;
}
.encourage.show { opacity: 1; transform: none; }

/* ---- artwork --------------------------------------------------------- */
.art-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 10px 30px -22px rgba(0,0,0,.5);
  transition: background .5s ease, opacity .4s ease;
}
.art-card.dim { opacity: .82; }
.art-frame {
  background: var(--frame);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  justify-content: center;
}
#art-canvas {
  width: 100%;
  max-width: 340px;
  aspect-ratio: 1;
  image-rendering: auto;
  border-radius: 4px;
}
.art-meta {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 14px;
}
.art-titles { display: flex; flex-direction: column; }
.art-name { font-family: var(--serif); font-size: 1.08rem; color: var(--text); }
.art-sub { font-size: .74rem; color: var(--text-soft); letter-spacing: .04em; }
.art-progress { display: flex; align-items: center; gap: 10px; min-width: 120px; }
.bar { flex: 1; height: 6px; background: var(--track); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; width: 0%; background: var(--accent); border-radius: 999px; transition: width .6s ease; }
.pct { font-size: .78rem; color: var(--text-soft); font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }

.collection { display: flex; gap: 8px; margin-top: 14px; justify-content: center; }
.collection i {
  width: 9px; height: 9px; border-radius: 50%;
  border: 1.5px solid var(--accent-soft); display: block;
}
.collection i.active { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.collection i.done { background: var(--accent); border-color: var(--accent); }

/* ---- footer ---------------------------------------------------------- */
.footer {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 14px; margin-top: auto;
  font-size: .72rem; color: var(--text-soft); min-height: 20px;
}
.install-hint { max-width: 70%; line-height: 1.4; }
.collection-pct { letter-spacing: .04em; }

/* ---- settings drawer ------------------------------------------------- */
.drawer-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.42); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 41;
  width: min(88vw, 360px);
  background: var(--surface);
  color: var(--text);
  padding: max(18px, env(safe-area-inset-top)) 22px 24px;
  box-shadow: -20px 0 50px -30px rgba(0,0,0,.6);
  overflow-y: auto;
  animation: slidein .28s ease;
}
@keyframes slidein { from { transform: translateX(100%); } to { transform: none; } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.drawer-head h2 { font-family: var(--serif); font-weight: 500; margin: 0; font-size: 1.3rem; }
.field { margin-bottom: 20px; }
.field > label { display: flex; justify-content: space-between; align-items: baseline; font-size: .84rem; color: var(--text-soft); margin-bottom: 8px; }
.field .val { color: var(--accent); font-variant-numeric: tabular-nums; }
.field-row { display: flex; align-items: center; justify-content: space-between; }
.field-row > label { margin: 0; }
input[type="range"] {
  width: 100%; -webkit-appearance: none; appearance: none;
  height: 4px; border-radius: 999px; background: var(--track); outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 20px; height: 20px;
  border-radius: 50%; background: var(--accent); cursor: pointer; border: 3px solid var(--surface);
  box-shadow: 0 2px 6px -1px rgba(0,0,0,.4);
}
input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px; border-radius: 50%; background: var(--accent);
  cursor: pointer; border: 3px solid var(--surface);
}
input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); cursor: pointer; }

.theme-row { display: flex; gap: 8px; }
.theme-swatch {
  flex: 1; font-family: var(--serif); font-size: .82rem; padding: 12px 6px;
  border-radius: 12px; border: 1.5px solid var(--track); background: var(--surface-2);
  color: var(--text); cursor: pointer; transition: border-color .2s, transform .1s;
}
.theme-swatch:hover { transform: translateY(-1px); }
.theme-swatch.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }

.drawer-foot { margin-top: 8px; border-top: 1px solid var(--track); padding-top: 16px; }

/* ---- modal ----------------------------------------------------------- */
.modal-scrim {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center;
  padding: 24px; animation: fadein .3s ease;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--surface); color: var(--text);
  border-radius: 22px; padding: 24px; max-width: 380px; width: 100%;
  text-align: center; box-shadow: 0 30px 80px -40px rgba(0,0,0,.8);
  animation: pop .4s cubic-bezier(.2,.8,.3,1.2);
}
@keyframes pop { from { transform: scale(.9); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-art { width: 220px; height: 220px; border-radius: 10px; background: var(--frame); padding: 10px; }
.modal-title { font-family: var(--serif); font-weight: 500; font-size: 1.5rem; margin: 16px 0 6px; }
.modal-line { font-family: var(--serif); font-style: italic; color: var(--text-soft); margin: 0 0 18px; line-height: 1.5; }
.modal-actions { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.modal-actions .primary-btn { margin-top: 0; }
.modal-hint { font-size: .8rem; color: var(--text-soft); margin-top: 14px; line-height: 1.5; }
.modal-brand {
  font-family: var(--serif); font-size: .72rem; letter-spacing: .1em;
  color: var(--text-soft); margin: 16px 0 0; opacity: .8;
}

@media (min-width: 620px) {
  .modal-art { width: 260px; height: 260px; }
}

/* Any wide, landscape viewport (a full-screen / docked desktop window, or a
   Notion embed): put the timer and the artwork side by side. Narrow or portrait
   viewports (phones, tall windows) stay stacked. */
@media (min-width: 680px) and (min-aspect-ratio: 1/1) {
  .app { max-width: 1000px; }
  .stage {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 30px;
  }
  .timer-card, .art-card { flex: 1 1 0; min-width: 0; }
  .art-card { max-width: 400px; }
  .ring-wrap { width: min(40vw, 224px); }
  #art-canvas { max-width: 260px; }
  .primary-btn { margin-top: 16px; padding: 12px 34px; }
  .encourage { min-height: 2.6em; margin-top: 14px; }
}

/* ---- background print opacity per theme ------------------------------ */
html[data-theme="dark"]   { --print-opacity: .26; }
html[data-theme="light"]  { --print-opacity: .55; }
html[data-theme="bubbly"] { --print-opacity: .32; }
.app { position: relative; z-index: 1; }

/* ---- task field ------------------------------------------------------ */
.task-input {
  font-family: var(--serif);
  font-size: 1.02rem;
  text-align: center;
  color: var(--text);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--track);
  padding: 6px 4px;
  margin: 2px 0 18px;
  width: min(78vw, 300px);
  outline: none;
  transition: border-color .2s;
}
.task-input::placeholder { color: var(--text-soft); font-style: italic; opacity: .8; }
.task-input:focus { border-color: var(--accent); }

.distraction-open { margin-top: 6px; opacity: .85; }
.distraction-open::before { content: "✎ "; opacity: .7; }

/* ---- settings note --------------------------------------------------- */
.field-note {
  font-size: .76rem; color: var(--text-soft); line-height: 1.5;
  margin: -8px 0 4px;
}

/* ---- distraction sheet ---------------------------------------------- */
.sheet-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 44; }
.sheet {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%);
  z-index: 45; width: min(100%, 460px);
  background: var(--surface); color: var(--text);
  border-radius: 20px 20px 0 0;
  padding: 20px 22px max(22px, env(safe-area-inset-bottom));
  box-shadow: 0 -18px 50px -28px rgba(0,0,0,.6);
  animation: sheetup .28s ease;
}
@keyframes sheetup { from { transform: translate(-50%, 100%); } to { transform: translate(-50%, 0); } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { font-family: var(--serif); font-weight: 500; margin: 0; font-size: 1.3rem; }
.sheet-sub { font-size: .84rem; color: var(--text-soft); line-height: 1.5; margin: 6px 0 14px; }
.distraction-entry { display: flex; flex-direction: column; gap: 10px; }
.distraction-entry textarea {
  width: 100%; resize: none; font-family: var(--sans); font-size: .95rem;
  color: var(--text); background: var(--surface-2); border: 1px solid var(--track);
  border-radius: 12px; padding: 10px 12px; outline: none;
}
.distraction-entry textarea:focus { border-color: var(--accent); }
.distraction-actions { display: flex; align-items: center; gap: 10px; justify-content: flex-end; }
.mic-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--track); background: var(--surface-2);
  color: var(--text-soft); cursor: pointer; transition: color .2s, border-color .2s, background .2s;
}
.mic-btn:hover { color: var(--text); }
.mic-btn.listening { color: var(--white); background: var(--accent); border-color: var(--accent); animation: pulse 1.3s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); } 50% { box-shadow: 0 0 0 8px transparent; } }
.mic-btn[hidden] { display: none !important; }
.primary-btn.small { margin-top: 0; font-size: 1rem; padding: 11px 22px; }

.distraction-list { list-style: none; margin: 16px 0 0; padding: 0; max-height: 34vh; overflow-y: auto; }
.distraction-list li {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: .92rem; line-height: 1.45; color: var(--text);
  padding: 9px 2px; border-bottom: 1px solid var(--track);
}
.distraction-list li::before { content: "•"; color: var(--accent); }
.distraction-list li.done { color: var(--text-soft); text-decoration: line-through; }
.distraction-list .di-text { flex: 1; cursor: pointer; }
.distraction-list .di-x { background: none; border: none; color: var(--text-soft); cursor: pointer; font-size: .9rem; padding: 0 4px; }
.distraction-list .di-x:hover { color: var(--rose-deep); }
.sheet .ghost-link { display: block; margin: 12px auto 0; }

@media (prefers-reduced-motion: reduce) {
  .sheet, .mic-btn.listening, .modal, .drawer { animation: none; }
  .ring-fill, .bar-fill, .encourage { transition: none; }
}
