/* ==========================================================================
   4-7-8 Breathing App — Styles
   Brand colors sourced from www.dogtraining-campus.com
   Adjust the variables below to retune the palette everywhere at once.
   ========================================================================== */

:root {
  /* --- Brand colors (from dogtraining-campus.com) --- */
  --color-red-primary:   #C51617;  /* brand accent red */
  --color-red-secondary: #AC2228;  /* brand secondary/darker red */
  --color-red-soft:      #ff8b8c;  /* light coral, used sparingly for glow/highlight */

  --color-ink:        #3a3a3a;     /* medium-dark grey (replaces pure black) */
  --color-ink-soft:   #575756;     /* secondary grey, for muted text */
  --color-grey-light: #d4cdbe;     /* light grey / warm stone, for borders & subtle fills */
  --color-grey-lighter:#e3ddd1;    /* even lighter, for hairline rules */

  --color-bg-soft:    #F7F2E6;     /* warm cream background, strong readability */
  --color-surface:    #ffffff;     /* card/button surface on top of soft bg */

  /* --- Semantic aliases (change these if the brand palette shifts) --- */
  --color-bg:            var(--color-bg-soft);
  --color-text:           var(--color-ink);
  --color-text-muted:     var(--color-ink-soft);
  --color-accent:         var(--color-red-primary);
  --color-accent-hover:   var(--color-red-secondary);
  --color-border:         var(--color-grey-lighter);

  --radius-lg: 28px;
  --radius-md: 16px;
  --radius-sm: 10px;
}

/* ---------- Reset & base ---------- */
* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--color-grey-lighter);
  color: var(--color-text);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

button {
  font-family: inherit;
  cursor: pointer;
}

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

/* ---------- App shell ----------
   Mobile: full-bleed, edge to edge.
   Desktop: centered "phone-like" app window/card.
   ------------------------------------------------------------------ */
.app-shell {
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--color-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

@media (min-width: 640px) {
  body {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
  }

  .app-shell {
    width: 420px;
    max-width: 100%;
    height: 860px;
    max-height: 92vh;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(58, 58, 58, 0.25), 0 2px 8px rgba(58, 58, 58, 0.15);
  }
}

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 6px;
  flex-shrink: 0;
  gap: 10px;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.logo-link {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.topbar-logo {
  /* Logo is a wide wordmark (not square) — size by height so it stays
     legible instead of being squeezed into a tiny square box. */
  height: 34px;
  width: auto;
  flex-shrink: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.brand-icon {
  color: var(--color-accent);
  flex-shrink: 0;
  margin-left: 4px;
}

.brand {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(58, 58, 58, 0.15);
  flex-shrink: 0;
}

.lang-btn {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.icon-btn:active {
  transform: scale(0.94);
}

/* ---------- Screens ---------- */
.screens {
  flex: 1;
  position: relative;
  min-height: 0;
}

.screen {
  position: absolute;
  inset: 0;
  display: none;
  overflow-y: auto;
}

.screen.active {
  display: block;
}

.screen-inner {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 28px 32px;
  text-align: center;
}

.brand-logo {
  width: 210px;
  max-width: 70%;
  height: auto;
  margin-bottom: 18px;
}

.title {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--color-text);
}

.subtitle {
  font-size: 0.95rem;
  color: var(--color-text-muted);
  line-height: 1.5;
  margin: 0 0 18px;
}

.mission-text {
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--color-text);
  background: var(--color-surface);
  border-left: 3px solid var(--color-accent);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin: 0 0 26px;
  text-align: left;
  width: 100%;
  max-width: 340px;
}

/* ---------- Start screen: technique picker ---------- */
.technique-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  max-width: 340px;
  margin-bottom: 22px;
}

.technique-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  border-radius: var(--radius-sm);
  padding: 14px 10px;
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.technique-btn:active {
  transform: scale(0.97);
}

.technique-btn.selected {
  border-color: var(--color-accent);
  background: var(--color-accent);
  color: #fff;
}

.technique-name {
  font-size: 1.1rem;
  font-weight: 700;
}

.technique-desc {
  font-size: 0.78rem;
  line-height: 1.35;
  opacity: 0.85;
}

/* ---------- Start screen: cycle picker ---------- */
.cycle-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  width: 100%;
  max-width: 340px;
  margin-bottom: 14px;
}

.option-btn {
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  border-radius: var(--radius-sm);
  padding: 14px 0;
  font-size: 1.05rem;
  font-weight: 600;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.option-btn.wide {
  width: 100%;
  max-width: 340px;
  padding: 14px 12px;
  margin-bottom: 28px;
}

.option-btn.selected {
  border-color: var(--color-accent);
  background: var(--color-accent);
  color: #fff;
}

.option-btn:active {
  transform: scale(0.97);
}

/* ---------- Primary / secondary buttons ---------- */
.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 340px;
  padding: 16px 20px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--color-accent);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(197, 22, 23, 0.28);
  transition: background 0.15s ease, transform 0.1s ease, opacity 0.15s ease;
}

.primary-btn:hover { background: var(--color-accent-hover); }
.primary-btn:active { transform: scale(0.98); }

.primary-btn:disabled {
  background: var(--color-grey-light);
  color: var(--color-surface);
  box-shadow: none;
  cursor: not-allowed;
}

.secondary-btn {
  margin-top: 14px;
  background: transparent;
  border: none;
  color: var(--color-text-muted);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 10px 16px;
  text-decoration: underline;
}

/* ---------- Session screen ---------- */
.session-inner {
  justify-content: space-between;
  padding-top: 18px;
}

.progress-label {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--color-text-muted);
  margin: 0;
}

.breath-stage {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 26px;
}

.breath-circle {
  --scale: 0.55;
  width: min(62vw, 260px);
  height: min(62vw, 260px);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 42%, #ffffff 0%, var(--color-bg-soft) 55%, var(--color-grey-lighter) 100%);
  border: 3px solid var(--color-accent);
  box-shadow: 0 0 0 10px rgba(197, 22, 23, 0.06), 0 10px 40px rgba(58, 58, 58, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  transform: scale(var(--scale));
  transition: transform 4s linear;
}

.phase-number {
  font-size: clamp(4rem, 22vw, 6.5rem);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.phase-label {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-accent-hover);
  margin: 0;
  letter-spacing: 0.02em;
}

.session-tagline {
  font-size: 0.85rem;
  font-style: italic;
  color: var(--color-text-muted);
  margin: 10px 0 0;
  max-width: 260px;
}

/* Soft full-area flash on every phase change — a visual echo of the chime,
   useful when the device is on silent (e.g. iPhone mute switch, which
   blocks web audio entirely and can't be worked around from a webpage). */
.session-flash {
  position: absolute;
  inset: 0;
  background: var(--color-accent);
  opacity: 0;
  pointer-events: none;
  z-index: 5;
}

.session-flash.flash {
  animation: gentle-flash 0.7s ease-out;
}

@keyframes gentle-flash {
  0%   { opacity: 0; }
  12%  { opacity: 0.16; }
  100% { opacity: 0; }
}

/* ---------- Controls ---------- */
.controls {
  display: flex;
  gap: 12px;
  width: 100%;
  padding-top: 18px;
}

.control-btn {
  flex: 1;
  padding: 16px 8px;
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 700;
}

.control-btn:active {
  transform: scale(0.96);
}

.control-btn-danger {
  border-color: var(--color-red-secondary);
  color: var(--color-red-secondary);
}

/* ---------- Info screen ---------- */
.info-text {
  font-size: 0.98rem;
  line-height: 1.6;
  color: var(--color-text);
  max-width: 340px;
  margin: 0 0 18px;
}

.link-btn {
  display: block;
  margin-top: 6px;
}

/* ---------- Small screens: tighten spacing ---------- */
@media (max-height: 700px) {
  .breath-circle { width: min(52vw, 210px); height: min(52vw, 210px); }
  .phase-number { font-size: clamp(3.2rem, 18vw, 5rem); }
  .subtitle { margin-bottom: 18px; }
}
