/* LEARN AI · YouTube channel showcase
   Portrait-first mosaic. Zero radius. Hard frames. */

:root {
  --mist: #d8e0e8;
  --paper: #eef2f6;
  --ink: #0e1116;
  --ink-soft: #2a3340;
  --steel: #5c6b7a;
  --lime: #c8f542;
  --lime-deep: #9bc41a;
  --cobalt: #1b3a8c;
  --vermillion: #e23d28;
  --frame: #f7f9fb;
  --shadow: 7px 7px 0 #0e1116;
  --font-display: "Bricolage Grotesque", system-ui, sans-serif;
  --font-body: "Source Serif 4", Georgia, serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --max: 1240px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  border-radius: 0 !important;
}

html {
  scroll-behavior: smooth;
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  background: var(--mist);
  font-family: var(--font-body);
  font-size: 1.05rem;
  line-height: 1.55;
  overflow-x: hidden;
}

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

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

button,
input {
  font: inherit;
  color: inherit;
}

.mono {
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.wallpaper {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    linear-gradient(
      180deg,
      rgba(238, 242, 246, 0.72) 0%,
      rgba(216, 224, 232, 0.55) 45%,
      rgba(238, 242, 246, 0.78) 100%
    ),
    url("assets/bg-signal-archive.png") center / cover no-repeat fixed;
  pointer-events: none;
}

.noise {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 90;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  mix-blend-mode: multiply;
}

main,
.footer {
  position: relative;
  z-index: 1;
}

main {
  flex: 1 0 auto;
  width: 100%;
}

.brand__mark {
  width: 1.75rem;
  height: 1.75rem;
  flex-shrink: 0;
  border: 2px solid color-mix(in srgb, var(--paper) 35%, transparent);
  box-shadow: 3px 3px 0 var(--lime);
  object-fit: cover;
  image-rendering: auto;
}

/* —— Channels —— */
.channels {
  width: min(100% - 2rem, var(--max));
  margin: 0 auto;
  padding: clamp(2rem, 5vw, 3.25rem) 0 2.5rem;
}

.channels__bar {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 1.5rem;
  align-items: end;
  margin-bottom: 1.25rem;
}

.channels__intro h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2rem, 5vw, 3.2rem);
  letter-spacing: -0.03em;
  line-height: 1;
  text-transform: uppercase;
}

.channels__intro p {
  margin: 0.65rem 0 0;
  color: var(--ink-soft);
  max-width: 36ch;
}

.channels__tools {
  display: grid;
  gap: 0.85rem;
}

.search-shell {
  display: grid;
  gap: 0.35rem;
  padding: 0.7rem 0.8rem;
  background: var(--frame);
  border: 2px solid var(--ink);
  box-shadow: 5px 5px 0 var(--cobalt);
}

.search-shell__label {
  font-size: 0.62rem;
  color: var(--steel);
}

.search-shell input {
  width: 100%;
  border: 0;
  border-bottom: 2px solid var(--ink);
  background: transparent;
  padding: 0.4rem 0;
  outline: none;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  text-transform: none;
  letter-spacing: 0;
}

.search-shell input:focus {
  border-bottom-color: var(--lime-deep);
  background: color-mix(in srgb, var(--lime) 18%, transparent);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.filter {
  cursor: pointer;
  padding: 0.6rem 0.85rem;
  background: var(--paper);
  border: 2px solid var(--ink);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  clip-path: polygon(
    0 0,
    calc(100% - 10px) 0,
    100% 10px,
    100% 100%,
    10px 100%,
    0 calc(100% - 10px)
  );
  transition:
    background 0.2s var(--ease),
    transform 0.2s var(--ease),
    box-shadow 0.2s var(--ease);
}

.filter:hover,
.filter:focus-visible {
  background: color-mix(in srgb, var(--lime) 35%, var(--paper));
  transform: translateY(-2px);
}

.filter.is-active {
  background: var(--lime);
  box-shadow: 4px 4px 0 var(--ink);
}

.result-count {
  min-height: 1.2em;
  margin: 0 0 1.1rem;
  font-size: 0.68rem;
  color: var(--steel);
}

/* —— Portrait mosaic (packed columns, no holes) —— */
.mosaic {
  column-count: 3;
  column-gap: 0.9rem;
}

.portrait {
  --accent: var(--lime);
  position: relative;
  display: block;
  width: 100%;
  margin: 0 0 0.9rem;
  break-inside: avoid;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: var(--ink);
  border: 3px solid var(--ink);
  box-shadow: 6px 6px 0 var(--ink);
  isolation: isolate;
  opacity: 1;
  transform: none;
  filter: none;
  transition:
    box-shadow 0.25s var(--ease),
    transform 0.25s var(--ease);
}

.portrait:nth-child(3n) {
  --accent: #3dd6c6;
}

.portrait:nth-child(3n + 1) {
  --accent: var(--lime);
}

.portrait:nth-child(3n + 2) {
  --accent: #f0a202;
}

.portrait:nth-child(4n) {
  --accent: #6ea8fe;
}

/* Height variety within equal-width columns */
.portrait--hero {
  aspect-ratio: 4 / 5;
}

.portrait--tall {
  aspect-ratio: 3 / 4;
}

.portrait--wide {
  aspect-ratio: 5 / 4;
}

.portrait--std {
  aspect-ratio: 1 / 1;
}

.portrait__media {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.portrait__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  filter: contrast(1.05) saturate(1.05);
  transform: scale(1.02);
  transition:
    transform 0.45s var(--ease),
    filter 0.35s var(--ease);
}

.portrait__frame {
  position: absolute;
  inset: 8px;
  z-index: 1;
  border: 1px solid color-mix(in srgb, white 45%, transparent);
  pointer-events: none;
  mix-blend-mode: soft-light;
}

.portrait__frame::before,
.portrait__frame::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid var(--accent);
}

.portrait__frame::before {
  top: -2px;
  left: -2px;
  border-right: 0;
  border-bottom: 0;
}

.portrait__frame::after {
  bottom: -2px;
  right: -2px;
  border-left: 0;
  border-top: 0;
}

.portrait__shade {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: linear-gradient(
    to top,
    rgba(14, 17, 22, 0.92) 0%,
    rgba(14, 17, 22, 0.45) 38%,
    rgba(14, 17, 22, 0.08) 62%,
    transparent 100%
  );
  pointer-events: none;
}

.portrait__meta {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  padding: 0.9rem 1rem 1rem;
  color: var(--paper);
}

.portrait__tag {
  display: inline-block;
  margin-bottom: 0.45rem;
  padding: 0.22rem 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.58rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--ink);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 70%, white);
}

.portrait__name {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.05rem, 2vw, 1.55rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.portrait--hero .portrait__name {
  font-size: clamp(1.35rem, 2.6vw, 2rem);
}

.portrait__handle {
  margin: 0.35rem 0 0;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: color-mix(in srgb, var(--lime) 75%, white);
}

.portrait__cta {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.55rem;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--paper);
  opacity: 0.85;
}

.portrait__cta::after {
  content: "↗";
  transition: transform 0.2s var(--ease);
}

.portrait:not(.is-leaving):not(.is-revealing):hover,
.portrait:not(.is-leaving):not(.is-revealing):focus-visible {
  transform: translate(-3px, -3px);
  box-shadow: 10px 10px 0 var(--accent);
  outline: none;
  z-index: 4;
}

.portrait:hover .portrait__media img,
.portrait:focus-visible .portrait__media img {
  transform: scale(1.08);
  filter: contrast(1.1) saturate(1.15);
}

.portrait:hover .portrait__cta::after,
.portrait:focus-visible .portrait__cta::after {
  transform: translate(3px, -3px);
}

/* Filter motion: keyframes (reliable after display toggles) */
.mosaic.is-filtering {
  pointer-events: none;
}

.portrait.is-leaving {
  animation: portraitOut 0.32s var(--ease) forwards;
  pointer-events: none;
}

.portrait.is-revealing {
  animation: portraitIn 0.48s var(--ease) both;
}

.portrait.is-hidden {
  display: none !important;
}

@keyframes portraitOut {
  from {
    opacity: 1;
    transform: none;
    filter: blur(0);
  }
  to {
    opacity: 0;
    transform: scale(0.94) translateY(10px);
    filter: blur(2px);
  }
}

@keyframes portraitIn {
  from {
    opacity: 0;
    transform: scale(0.94) translateY(16px);
    filter: blur(2px);
  }
  to {
    opacity: 1;
    transform: none;
    filter: blur(0);
  }
}

.portrait__fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  background:
    repeating-linear-gradient(
      -45deg,
      #1a2230,
      #1a2230 8px,
      #121820 8px,
      #121820 16px
    );
  color: var(--lime);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2rem, 5vw, 3.5rem);
}

/* —— Footer —— */
.footer {
  flex-shrink: 0;
  margin-top: auto;
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  padding: 1.5rem clamp(1rem, 3vw, 2rem);
  background: var(--ink);
  color: var(--paper);
  border-top: 4px solid var(--lime);
}

.footer__brand {
  display: flex;
  gap: 0.85rem;
  align-items: center;
}

.footer__brand strong {
  display: block;
  font-family: var(--font-display);
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}

.footer__brand p {
  margin: 0.2rem 0 0;
  font-size: 0.62rem;
  color: color-mix(in srgb, var(--paper) 65%, transparent);
}

.footer__note {
  margin: 0;
  font-size: 0.62rem;
  color: color-mix(in srgb, var(--paper) 55%, transparent);
  max-width: 42ch;
}

/* —— Reveal —— */
[data-reveal] {
  opacity: 0;
  transform: translateY(16px);
  transition:
    opacity 0.65s var(--ease),
    transform 0.65s var(--ease);
}

[data-reveal].is-in {
  opacity: 1;
  transform: none;
}

/* —— Responsive —— */
@media (max-width: 980px) {
  .channels__bar {
    grid-template-columns: 1fr;
  }

  .mosaic {
    column-count: 2;
  }
}

@media (max-width: 640px) {
  .mosaic {
    column-count: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  [data-reveal] {
    opacity: 1;
    transform: none;
  }

  .portrait.is-leaving,
  .portrait.is-revealing {
    animation: none !important;
    opacity: 1;
    filter: none;
    transform: none;
  }
}
