/* ============================================
   NB News Digest – Shared Stylesheet
   WCAG 2.0 AA compliant
   ============================================ */

/* --- Google Fonts import --- */
@import url('https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400;0,600;1,400&family=Source+Sans+3:wght@400;500;600&display=swap');

/* --- Design Tokens --- */
:root {
  --color-bg:        #FAF8F5;
  --color-surface:   #FFFFFF;
  --color-border:    #D9D3C8;
  --color-text:      #1C1917;
  --color-text-muted:#5C5552;
  --color-accent:    #0D7C72;      /* teal – distinct from any NB gov colour */
  --color-accent-dk: #085E56;
  --color-accent-lt: #E6F4F2;
  --color-error:     #B91C1C;
  --color-error-lt:  #FEF2F2;
  --color-success:   #166534;
  --color-success-lt:#F0FDF4;

  --font-display: 'Lora', Georgia, serif;
  --font-body:    'Source Sans 3', Verdana, sans-serif;

  --radius:   8px;
  --radius-lg: 14px;
  --shadow:   0 1px 4px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --transition: 160ms ease;

  --max-w: 560px;
  --space-xs: 0.5rem;
  --space-sm: 0.875rem;
  --space-md: 1.25rem;
  --space-lg: 2rem;
  --space-xl: 3rem;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 18px;     /* larger base for readability across age groups */
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--color-text);
  background-color: var(--color-bg);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--space-lg) var(--space-md);
}

/* --- Skip Link (screen readers / keyboard nav) --- */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  background: var(--color-accent);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  font-weight: 600;
  text-decoration: none;
  z-index: 9999;
  transition: top var(--transition);
}
.skip-link:focus { top: 1rem; }

/* --- Card wrapper --- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: var(--max-w);
  padding: var(--space-xl) var(--space-lg);
}

/* --- Site header / wordmark --- */
.site-header {
  width: 100%;
  max-width: var(--max-w);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.site-header .wordmark {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text-muted);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  line-height: 1.2;
}

.site-header .wordmark span {
  display: block;
  font-size: 0.72rem;
  font-style: italic;
  font-weight: 400;
  color: var(--color-text-muted);
  text-transform: none;
  letter-spacing: 0;
}

/* Decorative rule accent */
.site-header::before {
  content: '';
  display: block;
  width: 3px;
  height: 2.4rem;
  background: var(--color-accent);
  border-radius: 2px;
  flex-shrink: 0;
}

/* --- Typography --- */
h1 {
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 5vw, 2rem);
  font-weight: 600;
  line-height: 1.25;
  color: var(--color-text);
  margin-bottom: var(--space-xs);
}

h1 .subtitle {
  display: block;
  font-size: clamp(0.95rem, 3vw, 1.05rem);
  font-family: var(--font-body);
  font-style: italic;
  font-weight: 400;
  color: var(--color-text-muted);
  margin-top: 0.2rem;
}

h2 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  margin: var(--space-lg) 0 var(--space-sm);
  color: var(--color-text);
}

p {
  color: var(--color-text-muted);
  margin-bottom: var(--space-sm);
  font-size: 1rem;
}

p:last-child { margin-bottom: 0; }

a {
  color: var(--color-accent);
  text-underline-offset: 3px;
}
a:hover  { color: var(--color-accent-dk); }
a:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 3px;
  border-radius: 2px;
}

/* --- Divider --- */
.divider {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: var(--space-md) 0;
}

/* --- Form elements --- */
.form-group {
  margin-bottom: var(--space-md);
}

label {
  display: block;
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.35rem;
  color: var(--color-text);
}

.label-sub {
  display: block;
  font-weight: 400;
  font-size: 0.85rem;
  font-style: italic;
  color: var(--color-text-muted);
}

input[type="email"] {
  display: block;
  width: 100%;
  padding: 0.7rem 0.9rem;
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--color-text);
  background: var(--color-bg);
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
  -webkit-appearance: none;
}
input[type="email"]:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(13, 124, 114, 0.18);
}
input[type="email"]::placeholder { color: #9E9895; }

/* Radio group */
.radio-group {
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
  margin-top: 0.4rem;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.radio-option input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 1.25rem;
  height: 1.25rem;
  border: 2px solid var(--color-border);
  border-radius: 50%;
  background: var(--color-bg);
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  transition: border-color var(--transition);
}
.radio-option input[type="radio"]:checked {
  border-color: var(--color-accent);
  background: var(--color-accent);
  box-shadow: inset 0 0 0 3px var(--color-surface);
}
.radio-option input[type="radio"]:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 3px;
}
.radio-option span {
  font-size: 1rem;
  font-weight: 500;
  color: var(--color-text);
  line-height: 1.3;
}

/* --- Button --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--color-accent);
  color: #ffffff;
  width: 100%;
}
.btn-primary:hover  { background: var(--color-accent-dk); }
.btn-primary:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 3px;
}

/* --- Turnstile wrapper --- */
#turnstile-container {
  margin-bottom: var(--space-sm);
  min-height: 65px; /* reserve space so layout doesn't jump */
}

/* --- Legal / small text --- */
.legal {
  font-size: 0.82rem;
  color: var(--color-text-muted);
  text-align: center;
  margin-top: var(--space-sm);
  line-height: 1.5;
}
.legal a { font-size: inherit; }

/* --- Status / Confirmation pages --- */
.status-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 4rem;
  height: 4rem;
  border-radius: 50%;
  margin: 0 auto var(--space-md);
}
.status-icon--success { background: var(--color-success-lt); }
.status-icon--goodbye { background: var(--color-error-lt); }
.status-icon--info    { background: var(--color-accent-lt); }

.status-icon svg {
  width: 2rem;
  height: 2rem;
}

.status-block { text-align: center; }

.status-block h1 {
  margin-bottom: var(--space-sm);
}

.bilingual-pair {
  margin-bottom: var(--space-xs);
}
.bilingual-pair .primary   { color: var(--color-text-muted); }
.bilingual-pair .secondary {
  font-style: italic;
  font-size: 0.92rem;
  color: #8A8380;
}

/* --- Footer --- */
.site-footer {
  width: 100%;
  max-width: var(--max-w);
  margin-top: var(--space-lg);
  text-align: center;
  font-size: 0.8rem;
  color: #9E9895;
  line-height: 1.5;
}

/* --- TOS page --- */
.tos-card { max-width: 680px; }
.tos-card h1 { margin-bottom: var(--space-lg); }
.tos-card h2 { margin-top: var(--space-lg); }
.tos-card p  { color: var(--color-text); margin-bottom: var(--space-sm); }
.tos-card .meta {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--color-border);
}
.tos-card em { font-style: italic; }
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-accent);
  text-decoration: none;
  margin-bottom: var(--space-lg);
}
.back-link:hover { color: var(--color-accent-dk); }
.back-link:focus-visible {
  outline: 3px solid var(--color-accent);
  outline-offset: 3px;
  border-radius: 2px;
}

/* --- Responsive --- */
@media (max-width: 480px) {
  html { font-size: 16px; }
  .card { padding: var(--space-lg) var(--space-md); }
  .radio-group { gap: var(--space-sm); }
}

/* --- High-contrast / forced-colors support --- */
@media (forced-colors: active) {
  .btn-primary { forced-color-adjust: none; }
  input[type="email"], input[type="radio"] { forced-color-adjust: auto; }
}

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; }
}

/* ============================================
   Index page — above-fold compact layout
   ============================================ */

body {
  justify-content: center;
  min-height: 100dvh;
  padding: 1rem;
}

.card {
  padding: 2rem 2rem 1.5rem;
  position: relative;
}

/* Language toggle pill */
.lang-toggle {
  position: absolute;
  top: 1.1rem;
  right: 1.1rem;
  display: flex;
  gap: 2px;
  background: var(--color-bg);
  border: 1.5px solid var(--color-border);
  border-radius: 6px;
  padding: 2px;
}

.lang-btn {
  padding: 0.25rem 0.55rem;
  font-family: var(--font-body);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  background: transparent;
  color: var(--color-text-muted);
  transition: background var(--transition), color var(--transition);
  line-height: 1;
}

.lang-btn[aria-pressed="true"] {
  background: var(--color-accent);
  color: #fff;
}

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

/* Language content switching */
.lang-content        { display: none; }
.lang-content.active { display: block; }

/* Compact heading — pad right to clear toggle */
h1 {
  font-size: clamp(1.35rem, 4.5vw, 1.7rem);
  margin-bottom: 0.3rem;
  padding-right: 4.5rem;
}

.tagline {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-bottom: 1rem;
  font-style: italic;
}

/* Tighter form spacing for above-fold goal */
.form-group { margin-bottom: 0.85rem; }
input[type="email"] { padding: 0.6rem 0.85rem; }
.radio-group { margin-top: 0.3rem; }
#turnstile-container,
#turnstile-container-fr { min-height: 0; margin-bottom: 0.5rem; }
.btn-primary  { padding: 0.65rem 1.25rem; }
.legal        { margin-top: 0.6rem; font-size: 0.78rem; }
.site-footer  { margin-top: 0.85rem; font-size: 0.75rem; }

/* ============================================
   Bilingual block (check-email & status pages)
   ============================================ */

.bilingual-block {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  text-align: left;
  margin: 0 auto;
}

.bilingual-block .lang-row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.bilingual-block .lang-tag {
  flex-shrink: 0;
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--color-accent);
  background: var(--color-accent-lt);
  border-radius: 4px;
  padding: 0.15rem 0.4rem;
  margin-top: 0.2rem;
  line-height: 1.4;
}

.bilingual-block p {
  margin: 0;
  font-size: 1rem;
  color: var(--color-text);
  line-height: 1.55;
}

.bilingual-block .note {
  font-size: 0.88rem;
  color: var(--color-text-muted);
}

.divider-lang {
  border: none;
  border-top: 1px dashed var(--color-border);
  margin: 0.25rem 0;
}

/* Stacked bilingual headings */
.h1-fr {
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 3.5vw, 1.5rem);
  font-weight: 400;
  font-style: italic;
  color: var(--color-text-muted);
  line-height: 1.25;
  margin-top: 0.15rem;
  margin-bottom: 0;
}

/* Inline button overrides for status pages */
.btn-inline {
  display: inline-flex;
  width: auto;
  padding: 0.7rem 1.5rem;
  margin-top: 1.25rem;
}

/* ── Header layout when toggle sits inside the header ── */
.site-header {
  justify-content: space-between;
  align-items: center;
}

.site-header .lang-toggle {
  position: static; /* override index.html card-relative positioning */
  flex-shrink: 0;
}