/*
 * Journal of Prayers(TM) - base.css
 * Copyright (c) 2026 Spark Fire Technologies. All rights reserved. Proprietary.
 *
 * Palette and type are lifted from the printed pieces: the midnight-and-gold
 * cover, and the cream page with its navy headings and thin gold rules.
 */

:root {
  /* Cover: midnight blues and gilt */
  --navy-900: #0e1035;
  --navy-800: #171a4a;
  --navy-700: #232663;
  --navy-600: #2f3480;
  --navy-500: #3d4399;

  /* Gilt */
  --gold-600: #a67c1a;
  --gold-500: #c9a227;
  --gold-400: #d9b747;
  --gold-300: #e8cf85;
  --gold-200: #f2e3b3;

  /* Page: the cream stock and its inks */
  --paper: #fdfaf0;
  --paper-edge: #f2ebd8;
  --paper-shade: #e6dcc2;
  --ink: #1a2a5e;
  --ink-soft: #46527f;
  --rule: #c9b478;

  --danger: #93301f;
  --success: #2f6b46;

  --shadow-sm: 0 1px 3px rgba(14, 16, 53, .18);
  --shadow-md: 0 6px 20px rgba(14, 16, 53, .22);
  --shadow-lg: 0 24px 60px rgba(14, 16, 53, .42);

  --serif: Georgia, 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Times New Roman', serif;
  --display: 'Optima', 'Palatino Linotype', Georgia, 'Times New Roman', serif;
  --sans: 'Segoe UI', system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;

  --radius: 4px;
  /* Height of the top bar. Declared here, not on .chrome, so the stage and the
     book can subtract it - a custom property set on .chrome is invisible to a
     sibling. */
  --chrome-h: 4.25rem;
  --page-ratio: 1.294; /* height / width, taken from the supplied page art */

  /*
   * The reader's handwriting choices, from js/typography.js.
   *
   * They live here for the same reason --chrome-h does, and for a reason that
   * cost the feature entirely: typography.js applies them as inline styles on
   * the root element, and these three used to be declared on .page. A custom
   * property declared on the element itself always beats one inherited from an
   * ancestor, so .page overwrote every setting on its way down and the font,
   * size and ink controls changed nothing at all. Declared here, the inline
   * style on the same element wins, which is what was intended.
   */
  --writing-font: Georgia, 'Times New Roman', serif;
  --writing-scale: 0.62;
  --writing-ink: #1a2a5e;
}

* { box-sizing: border-box; }

/*
 * The `hidden` attribute hides via the UA sheet's `display: none`, which any
 * class-level `display` in this file would silently outrank - which is how a
 * sign-in form ends up showing its "confirm password" field. Make `hidden`
 * authoritative once, here, rather than remembering it at every call site.
 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--serif);
  color: var(--ink);
  background:
    radial-gradient(1200px 700px at 50% -10%, var(--navy-700) 0%, var(--navy-900) 60%),
    var(--navy-900);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: .01em; }

a { color: var(--gold-400); }
a:hover { color: var(--gold-300); }

button, input, textarea, select { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--gold-400);
  outline-offset: 2px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- controls ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .6rem 1.15rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  background: linear-gradient(180deg, var(--gold-400), var(--gold-600));
  color: var(--navy-900);
  font-family: var(--sans);
  font-size: .875rem;
  font-weight: 600;
  letter-spacing: .02em;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .12s ease, filter .12s ease;
}
.btn:hover:not(:disabled) { filter: brightness(1.06); box-shadow: var(--shadow-md); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-ghost {
  background: transparent;
  color: var(--gold-300);
  border-color: rgba(217, 183, 71, .45);
  box-shadow: none;
}
.btn-ghost:hover:not(:disabled) { background: rgba(217, 183, 71, .12); }

.btn-danger {
  background: transparent;
  border-color: rgba(147, 48, 31, .6);
  color: #e79b8b;
  box-shadow: none;
}
.btn-danger:hover:not(:disabled) { background: rgba(147, 48, 31, .18); }

.btn-sm { padding: .38rem .7rem; font-size: .78rem; }

.field { display: block; margin-bottom: 1rem; }
.field > span {
  display: block;
  font-family: var(--sans);
  font-size: .74rem;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--gold-300);
  margin-bottom: .4rem;
}
.field input, .field select {
  width: 100%;
  padding: .7rem .8rem;
  border-radius: var(--radius);
  border: 1px solid rgba(217, 183, 71, .34);
  background: rgba(8, 10, 32, .55);
  color: var(--paper);
  font-family: var(--sans);
  /* 16px, not .95rem. See the note below: under 16px, iOS Safari zooms the
     page in on focus and does not zoom back out. This was .95rem - 15.2px -
     and missed it by four fifths of a pixel. */
  font-size: 1rem;
}
.field input::placeholder { color: rgba(242, 227, 179, .35); }
.field input:focus { border-color: var(--gold-400); outline: none; }

/*
 * On a phone, no text field may be smaller than 16px.
 *
 * This is not a taste decision. iOS Safari zooms the entire page in when a
 * field with a font-size under 16px takes focus, and it does not zoom back out
 * when the field is left - so one tap on the email box leaves the whole site
 * enlarged and scrolled sideways, and it stays that way.
 *
 * Deliberately a bare element selector so it is a floor and not a rule:
 * anything that sets its own size with a class still wins. Which is also why
 * it is not enough on its own - `.field input` outranks it, and had to be
 * corrected at its own declaration above.
 */
@media (max-width: 620px), (max-height: 560px) and (pointer: coarse) {
  input, select, textarea { font-size: 16px; }
}

.hint {
  font-family: var(--sans);
  font-size: .78rem;
  color: rgba(242, 227, 179, .6);
  line-height: 1.5;
  margin: .35rem 0 0;
}

.notice {
  font-family: var(--sans);
  font-size: .85rem;
  padding: .7rem .9rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  border: 1px solid transparent;
  line-height: 1.45;
}
.notice-error { background: rgba(147, 48, 31, .18); border-color: rgba(147, 48, 31, .5); color: #f0b3a5; }
.notice-ok { background: rgba(47, 107, 70, .18); border-color: rgba(47, 107, 70, .5); color: #a8d9bd; }
.notice[hidden] { display: none; }

/* ---------- toast ---------- */

#toast {
  position: fixed;
  left: 50%;
  bottom: 1.6rem;
  transform: translate(-50%, 140%);
  /* Fully out of the way when idle - a translated-only toast still shows a
     sliver at the viewport edge. */
  opacity: 0;
  pointer-events: none;
  background: var(--navy-800);
  border: 1px solid rgba(217, 183, 71, .45);
  color: var(--paper);
  font-family: var(--sans);
  font-size: .86rem;
  padding: .7rem 1.1rem;
  border-radius: 999px;
  box-shadow: var(--shadow-md);
  transition: transform .28s cubic-bezier(.2, .9, .3, 1.2), opacity .2s ease;
  z-index: 90;
  max-width: min(90vw, 32rem);
  text-align: center;
}
#toast.show { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }

/*
 * On a phone the toast moves to the top.
 *
 * The foot of the screen is where the phone layout puts everything you touch -
 * the page-turn arrows, the tools row, and the scripture picker, which drops
 * downward from its button. A toast rising from the bottom covered the verse it
 * was announcing. There is nothing at the top but the bar it can sit under, so
 * it slides down from there instead; the transform is inverted to match.
 */
@media (max-width: 620px), (max-height: 560px) and (pointer: coarse) {
  #toast {
    top: calc(var(--chrome-h, 4.25rem) + .5rem);
    bottom: auto;
    transform: translate(-50%, -160%);
    max-width: calc(100vw - 2rem);
  }
  #toast.show { transform: translate(-50%, 0); }
}

/* ---------- modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6, 7, 26, .78);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  padding: 1.25rem;
  z-index: 100;
}
.modal-backdrop[hidden] { display: none; }

.modal {
  background: linear-gradient(180deg, var(--navy-800), var(--navy-900));
  border: 1px solid rgba(217, 183, 71, .35);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  width: min(38rem, 100%);
  max-height: 86vh;
  overflow: auto;
  padding: 1.6rem;
  color: var(--paper);
}
.modal h2 {
  margin: 0 0 .35rem;
  color: var(--gold-300);
  font-size: 1.3rem;
}
.modal p { font-family: var(--sans); font-size: .9rem; color: rgba(242, 227, 179, .78); line-height: 1.55; }
.modal-actions { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1.4rem; flex-wrap: wrap; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
