/* Inward — calm, serif, lots of space. Italic instead of bold. */

@font-face {
  font-family: "Fraunces";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/fraunces-latin-normal.woff2") format("woff2");
}

@font-face {
  font-family: "Fraunces";
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/fraunces-latin-italic.woff2") format("woff2");
}

/* Colours are registered so they can fade from one to the next */
@property --bg-top { syntax: "<color>"; inherits: true; initial-value: #F4F0E8; }
@property --bg-bottom { syntax: "<color>"; inherits: true; initial-value: #E2E4DD; }
@property --ink { syntax: "<color>"; inherits: true; initial-value: #1F3A4A; }
@property --ink-soft { syntax: "<color>"; inherits: true; initial-value: #3D5664; }
@property --accent { syntax: "<color>"; inherits: true; initial-value: #4C675B; }

:root {
  /* Palette */
  --teal-night: #1F3A4A;
  --sage: #8FA89B;
  --lavender: #A99BC4;
  --cream: #F4F0E8;

  /* Neutral look (Settings, welcome, setup), light mode */
  --bg-top: #F4F0E8;
  --bg-bottom: #E2E4DD;
  --ink: #1F3A4A;
  --ink-soft: #3D5664;
  --accent: #4C675B;

  --serif: "Fraunces", "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --fade: 1.4s;

  transition:
    --bg-top 1.6s ease, --bg-bottom 1.6s ease, --accent 1.6s ease,
    --ink 1.6s ease, --ink-soft 1.6s ease;
}

/* Night mode switches in and out slowly */
html.slow-fade {
  transition-duration: 6s;
}

/* No fade on the very first paint */
html.no-fade {
  transition: none;
}

/* On the prompt screen, each category tints the background and colours its name.
   Light mode: pale creamy backgrounds; the prompt stays deep teal.
   All colours checked for WCAG AA contrast. */
html[data-category="emotions"] {
  --bg-top: #EAE4E3;
  --bg-bottom: #DAD3DC;
  --accent: #645189;
}

html[data-category="relationships"] {
  --bg-top: #EDE4DE;
  --bg-bottom: #E4D3CF;
  --accent: #834C53;
}

html[data-category="memory"] {
  --bg-top: #EEE6D6;
  --bg-bottom: #E5D8BD;
  --accent: #705829;
}

html[data-category="longing"] {
  --bg-top: #E6E6E3;
  --bg-bottom: #D2D8DC;
  --accent: #405E7A;
}

html[data-category="gratitude"] {
  --bg-top: #E6E6DD;
  --bg-bottom: #D2D8CE;
  --accent: #4A5F54;
}

html[data-category="fears"] {
  --bg-top: #E4E2DE;
  --bg-bottom: #CCCFD1;
  --accent: #4A5767;
}

html[data-category="identity"] {
  --bg-top: #E4E7DF;
  --bg-bottom: #CCDAD2;
  --accent: #3D635D;
}

/* Dark mode: deep, muted backgrounds tinted with the category; the prompt stays cream */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-top: #1F3A4A;
    --bg-bottom: #13242F;
    --ink: #F4F0E8;
    --ink-soft: #D3D6D2;
    --accent: #B9CDC2;
  }

  html[data-category="emotions"] {
    --bg-top: #424759;
    --bg-bottom: #28313D;
    --accent: #BFB5D3;
  }

  html[data-category="relationships"] {
    --bg-top: #4A474E;
    --bg-bottom: #2B3139;
    --accent: #D1B1B4;
  }

  html[data-category="memory"] {
    --bg-top: #4B4B3E;
    --bg-bottom: #2B3333;
    --accent: #D2B884;
  }

  html[data-category="longing"] {
    --bg-top: #3A4C59;
    --bg-bottom: #25333D;
    --accent: #AABED2;
  }

  html[data-category="gratitude"] {
    --bg-top: #3A4B4D;
    --bg-bottom: #253338;
    --accent: #ACBEB5;
  }

  html[data-category="fears"] {
    --bg-top: #36434F;
    --bg-bottom: #233039;
    --accent: #A6B1BF;
  }

  html[data-category="identity"] {
    --bg-top: #364D50;
    --bg-bottom: #23343A;
    --accent: #9BC2BB;
  }
}

/* Warm night, 21:00–05:00: one palette with no blue light, on every screen and
   in both phone modes (set from app.js; overrides everything above) */
html[data-night],
html[data-night][data-category] {
  --bg-top: #2A2019;
  --bg-bottom: #1E1712;
  --ink: #EADBC4;
  --ink-soft: #CDB89C;
  --accent: #C9A06A;
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* No pull-to-refresh: a reload mid-way is never what the user meant */
html,
body {
  overscroll-behavior-y: contain;
}

html {
  min-height: 100%;
  background-color: var(--bg-bottom);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--serif);
  font-weight: 350;
  font-size: 1.0625rem;
  line-height: 1.6;
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
}

/* A fixed layer for the gradient (background-attachment: fixed is unreliable on iOS) */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}

/* Layout */

.screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding:
    max(3rem, env(safe-area-inset-top))
    max(1.5rem, env(safe-area-inset-right))
    max(2rem, env(safe-area-inset-bottom))
    max(1.5rem, env(safe-area-inset-left));
}

.column {
  width: 100%;
  max-width: 34rem;
  margin: 0 auto;
}

#settings,
#setup,
#reminders {
  justify-content: flex-start;
}

/* Welcome */

.welcome-text {
  font-style: italic;
  font-weight: 300;
  font-size: clamp(1.35rem, 1rem + 1.6vw, 1.75rem);
  line-height: 1.55;
  margin: 0 0 2.5rem;
  animation: fade-in var(--fade) ease both;
}

/* Today */

.today {
  text-align: center;
}

.prompt-block {
  margin-bottom: 2.25rem;
}

.category {
  margin: 0 0 1.5rem;
  font-size: 0.8125rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

.prompt {
  margin: 0;
  font-style: italic;
  font-weight: 300;
  font-size: clamp(1.75rem, 1.1rem + 3.4vw, 2.85rem);
  line-height: 1.3;
  text-wrap: balance;
}

.fade-in {
  animation: fade-in var(--fade) ease both;
}

.invitation {
  margin: 0 auto 2.75rem;
  max-width: 26rem;
  font-style: italic;
  color: var(--ink-soft);
  text-wrap: balance;
}

.footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding-top: 2rem;
  text-align: center;
}

#today {
  justify-content: space-between;
}

#today .today {
  margin: auto;
}

/* Text: headings in italic, never bold */

.screen-title {
  font-style: italic;
  font-weight: 300;
  font-size: clamp(1.75rem, 1.3rem + 2vw, 2.25rem);
  line-height: 1.25;
  margin: 0 0 0.75rem;
}

.setting-title {
  font-style: italic;
  font-weight: 400;
  font-size: 1.15rem;
  margin: 0 0 0.75rem;
  padding: 0;
}

.quiet {
  color: var(--ink-soft);
  margin: 0.75rem 0 0;
}

.note:empty {
  display: none;
}

/* One calendar button per time on Android */
.calendar-android-note {
  margin: 1.5rem 0 0;
  padding-left: 1.4rem;
}

.calendar-android-note li + li {
  margin-top: 0.4rem;
}

.calendar-android-note:not([hidden]) + .calendar-actions {
  padding-top: 1.25rem;
}

#settings .calendar-android-note,
.calendar-changed {
  margin: 0 0 1.25rem;
}

/* Folded: one quiet link per time, each opening the calendar directly */
.calendar-folded {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.calendar-again {
  text-align: left;
}

.calendar-folded-hint {
  margin-top: 0.25rem;
}

.calendar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

a.button {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.install-setup {
  padding-top: 1.5rem;
}

.install-ios {
  font-style: italic;
}

#settings [data-setup-only] {
  display: none;
}

.setting {
  border: 0;
  margin: 0;
  padding: 1.75rem 0 0;
  min-width: 0;
}

/* Legends sit in the fieldset border by default; float them back into the flow */
legend.setting-title {
  float: left;
  width: 100%;
}

legend.setting-title + * {
  clear: both;
}

.choices {
  margin: 0;
}

/* Controls */

.button {
  font: inherit;
  font-style: italic;
  font-size: 1.0625rem;
  color: var(--ink);
  background: transparent;
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 0.7rem 1.6rem;
  min-height: 2.75rem;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.button:hover {
  background-color: color-mix(in srgb, var(--ink) 8%, transparent);
}

.link {
  font: inherit;
  font-style: italic;
  color: var(--ink);
  background: none;
  border: 0;
  padding: 0.5rem 0;
  min-height: 2.75rem;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.3em;
  text-decoration-color: color-mix(in srgb, var(--ink) 45%, transparent);
}

.link:hover {
  text-decoration-color: currentColor;
}

/* "← Home" at the top of Settings (the arrow is drawn: the font has no arrow glyph) */
.back-home {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: -0.5rem 0 1.25rem;
  font-size: 0.9375rem;
  color: var(--ink-soft);
}

.back-arrow {
  flex: none;
}

/* Info & privacy page */
#info {
  justify-content: flex-start;
}

.info .setting-title {
  margin-top: 2rem;
}

.info p,
.info ul {
  margin: 0.6rem 0 0;
}

.info ul {
  padding-left: 1.3rem;
}

.info li + li {
  margin-top: 0.3rem;
}

.info a {
  color: var(--ink);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
  text-decoration-color: color-mix(in srgb, var(--ink) 45%, transparent);
  overflow-wrap: anywhere;
}

.info a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.info .info-updated {
  margin-top: 2.5rem;
  font-style: italic;
}

/* The same control at the bottom of Settings */
.actions .back-home {
  margin: 0;
}

.link.small {
  font-size: 0.9375rem;
  color: var(--ink-soft);
}

.button:focus-visible,
.link:focus-visible,
.option input:focus-visible + span,
.time input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.5rem;
  padding-top: 2.5rem;
}

.options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.option {
  position: relative;
  cursor: pointer;
}

.option input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.option span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0.4rem 1.1rem;
  border: 1px solid color-mix(in srgb, var(--ink) 35%, transparent);
  border-radius: 999px;
  color: var(--ink-soft);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.option input:checked + span {
  border-color: var(--ink);
  color: var(--ink);
  font-style: italic;
  background-color: color-mix(in srgb, var(--ink) 9%, transparent);
}

.times {
  display: grid;
  gap: 0.75rem;
}

.time {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 20rem;
}

.time span {
  color: var(--ink-soft);
}

.time input {
  font: inherit;
  font-size: 1.0625rem;
  color: var(--ink);
  background: color-mix(in srgb, var(--ink) 6%, transparent);
  border: 1px solid color-mix(in srgb, var(--ink) 35%, transparent);
  border-radius: 0.6rem;
  padding: 0.45rem 0.7rem;
  min-height: 2.75rem;
  color-scheme: light;
}

html[data-night] .time input {
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  .time input {
    color-scheme: dark;
  }
}

noscript p {
  padding: 3rem 1.5rem;
}

/* Motion */

@keyframes fade-in {
  from { opacity: 0; transform: translateY(0.4rem); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* Larger screens: a little more air */

@media (min-width: 48rem) {
  body {
    font-size: 1.125rem;
  }
  .screen {
    padding-left: 3rem;
    padding-right: 3rem;
  }
  .prompt-block {
    margin-bottom: 2.75rem;
  }
}
