/* ============================================================
   SHEPHERD — Global Stylesheet
   Catholic discipleship tool · Mobile-first · No magic colors
   ============================================================ */

/* ------------------------------------------------------------
   1. DESIGN TOKENS
   ------------------------------------------------------------ */

:root {
  /* Colors — deep navy primary, clean neutral surfaces */
  --color-primary:      #1e3a5f;
  --color-primary-dark: #142840;
  --color-bg:           #f5f5f0;
  --color-surface:      #ffffff;
  --color-text:         #1a1a1a;
  --color-text-muted:   #6b7280;
  --color-border:       #d1d5db;
  --color-danger:       #b91c1c;

  /* Type scale */
  --text-sm:   0.875rem;
  --text-base: 1rem;
  --text-lg:   1.125rem;
  --text-xl:   1.25rem;

  /* Spacing — 4px base unit */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;

  /* Radii */
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 8px 0 rgba(0, 0, 0, 0.12);
}

/* ------------------------------------------------------------
   2. RESET / NORMALIZE
   ------------------------------------------------------------ */

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

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    'Helvetica Neue', Arial, sans-serif;
  font-size: var(--text-base);
  color: var(--color-text);
  background-color: var(--color-bg);
  line-height: 1.6;
  min-height: 100dvh;
}

ul,
ol {
  list-style: none;
}

a {
  color: inherit;
  text-decoration: none;
}

img,
svg {
  display: block;
  max-width: 100%;
}

/* ------------------------------------------------------------
   3. LAYOUT PRIMITIVES
   ------------------------------------------------------------ */

/* Centered content column */
.container {
  width: 100%;
  max-width: 40rem;
  margin-inline: auto;
  padding-inline: var(--space-4);
}

/* Vertical flex stack */
.stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* Horizontal flex row */
.row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--space-3);
}

/* ------------------------------------------------------------
   4. HEADER
   ------------------------------------------------------------ */

header {
  background-color: var(--color-primary);
  color: var(--color-surface);
  padding: var(--space-3) var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}

header h1,
header .header-title {
  font-size: var(--text-lg);
  font-weight: 600;
  letter-spacing: 0.01em;
}

header nav a,
header button {
  color: var(--color-surface);
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: var(--text-sm);
  opacity: 0.85;
}

header nav a:hover,
header button:hover {
  opacity: 1;
}

/* ------------------------------------------------------------
   5. BOTTOM NAVIGATION
   ------------------------------------------------------------ */

nav.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: var(--color-surface);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  padding-bottom: env(safe-area-inset-bottom, 0);
  box-shadow: var(--shadow-md);
  z-index: 100;
}

nav.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2) var(--space-1);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  gap: var(--space-1);
  transition: color 0.15s ease;
}

nav.bottom-nav a.active,
nav.bottom-nav a:hover {
  color: var(--color-primary);
}

nav.bottom-nav a svg {
  width: 1.4rem;
  height: 1.4rem;
}

/* ------------------------------------------------------------
   6. CARD
   ------------------------------------------------------------ */

.card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
}

.card-title {
  font-size: var(--text-lg);
  font-weight: 600;
  margin-bottom: var(--space-2);
  color: var(--color-text);
}

.card-body {
  font-size: var(--text-base);
  color: var(--color-text-muted);
}

/* ------------------------------------------------------------
   7. BUTTONS
   ------------------------------------------------------------ */

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-size: var(--text-base);
  font-family: inherit;
  font-weight: 500;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.15s ease, opacity 0.15s ease;
  background-color: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Primary variant */
.btn-primary {
  background-color: var(--color-primary);
  color: var(--color-surface);
  border-color: var(--color-primary);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
}

/* Danger variant */
.btn-danger {
  background-color: var(--color-danger);
  color: var(--color-surface);
  border-color: var(--color-danger);
}

.btn-danger:hover:not(:disabled) {
  opacity: 0.88;
}

/* Full-width helper */
.btn-block {
  width: 100%;
}

/* ------------------------------------------------------------
   8. FORM ELEMENTS
   ------------------------------------------------------------ */

label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: var(--space-1);
}

input,
textarea,
select {
  width: 100%;
  font-size: var(--text-base);
  font-family: inherit;
  color: var(--color-text);
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: var(--space-2) var(--space-3);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  appearance: none;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.15);
}

textarea {
  min-height: 6rem;
  resize: vertical;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236b7280' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  padding-right: var(--space-6);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.field-error {
  font-size: var(--text-sm);
  color: var(--color-danger);
}

/* ------------------------------------------------------------
   9. MODAL OVERLAY
   ------------------------------------------------------------ */

.modal {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 200;
  padding: var(--space-4);
}

.modal-panel {
  background-color: var(--color-surface);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  width: 100%;
  max-width: 40rem;
  padding: var(--space-5);
  box-shadow: var(--shadow-md);
  max-height: 90dvh;
  overflow-y: auto;
}

.modal-title {
  font-size: var(--text-lg);
  font-weight: 600;
  margin-bottom: var(--space-4);
  color: var(--color-text);
}

/* ------------------------------------------------------------
   10. UTILITIES
   ------------------------------------------------------------ */

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

.text-sm {
  font-size: var(--text-sm);
}

.text-lg {
  font-size: var(--text-lg);
}

.text-xl {
  font-size: var(--text-xl);
}

.font-semibold {
  font-weight: 600;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

/* Main content padded above bottom-nav */
#app {
  padding-bottom: calc(4rem + env(safe-area-inset-bottom, 0px));
}

/* Page wrapper for container + spacing */
.page {
  padding-top: var(--space-4);
  padding-bottom: var(--space-6);
}
