/* Color Palette */
:root {
  /* Base colors */
  --color-light-crust: #F6EBCB;
  --color-medium-crust: #E3CB93;
  --color-dark-crust: #DC9C54;
  --color-medium-cherry: #572E31;
  --color-dark-cherry: #2F2222;
  
  /* Semantic mappings */
  --color-background: var(--color-light-crust);
  --color-text: var(--color-dark-cherry);
  --color-text-secondary: var(--color-medium-crust);
  --color-accent: var(--color-dark-crust);
  --color-card: var(--color-medium-cherry);
}

/* Default background and text colors */
body {
  background: var(--color-background);
  color: var(--color-text);
}

/* Typography class for UI elements (buttons, labels, etc.) */
.ui-text {
  font-size: 0.95rem;
}


.primary-button {
  margin-top: 1.5rem;
  padding: 0.6rem 1.5rem;
  min-width: 8rem;
  border-radius: 999px;
  border: 1px solid var(--color-dark-crust);
  background: var(--color-light-crust);
  color: var(--color-dark-crust);
  cursor: pointer;
}

.secondary-button {
  /* margin-top: 1.5rem; */
  padding: 0.6rem 1.5rem;
  min-width: 8rem;
  border-radius: 999px;
  border: 1px solid var(--color-dark-cherry);
  background: var(--color-dark-cherry);
  color: var(--color-light-crust);
  cursor: pointer;
}

.tertiary-button {
  margin-top: 0rem;
  padding: 0.6rem 0;
  /* min-width: 8rem; */
  border: none;
  color: var(--color-medium-crust);
  background: var(--color-light-crust);
  cursor: pointer;
}

/* Apply typography to all button classes, info text elements, and settings drawer */
.primary-button,
.secondary-button,
.tertiary-button,
.info-book,
.info-subtitle,
.info-version-meta,
.info-air-date,
.info-meta,
.ui-text,
.settings-section-label,
.settings-row,
.settings-row-label,
.settings-row-button,
.settings-row-button span,
.settings-close,
.settings-dev-inline input,
.settings-dev-inline button,
.settings-inline-error,
.settings-row button.danger,
.segmented-control button,
.about-body,
.about-body p {
  font-size: 1.05rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Smaller font size for section labels (hierarchy) */
.settings-section-label {
  font-size: 0.75rem;
}

/* Slight hover affordance on larger screens */
@media (hover: hover) {
  .primary-button:hover {
    color: var(--color-light-crust);
    background: var(--color-dark-crust)
  }
}

#quote p {
  margin: 0 0 1rem; /* normal paragraph spacing */
  orphans: 2;
}

#quote {
  max-width: 500px;      /* caps width on large displays */
  padding: 80px 1rem 0;       /* top padding 60px, horizontal padding 1rem */
  text-align: left;    /* center the text inside */
  line-height: 1.4;      /* give it some air */
  font-size: 2.5rem; /* fixed size */
  margin: 30px auto 1.5rem; /* pushes it down a bit from the top */
  font-family: "Libre Caslon Text", serif;
}

/* Text size variants, driven by a class on <body> */
body.text-size-small #quote {
  font-size: 1.0rem;
}

body.text-size-medium #quote {
  font-size: 1.33rem; /* same as default */
}

body.text-size-large #quote {
  font-size: 1.66rem;
}

body.text-size-xlarge #quote  {
  font-size: 2.0rem;
}

#secondary-buttons {
  max-width: 500px;
  margin: 0 auto 2rem;   /* centers the block, like #quote */
  padding: 0 1rem;       /* matches #quote's horizontal padding */
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end; /* buttons align to the right */
}

#back-button {
  display: none;
}

#back-button.visible {
  display: inline-block;
  margin-right: auto; /* push back button to left, info button stays on right */
}

#secondary-buttons .primary-button {
  margin-top: 0;
}

.hidden {
  display: none;
}

/* Hide the info overlay when it has the .hidden class */
#info-overlay.hidden {
  display: none;
}

/* Full-screen dimmed overlay */
#info-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: flex-start;
  padding-top: 6rem; /* tweak this amount */
  justify-content: center;
  z-index: 4000;
}

/* The card itself */
.info-card {
  width: 100%;
  max-width: 24rem;
  margin: 0 1rem 1.5rem;
  padding: 1rem;
  border-radius: 0.75rem;
  background: var(--color-dark-crust);
  color: var(--color-light-crust);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

/* Cover image */
.info-cover {
  width: 100%;
  aspect-ratio: 1; /* Book cover aspect ratio */
  object-fit: cover;
  border-radius: 0.5rem;
  margin-bottom: 0.75rem;
}

/* Book + meta text */
.info-text-block {
  margin-bottom: 0.75rem;
}

.info-book {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.info-subtitle {
  font-style: italic;
  font-weight: 400;
}

.info-version-meta {
  opacity: 0.7;  /* low contrast */
  margin-bottom: 0.25rem;
}

.info-air-date {
  opacity: 0.7;  /* low contrast */
  margin-bottom: 0.25rem;
}

.info-meta {
  opacity: 0.7;  /* low contrast */
  display: flex;
  gap: 0.5rem;
}

.info-debug-versions {
  opacity: 0.7;  /* low contrast */
}

/* Actions row */
.info-actions {
  max-width: 500px;
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end; /* buttons align to the right */
}

/* Base position (desktop / normal Safari) */
#app-footer {
  position: fixed;
  top: 0.75rem;
  right: 0.75rem;
}

/* If safe-area insets are supported (iOS with viewport-fit=cover) */
@supports (bottom: env(safe-area-inset-bottom)) {
  #app-footer {
    bottom: calc(env(safe-area-inset-bottom) + 2.0rem);
    right: calc(env(safe-area-inset-right) + 2.0rem);
  }
}

.footer-icon {
  background: var(--color-light-crust);
  color: var(--color-dark-crust);
  border-radius: 999px;
  border: 1px solid var(--color-dark-crust);
  font-size: 2rem;
  padding: 0.25rem;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  cursor: pointer;
  position: relative;
}

.footer-icon {
  font-size: 0;
}

.footer-icon::before {
  content: "⚙︎";
  font-size: 2rem;
  display: block;
  transform: translateY(-0.15rem);
  line-height: 1;
}

@media (hover: hover) {
  .footer-icon:hover {
    background: var(--color-dark-crust);
    color: var(--color-light-crust)
  }
}

.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 4400;
}

.settings-overlay.hidden {
  display: none;
}

.settings-sheet {
  width: 100%;
  max-width: 480px;
  background: var(--color-dark-crust);
  color: #eee8d5;
  border-radius: 1rem 1rem 0 0;
  padding: 0.75rem 1.25rem 1.25rem;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.5);
}

.settings-grabber {
  width: 2.5rem;
  height: 0.25rem;
  border-radius: 999px;
  background: var(--color-light-crust);
  margin: 0 auto 0.75rem;
}

.settings-section {
  margin-bottom: 0.75rem;
}

.settings-section-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  opacity: 0.7;
  margin-bottom: 0.25rem;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.4rem 0;
  line-height: 2.57; /* 39px content height with 0.95rem font-size */
}

.settings-row-label {
  flex: 1;
}

.settings-row-multiline {
  line-height: 1.35;
}

.settings-row-button {
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  padding: 0.4rem 0;
  cursor: pointer;
}

.settings-row-button span {
  border-bottom: 1px dotted rgba(147, 161, 161, 0.7);
}

.segmented-control {
  display: inline-flex;
  border-radius: 999px;
  border: 1px solid var(--color-medium-cherry);
  overflow: hidden;
  height: 39px;
}

.segmented-control button {
  border: none;
  background: transparent;
  color: var(--color-light-crust);
  padding: 0.25rem 1.4rem;
  cursor: pointer;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.segmented-control button + button {
  border-left: 1px solid var(--color-medium-cherry);
}

.segmented-control button.active {
  background: var(--color-medium-cherry);
  color: var(--color-light-crust);
}

.settings-row-dev {
  flex-direction: column;
  align-items: stretch;
}

.settings-dev-inline {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.settings-dev-inline input {
  flex: 0.5;
  padding: 0.25rem 0.4rem;
  border-radius: 0.25rem;
  border: 1px solid var(--color-medium-cherry);
  background: var(--color-dark-crust);
  color: var(--color-light-crust);
}

.settings-dev-inline button {
  padding: 0.25rem 0.6rem;
}

.settings-inline-error {
  margin-top: 0.25rem;
  color: #dc322f;
}

.settings-row button.danger {
  border: 1px solid #dc322f;
  border-radius: 999px;
  padding: 0.25rem 0.7rem;
  background: transparent;
  color: #dc322f;
}


.settings-close {
  margin-top: 0.75rem;
  display: block;
  margin-left: auto;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--color-light-crust);
  background: transparent;
  color: var(--color-light-crust);
  cursor: pointer;
}

.about-sheet {
  border-radius: 0.75rem;
  margin: 0 1rem 2rem;
}

.about-body {
  font-size: 0.9rem;
  line-height: 1.4;
}
