/* The Class nest display (nest-view.js): a serene, joyful sky gallery for the classroom screen. */

.main:has(> .cn) { max-width: none; padding-bottom: 28px; }

/* Full screen: the rail and floating assistant step aside, opening an unbroken morning sky. */
body:has(.cn.is-presenting) .rail,
body:has(.cn.is-presenting) .assistant,
body:has(.cn.is-presenting) .skip { display: none; }
body:has(.cn.is-presenting) .shell { display: block; }
body:has(.cn.is-presenting) .shell-main {
  min-height: 100dvh;
  background: transparent;
}
:root[data-theme="night"] body:has(.cn.is-presenting) .shell-main {
  background: transparent;
}
.main:has(> .cn.is-presenting) { padding: 18px clamp(16px, 2.2vw, 36px); }

.cn { display: grid; gap: clamp(14px, 1.8vh, 22px); align-content: start; }
.cn-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; }
.cn-brand { display: flex; align-items: center; gap: clamp(12px, 1.5vw, 20px); min-width: 0; }
/* The crest is drawn for a light ground, so its tile keeps the day sky in both themes. */
.cn-crest {
  flex: none; width: clamp(56px, 5.4vw, 80px); padding: var(--space-2); border-radius: var(--radius-md);
  background: var(--spot-cream);
  border: 1px solid var(--edge);
  box-shadow: var(--shadow-1);
}
.cn-crest .book-crest { filter: none; }
.cn-title-block { display: grid; gap: 3px; min-width: 0; }
/* The title and its line sit on the open sky, so they carry full ink weight. */
.cn-tagline, .cn-note { text-shadow: var(--ground-halo); }
.cn-note .btn { text-shadow: none; }
.cn-title { font-size: clamp(34px, 4.2vw, 64px); line-height: 1.04; overflow-wrap: anywhere; text-wrap: balance; }
.cn-tagline { font-size: clamp(16px, 1.5vw, 23px); color: var(--ink-2); font-weight: 500; }
.cn-staff { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }

.cn-leave { flex: none; }
.cn-key {
  padding: 1px 7px; border: 1px solid var(--line-strong); border-radius: 6px;
  font-size: 12px; font-weight: 700; color: var(--muted);
}

.cn-sky .sky { height: clamp(150px, 23vh, 300px); }

/* ---------- Every child's card: solid, like every surface that holds a name ---------- */
.cn-grid {
  --cn-pic: 124px; --cn-name: 26px; --cn-gap: clamp(12px, 1.3vw, 20px); --cn-cols: 6;
  display: flex; flex-wrap: wrap; justify-content: center; gap: calc(var(--cn-gap) + 12px) var(--cn-gap);
  width: 100%; margin: 0 auto;
  max-width: calc(var(--cn-cols) * (var(--cn-pic) + 44px) + (var(--cn-cols) - 1) * var(--cn-gap));
}
.cn-size-few { --cn-pic: min(240px, 24vh); --cn-name: clamp(22px, 2.4vw, 42px); }
.cn-size-some { --cn-pic: min(190px, 19vh); --cn-name: clamp(20px, 2vw, 36px); }
.cn-size-many { --cn-pic: min(136px, 13.5vh); --cn-name: clamp(18px, 1.7vw, 30px); }
.cn-size-lots { --cn-pic: min(112px, 11.5vh); --cn-name: clamp(17px, 1.4vw, 26px); }
.cn-cols-1 { --cn-cols: 1; }
.cn-cols-2 { --cn-cols: 2; }
.cn-cols-3 { --cn-cols: 3; }
.cn-cols-4 { --cn-cols: 4; }
.cn-cols-5 { --cn-cols: 5; }
.cn-cols-6 { --cn-cols: 6; }
.cn-cols-7 { --cn-cols: 7; }
.cn-cols-8 { --cn-cols: 8; }
.cn-cols-9 { --cn-cols: 9; }
.cn-cols-10 { --cn-cols: 10; }

.cn-child {
  position: relative; flex: 0 0 calc(var(--cn-pic) + 44px);
  display: grid; justify-items: center; align-content: start; gap: var(--space-2); padding: var(--space-3) var(--space-3) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--edge); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  text-align: center;
}
/* The picture's frame: the same window of sky as .hawk-pic (nest.css), sized by the grid. */
.cn-pic {
  display: grid; place-items: center; box-sizing: border-box;
  width: var(--cn-pic); height: var(--cn-pic); padding: calc(var(--cn-pic) * 0.07);
  border-radius: 22%;
  background: var(--hawk-well);
  box-shadow: inset 0 0 0 1px var(--hawk-well-edge);
}
.cn-pic > .hawk {
  width: 100%; height: 100%; max-width: none; object-fit: contain;
  padding: 0; border-radius: 0; background: none; box-shadow: none;
}
.cn-name {
  max-width: 100%; font-family: var(--font-display);
  font-variation-settings: "SOFT" 65, "WONK" 0;
  font-size: var(--cn-name); font-weight: 600; line-height: 1.15; overflow-wrap: anywhere;
}

/* Fully grown: Houston perched in his nest, bathed in soft sunlit champagne glow. */
.cn-stage-houston {
  border-color: var(--sun-edge);
  background: var(--sun-surface);
  box-shadow: 0 0 0 3px var(--sun-halo), var(--shadow-1);
}
.cn-stage-houston .cn-pic {
  background: url(/art/nest.svg) center 94% / 82% auto no-repeat, var(--hawk-well-sun);
  box-shadow: inset 0 0 0 1px var(--hawk-well-sun-edge);
}
.cn-badge {
  position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
  padding: 2px var(--space-3); border-radius: var(--radius-pill); white-space: nowrap;
  background: var(--gold-tint); color: var(--gold-ink); border: 1px solid var(--sun-500);
  box-shadow: var(--shadow-0);
  font-size: clamp(13px, 1vw, 16px); font-weight: 700;
}

/* Grown since the last reload: tranquil sunrise halo & gentle joyful hop. */
.cn-child.is-rising {
  border-color: var(--sun-500);
  box-shadow: 0 0 0 4px var(--sun-halo), var(--shadow-1);
}
.cn-badge-grew { background: var(--surface); border-color: var(--sun-500); color: var(--gold-ink); }

@media (prefers-reduced-motion: no-preference) {
  /* The frame stays still; only the picture inside it moves. A picture that is alive on
     its own (an SVG opened at #alive, or Houston's layered figure, which is not an <img>)
     is left to its own motion, so nothing ever moves twice. */
  .cn-stage-egg .cn-pic > img.hawk:not([src$="#alive"]), .cn-stage-cracking .cn-pic > img.hawk:not([src$="#alive"]) {
    animation: cn-egg-rock 8s var(--ease-silk) infinite; transform-origin: 50% 88%;
  }
  .cn-stage-hatching .cn-pic > img.hawk:not([src$="#alive"]), .cn-stage-hatchling .cn-pic > img.hawk:not([src$="#alive"]),
  .cn-stage-nestling .cn-pic > img.hawk:not([src$="#alive"]), .cn-stage-fledgling .cn-pic > img.hawk:not([src$="#alive"]) {
    animation: cn-gentle-bob 6s var(--ease-silk) infinite; transform-origin: 50% 100%;
  }
  .cn-stage-houston .cn-pic > img.hawk { animation: cn-hero-float 5.4s var(--ease-silk) infinite; }
  .cn-child:nth-child(3n + 1) .cn-pic > .hawk { animation-delay: -1.4s; }
  .cn-child:nth-child(3n + 2) .cn-pic > .hawk { animation-delay: -3.1s; }
  .cn-child:nth-child(5n + 3) .cn-pic > .hawk { animation-delay: -4.6s; }

  .cn-child.is-rising { animation: cn-glow 3s var(--ease-silk) infinite; }
  .cn-child.is-rising .cn-pic { animation: cn-hop 0.95s var(--ease-out) 4; transform-origin: 50% 100%; }
}
@keyframes cn-egg-rock {
  0%, 76%, 100% { transform: rotate(0); }
  81% { transform: rotate(-3.5deg); }
  87% { transform: rotate(3deg); }
  93% { transform: rotate(-1.5deg); }
}
@keyframes cn-gentle-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes cn-hero-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4.5px); } }
@keyframes cn-glow { 50% { box-shadow: 0 0 0 9px var(--sun-halo), 0 0 28px var(--sun-halo); } }
@keyframes cn-hop {
  0%, 100% { transform: translateY(0); }
  38% { transform: translateY(-10%) scale(1.03); }
  65% { transform: translateY(0) scale(1.02, 0.98); }
}

.cn-note {
  justify-self: center; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 12px;
  font-size: var(--text-sm); color: var(--ink-2); text-align: center;
}

@media (max-width: 720px) {
  .cn-sky .sky { min-height: 155px; }
  .cn-grid { --cn-pic: 96px; --cn-name: 20px; }
}

@media print {
  .cn-staff, .cn-leave, .cn-note, .cn-crest { display: none !important; }
  .cn-child { box-shadow: none; background: #fff; border-color: #999; }
}
