/* Calgary Life Church brand colours (Brand Style Guide, p. 12). */
:root {
  --beige: #fffbf0;
  --red: #d62118;
  --wine: #5c1220;
  --leaf: #78a360;
  --pine: #283b2d;
  --sky: #6387ab;
  --navy: #192138;
  --display: 'Rival Sans Narrow', 'Field Gothic Compact', 'Avenir Next Condensed', 'Roboto Condensed', 'Arial Narrow',
    system-ui, sans-serif;

  --bg: var(--beige);
  --text: var(--navy);
  --muted: #5e6375;
  --accent: var(--red);
  --logo: var(--red);
  --bar-bg: rgba(255, 251, 240, 0.94);
  --border: #e6dcc6;
  --button-bg: #f6efdd;
  --live: var(--leaf);
  --paused: var(--sky);
  --waiting: #9a9a9a;
  --problem: var(--red);
  --caption-size: 26px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: var(--navy);
    --text: var(--beige);
    --muted: #a9b4c8;
    --accent: #8fb0d3;
    --logo: var(--sky);
    --bar-bg: rgba(25, 33, 56, 0.94);
    --border: #2e3a5c;
    --button-bg: #222c4a;
    --live: var(--leaf);
    --paused: #8fb0d3;
    --waiting: #8a93a6;
    --problem: #ff7a70;
    color-scheme: dark;
  }
}

:root[data-theme='dark'] {
  --bg: var(--navy);
  --text: var(--beige);
  --muted: #a9b4c8;
  --accent: #8fb0d3;
  --logo: var(--sky);
  --bar-bg: rgba(25, 33, 56, 0.94);
  --border: #2e3a5c;
  --button-bg: #222c4a;
  --live: var(--leaf);
  --paused: #8fb0d3;
  --waiting: #8a93a6;
  --problem: #ff7a70;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  overflow-wrap: break-word;
}

button,
select {
  font: inherit;
  color: inherit;
}

[hidden] {
  display: none !important;
}

/* ---- Language picker (first visit) ---- */

.picker {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px 16px;
  text-align: center;
}

.picker h1 {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-stretch: condensed;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  font-size: 2.2rem;
  line-height: 1;
}

/* The logo is the official artwork used as a mask, so it can take any palette colour. */
.logo {
  display: block;
  background-color: var(--logo);
  -webkit-mask: var(--logo-src) center / contain no-repeat;
  mask: var(--logo-src) center / contain no-repeat;
}

.logo-stacked {
  --logo-src: url('/brand/logo-stacked.png');
  width: 150px;
  aspect-ratio: 640 / 473;
  margin-bottom: 8px;
}

.logo-icon {
  --logo-src: url('/brand/icon-mask.png');
  flex: none;
  width: 30px;
  aspect-ratio: 256 / 221;
}

.picker-hint {
  margin: 0;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.picker-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(100%, 360px);
}

.picker-buttons button {
  padding: 16px 16px;
  font-size: 1.4rem;
  font-weight: 600;
  border: 2px solid var(--border);
  border-radius: 999px;
  background: var(--button-bg);
  cursor: pointer;
}

.picker-buttons button:hover,
.picker-buttons button:focus-visible {
  border-color: var(--accent);
}

/* ---- Top bar ---- */

.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  padding-top: max(8px, env(safe-area-inset-top));
  background: var(--bar-bg);
  border-bottom: 1px solid var(--border);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.lang-select {
  min-height: 44px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--button-bg);
  font-weight: 600;
  max-width: 40vw;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
  font-size: 0.9rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 480px) {
  .bar {
    flex-wrap: wrap;
    row-gap: 4px;
  }
  .lang-select {
    flex: 1;
    max-width: none;
  }
  .status {
    order: 3;
    flex-basis: 100%;
    font-size: 0.85rem;
  }
}

.status #status-text {
  overflow: hidden;
  text-overflow: ellipsis;
}

.dot {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--waiting);
}

.status[data-kind='live'] .dot {
  background: var(--live);
}
.status[data-kind='paused'] .dot {
  background: var(--paused);
}
.status[data-kind='problem'] .dot {
  background: var(--problem);
  animation: pulse 1.2s ease-in-out infinite;
}
.status[data-kind='problem'] {
  color: var(--problem);
}

@keyframes pulse {
  50% {
    opacity: 0.3;
  }
}

.controls {
  display: inline-flex;
  gap: 6px;
  flex: none;
}

.icon-btn {
  min-width: 44px;
  min-height: 44px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--button-bg);
  font-weight: 700;
  cursor: pointer;
}

.icon-btn:focus-visible,
.lang-select:focus-visible,
.jump:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ---- Captions ---- */

.captions {
  padding: 16px max(16px, env(safe-area-inset-right)) calc(40vh + env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  font-size: var(--caption-size);
  line-height: 1.4;
  max-width: 48em;
  margin: 0 auto;
}

.empty {
  margin: 20vh 0 0;
  text-align: center;
  color: var(--muted);
  font-size: max(18px, 0.8em);
}

.line {
  margin: 0 0 0.55em;
}

.line .text {
  margin: 0;
  transition: color 0.3s ease;
}

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


/* ---- Jump to live ---- */

.jump {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 20;
  padding: 12px 20px;
  min-height: 44px;
  border: none;
  border-radius: 999px;
  background: var(--red);
  color: var(--beige);
  font-weight: 700;
  font-size: 1rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

/* Korean wraps between words, not in the middle of them. */
:lang(ko) .captions,
.captions:lang(ko) {
  word-break: keep-all;
}
