/* Page layout and controls. Cards and spreads are in cards.css. Dark theme
   only; colours are tokens so a light theme could be added later. */

:root {
  --bg: #14111f;
  --surface: #211c33;
  --surface-raised: #2c2545;
  --text: #ece6f5;
  --text-muted: #a99fbd;
  --accent: #d9b45a;
  --accent-text: #1b1608;
  --radius: 12px;
  --gutter: 16px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-display: "Iowan Old Style", "Palatino", Georgia, serif;
  --border: rgb(217 180 90 / 25%);
  --error: #f0a3a3;
  color-scheme: dark;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: radial-gradient(ellipse at 50% 0%, var(--surface) 0%, var(--bg) 70%) fixed, var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  /* Installed app: the page runs under the status bar and the home indicator. */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom)
    env(safe-area-inset-left);
  -webkit-tap-highlight-color: transparent;
}

.header {
  padding: 24px var(--gutter) 8px;
  text-align: center;
}

.header__logo {
  display: block;
  width: 58px;
  height: 56px;
  margin: 0 auto 6px;
}

/* Short screens (iPhone SE): a smaller logo keeps the form higher. */
@media (max-height: 700px) {
  .header {
    padding-top: 16px;
  }

  .header__logo {
    width: 41px;
    height: 40px;
    margin-bottom: 2px;
  }
}

/* During a reading the spread needs the room: no logo, no tagline. */
.is-reading .header__logo,
.is-reading .header__subtitle {
  display: none;
}

.header__title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--accent);
}

.header__subtitle {
  margin: 4px 0 0;
  color: var(--text-muted);
}

[hidden] {
  display: none !important;
}

.main {
  max-width: 40rem;
  margin: 0 auto;
  padding: 8px var(--gutter) 24px;
}

.button {
  min-height: 44px;
  padding: 12px 28px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
}

.button--primary {
  display: block;
  margin: 0 auto;
  background: var(--accent);
  color: var(--accent-text);
}

.button--link {
  background: none;
  color: var(--text-muted);
  font-weight: 400;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.button:disabled {
  opacity: 0.5;
  cursor: default;
}

.button:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 3px;
}

.note {
  margin: 0 auto;
  max-width: 32em;
  text-align: center;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.note--left {
  margin: 6px 0 0;
  text-align: left;
}

.note--error {
  color: var(--error);
}

/* --- Home ---------------------------------------------------------------- */

.home {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.section-title,
.field__label {
  display: block;
  margin: 0 0 8px;
  padding: 0;
  font-family: var(--font-display);
  font-size: 1.125rem;
  color: var(--accent);
}

.spread-choice {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.spread-choice__options {
  display: grid;
  gap: 8px;
}

.spread-option {
  position: relative;
  display: grid;
  gap: 2px;
  padding: 12px 14px 12px 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgb(33 28 51 / 70%);
  cursor: pointer;
}

.spread-option:has(:checked) {
  border-color: var(--accent);
  background: var(--surface-raised);
}

.spread-option:has(:focus-visible) {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

.spread-option__input {
  position: absolute;
  top: 14px;
  left: 14px;
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--accent);
}

.spread-option__name {
  font-weight: 600;
}

.spread-option__count {
  font-weight: 400;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.spread-option__description {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.field__optional {
  font-family: var(--font);
  font-size: 0.875rem;
  color: var(--text-muted);
}

.field__input {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  /* 16 px or more, or iOS zooms in on focus. */
  font: inherit;
  font-size: 1rem;
  resize: vertical;
}

.field__input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* On/off switch over a native checkbox (role="switch"). */
.switch {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  cursor: pointer;
}

.switch__label {
  font-weight: 600;
}

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

.switch__track {
  position: relative;
  flex: none;
  width: 51px;
  height: 31px;
  border-radius: 999px;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  transition: background 0.2s;
}

.switch__track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 25px;
  height: 25px;
  border-radius: 50%;
  background: var(--text);
  transition: transform 0.2s;
}

.switch__input:checked ~ .switch__track {
  background: var(--accent);
}

.switch__input:checked ~ .switch__track::after {
  transform: translateX(20px);
}

.switch__input:focus-visible ~ .switch__track {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .switch__track,
  .switch__track::after {
    transition: none;
  }
}

/* --- Reading ------------------------------------------------------------- */

.reading {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.reading__title {
  margin: 0;
  outline: none;
  text-align: center;
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--accent);
}

.reading__question {
  margin: -8px 0 0;
  text-align: center;
  font-style: italic;
  overflow-wrap: anywhere;
}

.reading__details {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.answer {
  padding: 16px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface-raised);
  text-align: center;
}

.answer__intro {
  margin: 0;
  color: var(--text-muted);
}

.answer__label {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 2.25rem;
  font-weight: 600;
  color: var(--accent);
}

.interpretations {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.interpretation {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgb(33 28 51 / 70%);
  scroll-margin-top: calc(env(safe-area-inset-top) + 12px);
}

.interpretation:focus {
  outline: none;
}

.interpretation.is-highlighted {
  animation: highlight 1.6s ease-out;
}

@keyframes highlight {
  from {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgb(217 180 90 / 45%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .interpretation.is-highlighted {
    animation: none;
    border-color: var(--accent);
  }
}

.interpretation__header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.interpretation__number {
  display: grid;
  place-items: center;
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 0.75rem;
  font-weight: 700;
}

.interpretation__label {
  font-weight: 600;
  color: var(--accent);
}

.interpretation__position {
  margin: 2px 0 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.interpretation__name {
  margin: 10px 0 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
}

.interpretation__reversed {
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--text-muted);
}

.interpretation__keywords {
  margin: 2px 0 0;
  font-size: 0.875rem;
  color: var(--accent);
}

.interpretation__meaning {
  margin: 8px 0 0;
}

/* --- Footer and About ---------------------------------------------------- */

.footer {
  padding: 0 var(--gutter) 24px;
  text-align: center;
}

/* "Add to home screen" hint, in the page flow above the About button. */
.install-hint {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  max-width: 34rem;
  margin: 0 auto 12px;
  padding: 10px 4px 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
}

.install-hint__text {
  flex: 1;
  min-width: 0;
  margin: 2px 0 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.install-hint__icon {
  width: 1.15em;
  height: 1.15em;
  vertical-align: -0.2em;
  color: var(--accent);
}

.install-hint__dismiss {
  flex: none;
  width: 44px;
  height: 44px;
  margin: -10px 0 -10px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--text-muted);
  font: inherit;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
}

.install-hint__dismiss:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: -4px;
}

.about {
  width: min(100% - 2 * var(--gutter), 34rem);
  max-height: calc(100% - 2 * var(--gutter) - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
}

.about::backdrop {
  background: rgb(10 8 16 / 75%);
}

.about__body {
  padding: 20px 20px 0;
}

.about__title {
  margin: 0 0 8px;
  font-family: var(--font-display);
  color: var(--accent);
}

.about__heading {
  margin: 20px 0 4px;
  font-size: 1rem;
  color: var(--accent);
}

.about p {
  margin: 0;
}

.about a {
  color: var(--text);
}

.about__sources {
  margin-top: 8px;
}

.about__sources summary {
  padding: 11px 0;
  cursor: pointer;
  color: var(--text-muted);
}

.about__sources ul {
  margin: 0;
  padding-left: 20px;
  font-size: 0.875rem;
}

.about__sources li {
  padding: 4px 0;
}

.about__actions {
  padding: 20px;
}
