/* =========================================================================
   Studio archive — warm paper, ink type, terracotta accents.
   One palette across the showcase, the player chrome and the admin desk.
   ========================================================================= */

:root {
  --paper: #f4efe4;
  --paper-2: #ebe4d6;
  --paper-3: #e0d7c5;
  --ink: #1d1713;
  --ink-soft: #4a4038;
  --ink-faint: #8a7d70;
  --terracotta: #b4541f;
  --terracotta-dim: #8f4318;
  --pine: #2f4f4a;
  --gold: #c08a2e;
  --rule: rgba(29, 23, 19, 0.14);
  --shadow-sm: 0 1px 2px rgba(29, 23, 19, 0.08);
  --shadow-lg: 0 24px 60px -32px rgba(29, 23, 19, 0.45);
  --display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --body: "Archivo", "Helvetica Neue", Helvetica, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background-color: var(--paper);
  /* Layered warmth: a soft top-left glow, a faint grid, and paper grain. */
  background-image:
    radial-gradient(120% 90% at 8% -10%, rgba(192, 138, 46, 0.18), transparent 60%),
    radial-gradient(80% 60% at 100% 0%, rgba(47, 79, 74, 0.1), transparent 55%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.6;
  font-synthesis-weight: none;
}

body::after {
  /* Fixed, non-interactive grain overlay. */
  content: "";
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  opacity: 0.32;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

a {
  color: var(--terracotta-dim);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

h1,
h2,
h3 {
  font-family: var(--display);
  font-weight: 600;
  font-variation-settings: "SOFT" 0, "WONK" 1;
  letter-spacing: -0.02em;
  line-height: 1.02;
  margin: 0;
}

.mono {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.shell {
  width: min(1180px, 100% - 3rem);
  margin-inline: auto;
}

/* ---------- Site header ---------- */

.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.6rem 0 1.1rem;
  border-bottom: 1px solid var(--rule);
}

.wordmark {
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.wordmark::before {
  content: "";
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--gold), var(--terracotta) 70%);
  box-shadow: inset 0 0 0 1px rgba(29, 23, 19, 0.25);
}

.topbar nav {
  display: flex;
  gap: 1.4rem;
  align-items: baseline;
}

.topbar nav a {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
  text-decoration: none;
  padding-bottom: 2px;
  border-bottom: 1px solid transparent;
  transition: border-color 0.25s var(--ease), color 0.25s var(--ease);
}

.topbar nav a:hover {
  color: var(--ink);
  border-color: var(--terracotta);
}

/* ---------- Editorial hero ---------- */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.85fr);
  gap: clamp(1.5rem, 5vw, 4.5rem);
  align-items: end;
  padding: clamp(3rem, 8vw, 6.5rem) 0 clamp(2rem, 4vw, 3.2rem);
}

.hero h1 {
  font-size: clamp(2.7rem, 8.5vw, 6.1rem);
  max-width: 22ch;
}

.hero h1 em {
  font-style: italic;
  font-variation-settings: "SOFT" 40, "WONK" 1;
  color: var(--terracotta);
}

.hero-aside {
  padding-bottom: 0.6rem;
  border-left: 1px solid var(--rule);
  padding-left: clamp(1rem, 2vw, 1.8rem);
}

.hero-aside p {
  margin: 0.7rem 0 0;
  color: var(--ink-soft);
  max-width: 38ch;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1.4rem;
}

.eyebrow::after {
  content: "";
  width: clamp(2rem, 8vw, 5rem);
  height: 1px;
  background: var(--rule);
}

/* ---------- Course index ---------- */

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.9rem;
  border-bottom: 2px solid var(--ink);
}

.course-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.course-row {
  position: relative;
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1fr) auto;
  gap: clamp(0.75rem, 2vw, 2rem);
  align-items: center;
  padding: clamp(1.4rem, 3vw, 2.1rem) 0;
  border-bottom: 1px solid var(--rule);
  animation: rise 0.6s var(--ease) both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
}

.course-row::before {
  /* Terracotta wash that sweeps in behind the row on hover. */
  content: "";
  position: absolute;
  inset: 0 -1.25rem;
  background: linear-gradient(90deg, rgba(180, 84, 31, 0.1), rgba(180, 84, 31, 0));
  opacity: 0;
  transform: scaleX(0.96);
  transform-origin: left;
  transition: opacity 0.35s var(--ease), transform 0.35s var(--ease);
  pointer-events: none;
}

.course-row:hover::before {
  opacity: 1;
  transform: scaleX(1);
}

.course-index {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--ink-faint);
  align-self: start;
  padding-top: 0.45rem;
}

.course-title {
  font-family: var(--display);
  font-size: clamp(1.4rem, 3.2vw, 2.1rem);
  margin: 0 0 0.35rem;
}

.course-title a {
  color: inherit;
  text-decoration: none;
}

.course-title a:hover {
  color: var(--terracotta-dim);
}

.course-sub {
  margin: 0;
  color: var(--ink-soft);
  max-width: 54ch;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 1.1rem;
  margin-top: 0.85rem;
}

.tag {
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.22rem 0.6rem;
  background: rgba(255, 255, 255, 0.4);
}

.tag--live {
  border-color: rgba(47, 79, 74, 0.4);
  color: var(--pine);
}

.tag--hidden {
  border-color: rgba(180, 84, 31, 0.45);
  color: var(--terracotta-dim);
}

.row-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: stretch;
  min-width: 9.5rem;
}

/* ---------- Buttons & controls ---------- */

.btn {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.1rem;
  border-radius: 2px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.18s var(--ease), background 0.25s var(--ease), color 0.25s var(--ease),
    box-shadow 0.25s var(--ease);
}

.btn:hover {
  background: var(--terracotta);
  border-color: var(--terracotta);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn:active {
  transform: translateY(0);
}

.btn--ghost {
  background: transparent;
  color: var(--ink);
}

.btn--ghost:hover {
  background: rgba(29, 23, 19, 0.06);
  border-color: var(--ink);
  color: var(--ink);
}

.btn--danger {
  background: transparent;
  border-color: rgba(180, 84, 31, 0.5);
  color: var(--terracotta-dim);
}

.btn--danger:hover {
  background: var(--terracotta);
  border-color: var(--terracotta);
  color: var(--paper);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn--sm {
  padding: 0.45rem 0.75rem;
  font-size: 0.63rem;
}

input[type="text"],
input[type="password"],
input[type="file"],
textarea {
  width: 100%;
  font-family: var(--body);
  font-size: 0.95rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--rule);
  border-radius: 2px;
  padding: 0.65rem 0.8rem;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

input:focus-visible,
textarea:focus-visible,
.btn:focus-visible,
a:focus-visible {
  outline: 2px solid var(--terracotta);
  outline-offset: 2px;
}

textarea {
  resize: vertical;
  min-height: 5rem;
}

label {
  display: block;
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 0.4rem;
}

.field + .field {
  margin-top: 1.1rem;
}

/* ---------- Panels ---------- */

.panel {
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: clamp(1.3rem, 3vw, 2rem);
  box-shadow: var(--shadow-sm);
}

.notice {
  border-left: 3px solid var(--gold);
  background: rgba(192, 138, 46, 0.12);
  padding: 0.9rem 1.1rem;
  margin: 1.2rem 0;
  font-size: 0.9rem;
}

.notice--error {
  border-left-color: var(--terracotta);
  background: rgba(180, 84, 31, 0.12);
}

.notice--ok {
  border-left-color: var(--pine);
  background: rgba(47, 79, 74, 0.1);
}

.empty {
  margin-top: 2.5rem;
  padding: clamp(2rem, 6vw, 4rem);
  border: 1px dashed var(--rule);
  border-radius: 3px;
  text-align: left;
  background:
    repeating-linear-gradient(
      -45deg,
      rgba(29, 23, 19, 0.025) 0 10px,
      transparent 10px 20px
    );
}

.empty h3 {
  font-size: clamp(1.4rem, 3.5vw, 2rem);
  margin-bottom: 0.6rem;
}

.empty p {
  color: var(--ink-soft);
  max-width: 48ch;
}

/* Skeleton rows while the catalogue loads. */
.skeleton {
  display: grid;
  grid-template-columns: 4.5rem 1fr 9rem;
  gap: 2rem;
  padding: 2rem 0;
  border-bottom: 1px solid var(--rule);
}

.skeleton span {
  display: block;
  height: 0.8rem;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--paper-2), var(--paper-3), var(--paper-2));
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}

.skeleton span:nth-child(2) {
  height: 2rem;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

.footer {
  margin-top: clamp(3rem, 8vw, 6rem);
  padding: 2rem 0 3rem;
  border-top: 1px solid var(--rule);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ---------- Embed snippet ---------- */

.snippet {
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.7;
  background: var(--ink);
  color: #e8ddcd;
  padding: 0.9rem 1rem;
  border-radius: 2px;
  overflow-x: auto;
  white-space: pre;
  margin: 0.6rem 0 0;
}

/* ---------- Player (dark chrome) ---------- */

body.player {
  background: #17120f;
  background-image: none;
  color: #efe6d8;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

body.player::after {
  opacity: 0.18;
}

.player-bar {
  display: flex;
  align-items: center;
  gap: clamp(0.6rem, 2vw, 1.4rem);
  padding: 0.7rem clamp(0.8rem, 2vw, 1.4rem);
  background: rgba(29, 23, 19, 0.92);
  border-bottom: 1px solid rgba(239, 230, 216, 0.14);
  flex: none;
  z-index: 2;
}

.player-bar .back {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #cbbda9;
  text-decoration: none;
  white-space: nowrap;
}

.player-bar .back:hover {
  color: var(--gold);
}

.player-title {
  font-family: var(--display);
  font-size: clamp(0.95rem, 2.2vw, 1.2rem);
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.player-tools {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: none;
}

.player-bar .btn {
  border-color: rgba(239, 230, 216, 0.28);
  background: transparent;
  color: #efe6d8;
}

.player-bar .btn:hover {
  background: var(--terracotta);
  border-color: var(--terracotta);
}

.pill {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  border: 1px solid rgba(239, 230, 216, 0.28);
  color: #cbbda9;
  white-space: nowrap;
}

.pill[data-status="completed"],
.pill[data-status="passed"] {
  border-color: rgba(122, 176, 128, 0.6);
  color: #9fd3a4;
}

.pill[data-status="incomplete"],
.pill[data-status="browsed"] {
  border-color: rgba(192, 138, 46, 0.65);
  color: #e3b765;
}

.pill[data-status="failed"] {
  border-color: rgba(214, 112, 72, 0.7);
  color: #e89a77;
}

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #0f0c0a;
}

.stage iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
}

.stage-message {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  padding: 2rem;
  gap: 0.8rem;
  color: #cbbda9;
}

.spinner {
  width: 2rem;
  height: 2rem;
  margin: 0 auto;
  border: 2px solid rgba(239, 230, 216, 0.25);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(1turn);
  }
}

/* ---------- Admin ---------- */

.admin-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(1.2rem, 3vw, 2.5rem);
  align-items: start;
  margin-top: 2.2rem;
}

.dropzone {
  border: 2px dashed var(--rule);
  border-radius: 3px;
  padding: clamp(1.6rem, 4vw, 2.8rem);
  text-align: center;
  background: rgba(255, 255, 255, 0.35);
  transition: border-color 0.25s var(--ease), background 0.25s var(--ease),
    transform 0.25s var(--ease);
  cursor: pointer;
}

.dropzone:hover,
.dropzone.is-over {
  border-color: var(--terracotta);
  background: rgba(180, 84, 31, 0.07);
  transform: translateY(-2px);
}

.dropzone strong {
  font-family: var(--display);
  font-size: 1.25rem;
  display: block;
  margin-bottom: 0.3rem;
}

.progress {
  height: 6px;
  background: var(--paper-3);
  border-radius: 999px;
  overflow: hidden;
  margin: 1rem 0 0.5rem;
}

.progress span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--gold), var(--terracotta));
  transition: width 0.3s var(--ease);
}

.log {
  font-family: var(--mono);
  font-size: 0.7rem;
  line-height: 1.8;
  color: var(--ink-soft);
  max-height: 11rem;
  overflow-y: auto;
  margin-top: 0.8rem;
  padding-left: 0.1rem;
}

.manage-item {
  padding: 1rem 0;
  border-bottom: 1px solid var(--rule);
}

.manage-item h4 {
  font-family: var(--display);
  font-size: 1.1rem;
  margin: 0 0 0.3rem;
}

.manage-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.7rem;
}

.login-card {
  max-width: 26rem;
  margin: clamp(2rem, 10vh, 6rem) auto;
}

/* ---------- Responsive ---------- */

@media (max-width: 820px) {
  .hero,
  .admin-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .hero-aside {
    border-left: 0;
    border-top: 1px solid var(--rule);
    padding-left: 0;
    padding-top: 1.2rem;
  }

  .course-row {
    grid-template-columns: 2.6rem minmax(0, 1fr);
  }

  .row-actions {
    grid-column: 1 / -1;
    flex-direction: row;
    min-width: 0;
  }

  .skeleton {
    grid-template-columns: 2.6rem 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
