/* ==========================================================================
   IW Content Hub — stylesheet
   Mobile-first, BEM-influenced, CSS custom properties for brand colours
   ========================================================================== */

/* --------------------------------------------------------------------------
   Custom properties
   -------------------------------------------------------------------------- */
:root {
  /* Brand colours */
  --color-blue:       #264D7E;
  --color-navy:       #162d4a;
  --color-amber:      #FFB120;
  --color-coral:      #FF6B6B;
  --color-mint:       #7FDBB6;
  --color-offwhite:   #FAF5EC;

  /* Status colours */
  --status-in-review:   var(--color-amber);
  --status-approved:    var(--color-mint);
  --status-declined:    var(--color-coral);

  /* UI neutrals */
  --color-bg:         var(--color-offwhite);
  --color-surface:    #ffffff;
  --color-border:     #e2ddd5;
  --color-text:       #1a1a2e;
  --color-text-muted: #64748b;

  /* Typography */
  --font-ui:    Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  /* Spacing */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;

  /* Layout */
  --header-height: 64px;
  --max-width:     1280px;
  --grid-gap:      1.5rem;
  --card-radius:   12px;
  --overlay-z:     100;

  /* Transitions */
  --trans-fast: 150ms ease;
  --trans-std:  200ms ease;
}

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

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

body {
  font-family: var(--font-ui);
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

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

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

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

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

/* Screen-reader only utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --------------------------------------------------------------------------
   Focus styles — visible for all keyboard users
   -------------------------------------------------------------------------- */
:focus-visible {
  outline: 2px solid var(--color-amber);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-height);
  background-color: var(--color-navy);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-6);
  height: 100%;
  gap: var(--space-4);
}

.site-header__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-shrink: 0;
}

.logo-mark {
  flex-shrink: 0;
}

.site-header__title {
  font-size: 1.125rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

/* Week selector */
.week-selector {
  appearance: none;
  -webkit-appearance: none;
  background-color: rgba(255, 255, 255, 0.1);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23FFB120' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.625rem center;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  color: #ffffff;
  font-size: 0.875rem;
  font-weight: 500;
  padding: var(--space-2) var(--space-8) var(--space-2) var(--space-3);
  transition: border-color var(--trans-fast), background-color var(--trans-fast);
  min-width: 160px;
}

.week-selector:hover {
  background-color: rgba(255, 255, 255, 0.15);
  border-color: var(--color-amber);
}

.week-selector option {
  background-color: var(--color-navy);
  color: #ffffff;
}

/* --------------------------------------------------------------------------
   Main content area
   -------------------------------------------------------------------------- */
.main-content {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-8) var(--space-6) var(--space-12);
}

/* Week meta bar */
.week-meta {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  margin-bottom: var(--space-8);
  min-height: 2rem;
}

.week-meta__label {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-navy);
}

.week-meta__date {
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: var(--space-12);
  color: var(--color-text-muted);
}

/* --------------------------------------------------------------------------
   Post grid
   -------------------------------------------------------------------------- */
.post-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--grid-gap);
}

@media (min-width: 640px) {
  .post-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .post-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* --------------------------------------------------------------------------
   Post card
   -------------------------------------------------------------------------- */
.post-card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--card-radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--trans-std), box-shadow var(--trans-std);
  display: flex;
  flex-direction: column;
}

.post-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(22, 45, 74, 0.12);
}

.post-card:focus-visible {
  outline: 2px solid var(--color-amber);
  outline-offset: 2px;
}

/* Thumbnail */
.post-card__thumb {
  position: relative;
  width: 100%;
  padding-bottom: 100%; /* 1:1 ratio */
  overflow: hidden;
  background-color: #f0ece4;
}

.post-card__thumb-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 300ms ease;
}

.post-card:hover .post-card__thumb-img {
  transform: scale(1.03);
}

/* Slide count pill on thumbnail */
.post-card__slide-pill {
  position: absolute;
  bottom: var(--space-2);
  right: var(--space-2);
  background-color: rgba(22, 45, 74, 0.85);
  color: #ffffff;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 2px var(--space-2);
  border-radius: 20px;
  letter-spacing: 0.02em;
  backdrop-filter: blur(4px);
}

/* Card body */
.post-card__body {
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex: 1;
}

.post-card__title {
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--color-text);
}

.post-card__meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.day-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  font-weight: 500;
}

/* Platform badge */
.platform-badge {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 20px;
  background-color: var(--color-blue);
  color: #ffffff;
}

/* Status badge on card */
.post-card__status {
  margin-top: auto;
  padding-top: var(--space-2);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: capitalize;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: opacity var(--trans-fast);
}

.status-badge::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: currentColor;
  flex-shrink: 0;
}

.status-badge--in-review {
  background-color: rgba(255, 177, 32, 0.12);
  color: #c8870a;
  border-color: rgba(255, 177, 32, 0.3);
}

.status-badge--approved {
  background-color: rgba(127, 219, 182, 0.15);
  color: #1a7a54;
  border-color: rgba(127, 219, 182, 0.35);
}

.status-badge--declined {
  background-color: rgba(255, 107, 107, 0.1);
  color: #c0392b;
  border-color: rgba(255, 107, 107, 0.3);
}

.status-badge:hover {
  opacity: 0.8;
}

/* --------------------------------------------------------------------------
   Overlay
   -------------------------------------------------------------------------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: var(--overlay-z);
  display: flex;
  align-items: stretch;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--trans-std);
}

.overlay[hidden] {
  display: none;
}

.overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

.overlay__backdrop {
  position: absolute;
  inset: 0;
  background-color: rgba(22, 45, 74, 0.7);
  backdrop-filter: blur(3px);
}

/* The panel sits above the backdrop */
.overlay__panel {
  position: relative;
  z-index: 1;
  display: flex;
  width: 100%;
  max-width: var(--max-width);
  margin: auto;
  height: 100%;
  max-height: 100vh;
  overflow: hidden;
  background-color: var(--color-surface);
}

@media (min-width: 768px) {
  .overlay__panel {
    height: calc(100vh - 2rem);
    max-height: 860px;
    border-radius: var(--card-radius);
    margin: auto;
    width: calc(100% - 2rem);
    box-shadow: 0 24px 64px rgba(22, 45, 74, 0.35);
  }
}

/* --------------------------------------------------------------------------
   Slide viewer (left 60%)
   -------------------------------------------------------------------------- */
.slide-viewer {
  display: flex;
  flex-direction: column;
  background-color: #0f1c2d;
  flex: 0 0 60%;
  min-width: 0;
  overflow: hidden;
}

/* On mobile the layout stacks vertically */
@media (max-width: 767px) {
  .overlay__panel {
    flex-direction: column;
  }

  .slide-viewer {
    flex: 0 0 55vw;
  }

  .content-sidebar {
    flex: 1;
    overflow-y: auto;
  }
}

.slide-viewer__stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: var(--space-6);
}

.slide-viewer__img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  border-radius: 4px;
}

.slide-viewer__controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-6);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.slide-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: #ffffff;
  background-color: rgba(255, 255, 255, 0.1);
  transition: background-color var(--trans-fast);
  flex-shrink: 0;
}

.slide-btn:hover:not(:disabled) {
  background-color: var(--color-blue);
}

.slide-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.slide-counter {
  font-size: 0.8125rem;
  color: rgba(255, 255, 255, 0.6);
  font-weight: 500;
  min-width: 4rem;
  text-align: center;
}

/* --------------------------------------------------------------------------
   Content sidebar (right 40%)
   -------------------------------------------------------------------------- */
.content-sidebar {
  flex: 0 0 40%;
  min-width: 0;
  overflow-y: auto;
  padding: var(--space-6) var(--space-6) var(--space-8);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  position: relative;
  border-left: 1px solid var(--color-border);
}

/* Close button */
.overlay__close {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: var(--color-text-muted);
  background-color: transparent;
  transition: background-color var(--trans-fast), color var(--trans-fast);
  flex-shrink: 0;
}

.overlay__close:hover {
  background-color: #f1ede5;
  color: var(--color-text);
}

/* Sidebar header */
.content-sidebar__header {
  padding-right: var(--space-8); /* avoid close button overlap */
}

.content-sidebar__title {
  font-size: 1.0625rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--color-navy);
  margin-bottom: var(--space-2);
}

.content-sidebar__meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* Status section */
.content-sidebar__status {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.sidebar-label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
}

.status-select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  background-color: #f8f4ec;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.625rem center;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-text);
  font-size: 0.875rem;
  font-weight: 500;
  padding: var(--space-2) var(--space-8) var(--space-2) var(--space-3);
  transition: border-color var(--trans-fast);
}

.status-select:hover {
  border-color: var(--color-blue);
}

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

/* Sidebar sections */
.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* Caption box */
.caption-box {
  background-color: #f8f4ec;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: var(--space-3) var(--space-4);
  font-size: 0.875rem;
  line-height: 1.65;
  color: var(--color-text);
  white-space: pre-wrap;
  max-height: 200px;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.caption-box:focus {
  outline: 2px solid var(--color-amber);
  outline-offset: 2px;
}

/* Copy button */
.copy-btn {
  align-self: flex-start;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-blue);
  border: 1px solid var(--color-blue);
  border-radius: 6px;
  padding: 5px var(--space-4);
  transition: background-color var(--trans-fast), color var(--trans-fast);
}

.copy-btn:hover {
  background-color: var(--color-blue);
  color: #ffffff;
}

.copy-btn.is-copied {
  background-color: var(--color-mint);
  border-color: var(--color-mint);
  color: #065f46;
}

/* Hashtag pills */
.hashtag-pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.hashtag-pill {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-blue);
  background-color: rgba(38, 77, 126, 0.08);
  border: 1px solid rgba(38, 77, 126, 0.18);
  border-radius: 20px;
  padding: 2px 10px;
}

/* Sidebar footer */
.sidebar-footer {
  margin-top: auto;
  padding-top: var(--space-2);
}

.site-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-blue);
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: color var(--trans-fast);
}

.site-link:hover {
  color: var(--color-coral);
}

/* --------------------------------------------------------------------------
   Comments
   -------------------------------------------------------------------------- */
.comment-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-height: 0;
}

.comment-list:empty::after {
  content: 'No comments yet.';
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  font-style: italic;
}

.comment-item {
  background-color: #f8f4ec;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.comment-item__meta {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--color-text-muted);
  letter-spacing: 0.02em;
}

.comment-item__text {
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--color-text);
  white-space: pre-wrap;
  word-break: break-word;
}

.comment-compose {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.comment-textarea {
  font-family: var(--font-ui);
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--color-text);
  background-color: #f8f4ec;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: var(--space-3) var(--space-4);
  resize: vertical;
  min-height: 64px;
  transition: border-color var(--trans-fast);
  width: 100%;
}

.comment-textarea:hover {
  border-color: var(--color-blue);
}

.comment-textarea:focus {
  outline: 2px solid var(--color-amber);
  outline-offset: 2px;
  border-color: transparent;
}

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

.comment-submit-btn {
  align-self: flex-end;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #ffffff;
  background-color: var(--color-blue);
  border-radius: 6px;
  padding: 6px var(--space-5);
  transition: background-color var(--trans-fast);
}

.comment-submit-btn:hover {
  background-color: var(--color-navy);
}

.comment-submit-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* --------------------------------------------------------------------------
   Responsive tweaks: small mobile (375px)
   -------------------------------------------------------------------------- */
@media (max-width: 479px) {
  .main-content {
    padding: var(--space-6) var(--space-4) var(--space-10);
  }

  .site-header__inner {
    padding: 0 var(--space-4);
  }

  .site-header__title {
    font-size: 1rem;
  }

  .week-selector {
    min-width: 120px;
    font-size: 0.8125rem;
  }

  .slide-viewer__stage {
    padding: var(--space-3);
  }

  .content-sidebar {
    padding: var(--space-4);
  }
}
