/* ─────────────────────────────────────────────────────────────────────
   Ken je Kamerlid — styles.css
   Mobile-first. State-driven via body[data-state] attribute.
   States: loading | cover | reveal | fact | error
   ───────────────────────────────────────────────────────────────────── */

/* ── Custom properties ──────────────────────────────────────────────── */
:root {
  --bg:           #F5F3EF;
  --surface:      #FFFFFF;
  --ink:          #1a1a1a;
  --ink-muted:    #6b6b6b;
  --red:          #E8391D;
  --party-color:  #333333; /* overridden per member via JS */

  --serif:  'Playfair Display', Georgia, serif;
  --sans:   'DM Sans', system-ui, sans-serif;

  --radius:       16px;
  --radius-sm:    10px;
  --shadow-card:  0 2px 16px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.05);
  --shadow-fact:  0 -4px 40px rgba(0,0,0,0.12), 0 -1px 6px rgba(0,0,0,0.06);

  --ease-reveal:  cubic-bezier(0.32, 0.72, 0, 1);
  --dur-photo:    0.75s;
  --dur-slide:    0.45s;
  --dur-strip:    0.35s;
  --dur-identity: 0.3s;
}

/* ── Reset ──────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
button { font: inherit; cursor: pointer; border: none; background: none; }
blockquote { font-style: normal; }

/* ── Base ────────────────────────────────────────────────────────────── */
html { height: 100%; }

body {
  background-color: var(--bg);
  font-family: var(--sans);
  color: var(--ink);
  height: 100dvh;
  overflow: hidden;
  display: flex;
  justify-content: center;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── App shell ──────────────────────────────────────────────────────── */
#app {
  width: 100%;
  max-width: 480px;
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* ── Header ─────────────────────────────────────────────────────────── */
#site-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px 10px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.07);
  background: var(--bg);
  /* Ensure header sits above the sliding fact card */
  position: relative;
  z-index: 20;
}

.title-kicker {
  display: block;
  font-size: 0.55rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-family: var(--sans);
  margin-bottom: 1px;
}

#site-header h1 {
  font-family: var(--serif);
  font-size: clamp(1.3rem, 7vw, 1.8rem);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--ink);
}

#streak {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  font-family: var(--sans);
  letter-spacing: 0.01em;
}

/* Hide streak until data loads */
body[data-state="loading"] #streak { visibility: hidden; }

/* ── Main ────────────────────────────────────────────────────────────── */
#main {
  flex: 1;
  position: relative;
  overflow: hidden;
  padding: 12px 16px 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ── Status message (loading / error) ───────────────────────────────── */
#status-msg {
  padding: 24px 16px;
  text-align: center;
  font-size: 0.88rem;
  color: var(--ink-muted);
  line-height: 1.5;
}
#status-msg:empty { display: none; }

/* ── Photo card ──────────────────────────────────────────────────────── */
#card {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  background: var(--surface);
  min-height: 0;
}

/* Hide card in loading/error states */
body[data-state="loading"] #card,
body[data-state="error"]   #card { display: none; }

/* ── Party colour strip (top of card) ──────────────────────────────── */
#party-strip {
  flex-shrink: 0;
  height: 7px;
  background-color: var(--party-color);
  transform-origin: top;
  transition: transform var(--dur-strip) var(--ease-reveal),
              opacity   var(--dur-strip) ease;
}

/* Hidden in cover state */
body[data-state="cover"] #party-strip {
  transform: scaleY(0);
  opacity: 0;
}

/* ── Identity (name + party) ─────────────────────────────────────────── */
#identity {
  flex-shrink: 0;
  padding: 12px 16px 10px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  transition: opacity var(--dur-identity) ease,
              transform var(--dur-identity) ease;
}

body[data-state="cover"] #identity {
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
}

/* Identity row: logo + text side by side */
#identity-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

#party-logo {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  padding: 4px;
}

/* Hide broken/missing logo without layout shift */
#party-logo:not([src]),
#party-logo[src=""] {
  display: none;
}

#identity-text {
  flex: 1;
  min-width: 0;
}

#mp-name {
  font-family: var(--serif);
  font-size: clamp(1.1rem, 5vw, 1.5rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#mp-party-label {
  margin-top: 2px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--party-color);
  font-family: var(--sans);
}

/* Age + woonplaats under the identity row */
#mp-meta {
  margin-top: 6px;
  font-size: 0.72rem;
  color: var(--ink-muted);
  font-family: var(--sans);
}
#mp-meta:empty { display: none; }

/* ── Photo ───────────────────────────────────────────────────────────── */
#photo-wrap {
  flex: 1;
  overflow: hidden;
  min-height: 0;
  background: #ddd9d2;
}

#photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
  transition: filter var(--dur-photo) ease;
  /* prevent selection / long-press save on mobile */
  -webkit-user-select: none;
  user-select: none;
  pointer-events: none;
}

/* Obscured in cover state */
body[data-state="cover"] #photo {
  filter: blur(14px) grayscale(1) brightness(0.6);
}

body[data-state="reveal"] #photo,
body[data-state="fact"]   #photo {
  filter: none;
}

/* ── Fact card (slides up from bottom) ──────────────────────────────── */
#fact-card {
  position: absolute;
  left: 16px;   /* align with #card horizontal edges (matches #main padding) */
  right: 16px;
  bottom: 0;
  background: var(--surface);
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: var(--shadow-fact);
  padding: 20px 20px 18px;
  z-index: 10;
  transform: translateY(100%);
  transition: transform var(--dur-slide) var(--ease-reveal);
}

body[data-state="reveal"] #fact-card,
body[data-state="fact"]   #fact-card {
  transform: translateY(0);
}

/* "Raar Feitje" eyebrow label */
#fact-eyebrow {
  display: block;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--party-color);
  font-family: var(--sans);
  margin-bottom: 10px;
}

/* Pull-quote fact text */
#fact-text {
  font-family: var(--serif);
  font-size: clamp(1.05rem, 4.2vw, 1.3rem);
  font-style: italic;
  line-height: 1.5;
  color: var(--ink);
  margin-bottom: 16px;
  padding-left: 22px;
  position: relative;
}

/* Opening quotation mark accent */
#fact-text::before {
  content: '\201C'; /* left double quotation mark */
  position: absolute;
  left: -2px;
  top: -6px;
  font-size: 2.8rem;
  line-height: 1;
  font-style: normal;
  color: var(--party-color);
  font-family: var(--serif);
  opacity: 0.5;
}

/* ── Share buttons (inside fact card) ──────────────────────────────── */
#share-buttons {
  display: flex;
  gap: 10px;
}

.share-btn {
  flex: 1;
  min-height: 48px;
  font-family: var(--sans);
  font-size: 0.8rem;
  font-weight: 700;
  border: 1.5px solid rgba(0, 0, 0, 0.18);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  padding: 0 12px;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  letter-spacing: 0.01em;
}

.share-btn:hover {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

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

.share-btn:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: 2px;
}

/* Copied state for copy button */
#copy-btn.is-copied {
  background: #1a7a3a;
  border-color: #1a7a3a;
  color: #fff;
}

/* ── Action bar ──────────────────────────────────────────────────────── */
#action-bar {
  flex-shrink: 0;
  padding: 10px 16px max(16px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg);
  /* Ensure action bar sits above content */
  position: relative;
  z-index: 20;
}

/* Hide action bar during loading */
body[data-state="loading"] #action-bar,
body[data-state="error"]   #action-bar { display: none; }

/* ── Hint text ──────────────────────────────────────────────────────── */
#hint {
  text-align: center;
  font-size: 0.75rem;
  color: var(--ink-muted);
  font-family: var(--sans);
  line-height: 1.4;
  padding: 0 8px;
}

/* Hide hint after first interaction or in non-cover states */
body[data-hint-dismissed] #hint,
body[data-state="reveal"]  #hint,
body[data-state="fact"]    #hint { display: none; }

/* ── Reveal button (cover state CTA) ────────────────────────────────── */
#reveal-btn {
  width: 100%;
  min-height: 56px;
  background: var(--red);
  color: #fff;
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 700;
  border-radius: 12px;
  letter-spacing: 0.015em;
  transition: background 0.15s ease, transform 0.1s ease;
}

#reveal-btn:hover  { background: #c8311a; }
#reveal-btn:active { transform: scale(0.98); }
#reveal-btn:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
}

/* ── Next button (fact state, secondary) ────────────────────────────── */
#next-btn {
  width: 100%;
  min-height: 48px;
  background: transparent;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 0.9rem;
  font-weight: 500;
  border: 1.5px solid rgba(0, 0, 0, 0.18);
  border-radius: 12px;
  letter-spacing: 0.01em;
  transition: background 0.15s ease;
}

#next-btn:hover { background: rgba(0, 0, 0, 0.04); }
#next-btn:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: 2px;
}

/* ── State-based button visibility ──────────────────────────────────── */

/* COVER — show reveal, hide next */
body[data-state="cover"]  #reveal-btn { display: block; }
body[data-state="cover"]  #next-btn   { display: none;  }

/* REVEAL — hide both (animation window) */
body[data-state="reveal"] #reveal-btn { display: none; }
body[data-state="reveal"] #next-btn   { display: none; }

/* FACT — hide reveal, show next */
body[data-state="fact"]   #reveal-btn { display: none;  }
body[data-state="fact"]   #next-btn   { display: block; }

/* ── Error state ─────────────────────────────────────────────────────── */
body[data-state="error"] #status-msg {
  color: var(--red);
  font-weight: 500;
}

/* ── Shuffling state (randomiser animation between MPs) ─────────────── */

/* Instant reset: snap fact-card away, hide identity, keep photo blurred */
body[data-state="shuffling"] #photo {
  filter: blur(14px) grayscale(1) brightness(0.6);
  transition: none; /* changes must be instant during cycling */
  animation: shuffle-flicker 0.13s steps(1) infinite;
}

body[data-state="shuffling"] #party-strip {
  transform: scaleY(0);
  opacity: 0;
  transition: none;
}

body[data-state="shuffling"] #identity {
  opacity: 0;
  pointer-events: none;
  transition: none;
}

body[data-state="shuffling"] #fact-card {
  transform: translateY(100%);
  transition: none; /* snap away instantly */
}

body[data-state="shuffling"] #action-bar {
  visibility: hidden; /* maintain layout space, hide visually */
}

@keyframes shuffle-flicker {
  0%   { opacity: 1;   filter: blur(14px) grayscale(1) brightness(0.60); }
  45%  { opacity: 0.7; filter: blur(18px) grayscale(1) brightness(0.45); }
  55%  { opacity: 0.7; filter: blur(18px) grayscale(1) brightness(0.45); }
  100% { opacity: 1;   filter: blur(14px) grayscale(1) brightness(0.60); }
}

/* ── Reduced motion ──────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  #photo,
  #fact-card,
  #party-strip,
  #identity,
  .share-btn,
  #reveal-btn,
  #next-btn {
    transition: none !important;
  }

  body[data-state="cover"] #photo,
  body[data-state="shuffling"] #photo {
    /* Keep visual obscuring, just no animation */
    filter: blur(14px) grayscale(1) brightness(0.6);
    animation: none !important;
  }
}

/* ── Very small screens ──────────────────────────────────────────────── */
@media (max-width: 360px) {
  #site-header { padding: 10px 14px 8px; }
  #main        { padding: 10px 12px 0;   }
  #fact-card   { left: 12px; right: 12px; padding: 16px 16px 14px; }
  #action-bar  { padding: 8px 12px 14px; }
}

/* ── Desktop centering ───────────────────────────────────────────────── */
@media (min-width: 480px) {
  body { align-items: flex-start; }

  #app {
    /* Subtle border on desktop so card doesn't float in wide viewport */
    border-left:  1px solid rgba(0,0,0,0.06);
    border-right: 1px solid rgba(0,0,0,0.06);
  }
}
