/* Colours. Every other rule uses these names, so changing a colour here changes it everywhere */
:root {
  --background: #F4F6F3;
  --text: #1E2A24;
  --accent: #2F6B57;
  /* Softer text for quiet links and icons */
  --muted: #5B6B63;
  color-scheme: light;
}

/* Dark theme when the device is set to dark, unless the visitor has chosen light */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --background: #121815;
    --text: #E6ECE8;
    --accent: #6FBF9E;
    --muted: #8F9C95;
    color-scheme: dark;
  }
}

/* Dark theme when the visitor has chosen dark */
:root[data-theme="dark"] {
  --background: #121815;
  --text: #E6ECE8;
  --accent: #6FBF9E;
  --muted: #8F9C95;
  color-scheme: dark;
}

/* Base text: Newsreader for all English text */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-family: "Newsreader", Georgia, serif;
  font-size: 1.125rem;
  line-height: 1.6;
}

/* Niconne for the site title only */
#siteTitle {
  font-family: "Niconne", cursive;
  font-weight: 400;
}

/* On the About page the title is a link home, but should still look like the title */
#siteTitle a {
  color: inherit;
  text-decoration: none;
}

/* Amiri for anything in Arabic */
[lang="ar"] {
  font-family: "Amiri", serif;
}

a {
  color: var(--accent);
}

/* Keyboard focus: a clear ring around whatever is selected with the Tab key */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Header: title on the left, quiet link and icons on the right, tagline underneath */
#siteHeader {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  column-gap: 0.5rem;
  padding: 1.5rem 16px;
}

#siteTitle {
  margin: 0;
  font-size: 3rem;
  line-height: 1.1;
}

#siteTagline {
  grid-column: 1 / -1;
  margin: 0.25rem 0 0;
}

/* On the title's row, in the right-hand column */
#siteHeader nav {
  grid-row: 1;
  grid-column: 2;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* Round icon buttons: theme and My reflections */
.iconButton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.iconButton:hover {
  background: color-mix(in srgb, var(--accent) 12%, var(--background));
  color: var(--accent);
}

.iconButton svg {
  width: 22px;
  height: 22px;
}

/* Only the icon for the current theme shows. js/app.js sets data-theme-choice */
.themeIcon {
  display: none;
}

#themeButton[data-theme-choice="system"] .systemIcon,
#themeButton[data-theme-choice="light"] .sunIcon,
#themeButton[data-theme-choice="dark"] .moonIcon {
  display: block;
}

/* The panel's Close button: a rounded outline, at least 44px tall */
#closePanelButton {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 1rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: transparent;
  color: var(--accent);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

#closePanelButton:hover {
  background: var(--accent);
  color: var(--background);
}

/* Wider screens: a little more space at the sides */
@media (min-width: 700px) {
  #siteHeader {
    padding: 1.5rem 2rem;
  }
}

/* Main content: a comfortable reading width, centred, 16px from the edges on phones */
#dailyPage,
#aboutPage {
  max-width: 40rem;
  margin: 0 auto;
  padding: 0 16px 3rem;
}

/* Photo: a slim banner, so the verse shows on the first screen of a phone */
#dailyPhoto {
  margin: 0;
}

#dailyPhotoFrame {
  aspect-ratio: 3 / 1;
  overflow: hidden;
  border-radius: 0.75rem;
  /* Soft green shown while the photo loads, or if it is missing */
  background: color-mix(in srgb, var(--accent) 12%, var(--background));
}

#dailyPhotoFrame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Wider screens have more room, so the banner can be a little taller */
@media (min-width: 700px) {
  #dailyPhotoFrame {
    aspect-ratio: 5 / 2;
  }
}

/* Small labels above the verse and the prompt */
#verseHeading,
#promptHeading {
  margin: 0 0 0.75rem;
  color: var(--accent);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

/* Verse: centred, with the Arabic largest */
#dailyVerse {
  margin-top: 2.5rem;
  text-align: center;
}

#verseArabic {
  margin: 0;
  font-size: 2rem;
  line-height: 2;
}

#verseTranslation {
  margin: 1rem 0 0;
  font-size: 1.25rem;
  font-style: italic;
}

#verseReference {
  margin: 0.5rem 0 0;
  font-size: 1rem;
}

/* Prompt */
#dailyPrompt {
  margin-top: 2.5rem;
}

#promptText {
  margin: 0;
  font-size: 1.25rem;
}

/* Reflection box */
#reflectionForm {
  margin-top: 1.5rem;
}

#reflectionForm label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 700;
}

#reflectionText {
  display: block;
  width: 100%;
  min-height: 12rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--accent);
  border-radius: 0.75rem;
  background: var(--background);
  color: var(--text);
  font: inherit;
  resize: vertical;
}

#saveButton {
  min-height: 44px;
  margin-top: 1rem;
  padding: 0 1.75rem;
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: var(--background);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

/* Reflections panel. Phones first: waits off the right edge, slides in when js/app.js adds isOpen */
#reflectionsPanel {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto;
  align-content: start;
  align-items: center;
  gap: 1rem;
  width: min(22rem, 85vw);
  height: 100vh;
  padding: 1.5rem 16px;
  overflow-y: auto;
  border-left: 1px solid color-mix(in srgb, var(--accent) 30%, var(--background));
  background: color-mix(in srgb, var(--accent) 6%, var(--background));
  box-shadow: -0.5rem 0 2rem rgb(0 0 0 / 0.15);
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 0.3s ease, visibility 0.3s;
}

/* Visible straight away when opening, so the Close button can take focus; still slides in */
#reflectionsPanel.isOpen {
  transform: translateX(0);
  visibility: visible;
  transition: transform 0.3s ease, visibility 0s;
}

#reflectionsHeading {
  margin: 0;
  font-size: 1.5rem;
}

/* Each month spans the full width, under the heading and Close button */
.reflectionMonth {
  grid-column: 1 / -1;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 30%, var(--background));
}

.reflectionMonth summary {
  display: flex;
  align-items: center;
  min-height: 44px;
  font-weight: 700;
  cursor: pointer;
}

/* Hide the browser's own arrow, Safari included, in favour of the plus sign below */
.reflectionMonth summary {
  list-style: none;
}

.reflectionMonth summary::-webkit-details-marker {
  display: none;
}

/* A plus sign that turns into a cross when the month is open */
.reflectionMonth summary::after {
  content: "+";
  margin-left: auto;
  color: var(--accent);
  font-size: 1.5rem;
  transition: transform 0.2s ease;
}

.reflectionMonth[open] summary::after {
  transform: rotate(45deg);
}

.reflectionList {
  margin: 0;
  padding: 0 0 1rem;
  list-style: none;
}

.reflectionEntry {
  margin-top: 0.75rem;
}

.reflectionEntry time {
  color: var(--accent);
  font-size: 0.875rem;
  font-weight: 700;
}

.reflectionEntry p {
  margin: 0.25rem 0 0;
}

/* Desktop: panel always shown on the right, page content makes room for it */
@media (min-width: 1000px) {
  /* Only pages with the panel need to make room for it */
  body:has(#reflectionsPanel) {
    padding-right: 22rem;
  }

  #reflectionsPanel {
    width: 22rem;
    box-shadow: none;
    transform: none;
    visibility: visible;
    transition: none;
  }

  /* No need to open or close a panel that is always there */
  #siteHeader #reflectionsButton,
  #closePanelButton {
    display: none;
  }
}

/* Visitors who prefer less motion get no sliding */
@media (prefers-reduced-motion: reduce) {
  #reflectionsPanel {
    transition: none;
  }
}

/* Footer: quiet, centred under the main content */
/* Width matches the main content's text, so the line above lines up with it */
#siteFooter {
  width: min(40rem - 32px, 100% - 32px);
  margin: 0 auto;
  padding: 1.5rem 0 2rem;
  border-top: 1px solid color-mix(in srgb, var(--accent) 30%, var(--background));
}

#siteFooter nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem 1.5rem;
}

/* Links stay at least 44px tall so they are easy to tap */
#siteFooter a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: 1rem;
}

#saveMessage {
  margin: 0.75rem 0 0;
  font-size: 1rem;
}

/* About page: soft headings and generous space between sections */
#aboutHeading {
  margin: 1rem 0 2rem;
  font-size: 2.25rem;
  font-weight: 400;
  line-height: 1.2;
}

#aboutPage section {
  margin-top: 2.5rem;
}

#aboutPage h2 {
  margin: 0 0 0.75rem;
  color: var(--accent);
  font-size: 1.4rem;
  font-weight: 400;
}

#aboutPage section p {
  margin: 0 0 1rem;
}
