/* Floppy disk mechanics and materials. Loaded after style.css.
 *
 * All geometry is in % of the .disk padding box (the disk is square).
 *   Fixed media opening (.read-window, in the shell):  x 45–55 %, y 5–29 %  → centre 50 % / 17 %
 *   Shutter (.shutter):                                 x 24–76 %, y 0–35 %
 *   Shutter aperture, closed:                           x 61–71 %  (over plain plastic)
 *   Travel to the mechanical stop:                      16 % of the disk = 30.769 % of the shutter
 *   Aperture, open (at the stop):                       x 45–55 %  = exactly the media opening
 *
 * Inputs (inherited custom properties, set by site.js on .opening):
 *   --shutter-open  unitless 0…1, linear. The spring-loaded curve and the hard stop live here.
 *   --spin          media rotation (deg).   --zoom  camera scale (fades the surface sheen).
 * Inputs set by disk-effects.js on .disk-art: --lx / --ly (0…1), light position from the pointer.
 */

.disk-art { --lx: .28; --ly: .18; }

.disk {
  --plastic-hi: #ffd590;
  --plastic-lo: #c8762f;
  --metal-hi: #fbfcf4;
  --metal: #c9d2c9;
  --metal-lo: #87958d;
  --media: #2e2839;
  /* Camera pivot = centre of the aligned media opening (border 4px; 50 % / 17 % of the padding box). site.js reads it. */
  transform-origin: 50% calc(4px + (100% - 8px) * .17);
  --o: clamp(0, var(--shutter-open, 0), 1);
  /* Spring-loaded: eases out of rest, still moving when it meets the stop. */
  --travel: calc(var(--o) * var(--o) * (2 - var(--o)));
  /* 0 → 1 as the camera passes through the aperture: its cut edges dissolve instead of framing the view. */
  --near: clamp(0, (var(--zoom, 1) - 6) / 12, 1);
  background:
    radial-gradient(140% 70% at 0 0, rgb(255 240 200 / .35), transparent 60%),
    linear-gradient(130deg, #ffc368, #e89241 67%, #d9873a);
}

/* ---------- Shell: recessed shutter channel and its stop ---------- */
.shutter-track {
  position: absolute; left: 5.5%; width: 70.5%; top: 0; height: 36%;
  background: linear-gradient(to bottom, rgb(120 56 18 / .16), rgb(120 56 18 / .05) 40%, rgb(255 220 160 / .05));
  box-shadow: inset 0 3px 0 rgb(92 46 20 / .22), inset 3px 0 0 rgb(92 46 20 / .14), inset 0 -2px 0 rgb(255 226 168 / .55);
}
.shutter-stop {
  position: absolute; left: 0; width: 3.546%; top: 22.2%; height: 52.8%; transform-origin: 0 50%;
  background: linear-gradient(90deg, #ffd790, #eea04c);
  box-shadow: inset -2px 0 0 #7a4a2a, inset 0 -2px 0 #9b5f32, 2px 2px 0 rgb(82 40 18 / .35);
}

/* ---------- Fixed media opening (in the shell) ---------- */
.disk .read-window {
  left: 45%; top: 5%; width: 10%; height: 24%; border-radius: 1px; isolation: isolate;
  background: var(--media);
  box-shadow: none;
}
/* Media is a circle centred on the hub (50 %, 52 %), radius 48 % of the disk. */
.disk .read-window::before,
.disk .read-window::after {
  content: ""; position: absolute; left: -430%; top: -4.17%; width: 960%; aspect-ratio: 1; border-radius: 50%;
}
/* Rotating oxide: fine tracks + slow mottling that betrays the spin. */
.disk .read-window::after {
  transform: rotate(var(--spin, 0deg));
  background:
    repeating-radial-gradient(circle closest-side, rgb(255 238 214 / .07) 0 .16%, rgb(0 0 0 / .16) .3% .42%, transparent .5% .714%),
    conic-gradient(#322935, #2b2431 40deg, #3a2f3e 95deg, #29222e 160deg, #352b38 230deg, #2c2431 300deg, #322935);
}
/* Anisotropic sheen stays put relative to the light while the disk turns. */
.disk .read-window::before {
  z-index: 1;
  background: conic-gradient(from -28deg, transparent 0 14deg, rgb(255 232 205 / .2) 32deg, transparent 52deg 194deg, rgb(255 232 205 / .12) 212deg, transparent 232deg);
}
/* Depth of the shell wall above the media. */
.read-window-wall {
  position: absolute; left: 45%; top: 5%; width: 10%; height: 24%; pointer-events: none;
  box-shadow: inset 0 0 0 2px rgb(43 28 20 / calc(1 - var(--near))), inset 2px 5px 0 1px rgb(14 8 12 / calc(.42 - .42 * var(--near)));
}

/* ---------- Metal shutter with a real aperture ---------- */
.disk .shutter {
  --cut: polygon(evenodd, 0 0, 100% 0, 100% 100%, 0 100%, 0 0, 71.154% 14.286%, 71.154% 82.857%, 90.385% 82.857%, 90.385% 14.286%, 71.154% 14.286%);
  left: 24%; width: 52%; height: 35%;
  border: 0; border-radius: 0; background: none; box-shadow: none;
  transform: none;
  translate: calc(var(--travel) * -30.769%) 0;
}
.disk .shutter::after { content: none; }
/* Hard offset shadow, cut with the same aperture so light falls through the hole. */
.disk .shutter::before {
  content: ""; position: absolute; inset: 0; translate: calc(3px - 3px * var(--near)) calc(3px - 3px * var(--near));
  background: rgb(74 36 14 / .34);
  clip-path: var(--cut);
}
.shutter-plate {
  position: absolute; inset: 0; overflow: hidden;
  clip-path: var(--cut);
  background:
    linear-gradient(to bottom, rgb(255 255 255 / .55) 0 5%, rgb(90 100 96 / .25) 5% 6.5%, transparent 6.5%),
    radial-gradient(60% 80% at 18% 62%, rgb(255 255 255 / .18), transparent 70%),
    radial-gradient(40% 60% at 52% 40%, rgb(70 84 80 / .1), transparent 70%),
    repeating-linear-gradient(0deg, rgb(255 255 255 / .12) 0 1px, transparent 1px 3px),
    linear-gradient(100deg, #e4e9df, var(--metal) 45%, #aab6ae);
  box-shadow: inset 2px 0 0 var(--edge, #523526), inset -2px -2px 0 var(--edge, #523526), inset 5px 0 0 var(--metal-hi), inset -5px -5px 0 var(--metal-lo);
}
/* Stamped rib: a fixed feature on the plate so its travel reads. */
.shutter-plate::before {
  content: ""; position: absolute; left: 9%; width: 46%; top: 22%; height: 52%; border-radius: 2px;
  background: linear-gradient(100deg, rgb(255 255 255 / .2), rgb(255 255 255 / .04) 60%, rgb(80 92 88 / .1));
  box-shadow: inset 1px 1px 0 rgb(80 92 88 / .35), inset -1px -1px 0 rgb(255 255 255 / .6);
}
/* Glint: counter-moves with the plate, so it stays with the light while the metal slides under it. */
.shutter-glint {
  position: absolute; inset: 0; pointer-events: none;
  --gx: calc(16% + var(--lx) * 46%);
  translate: calc(var(--travel) * 30.769%) 0;
  background:
    linear-gradient(104deg, transparent calc(var(--gx) - 9%), rgb(255 255 255 / .42) calc(var(--gx) - 1.5%), rgb(255 255 255 / .8) var(--gx), transparent calc(var(--gx) + 5%)),
    linear-gradient(104deg, transparent calc(var(--gx) + 10%), rgb(255 255 255 / .22) calc(var(--gx) + 13%), transparent calc(var(--gx) + 16%));
}
/* The aperture's cut edge: metal thickness, and the shadow it casts on whatever lies under it. */
.shutter-rim {
  position: absolute; left: 71.154%; top: 14.286%; width: 19.231%; height: 68.571%; pointer-events: none;
  box-shadow: inset 0 0 0 2px rgb(82 53 38 / calc(1 - var(--near))), inset 3px 3px 0 2px rgb(48 22 8 / calc(.3 - .3 * var(--near))), 1px 1px 0 2px var(--metal-hi);
}

/* ---------- Handwritten paper label ---------- */
.disk .disk-label {
  background:
    linear-gradient(to bottom, #396c6a 0 18%, rgb(255 255 255 / .35) 18% 19.5%, transparent 19.5%),
    repeating-linear-gradient(to bottom, transparent 0 calc(26% - 1px), rgb(140 160 190 / .38) calc(26% - 1px) 26%),
    linear-gradient(160deg, #fff6dc, #fbe8bd);
  background-position: 0 0, 0 9%, 0 0;
}
.disk-title, .disk-inscription {
  position: absolute; z-index: 1; left: 50%;
  font: 600 14cqw/.9 Caveat, cursive; white-space: nowrap;
  transform: translate(-50%, -50%) rotate(-6deg);
}
.disk-title {
  top: 37%; color: #161310;
  font-size: min(14cqw, calc(180cqw / var(--title-length, 11)));
  text-decoration-thickness: .085em;
}
.disk-inscription {
  top: 66%; color: #263952;
  text-shadow: 0 0 .5px rgb(38 57 82 / .5);
}

/* ---------- Light across the whole shell (fades once the camera dives in) ---------- */
.disk-sheen {
  position: absolute; inset: 0; pointer-events: none; z-index: 2;
  opacity: calc(1.6 - var(--zoom, 1) * .6);
  background:
    radial-gradient(90% 70% at calc(var(--lx) * 100%) calc(var(--ly) * 100%), rgb(255 250 230 / .26), transparent 62%),
    linear-gradient(135deg, transparent 55%, rgb(70 30 10 / .1));
}

/* ---------- Inside: Three.js platter (fallback: the CSS .spindle) ---------- */
.platter-3d { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.inside-disk.has-3d .spindle { display: none; }
