/* =============================================================================
   FD Study v2 — interactive scene navigation on the homepage
   =============================================================================
   Markup in homepage-study.html. Two presentations:

     ≥ 720px  the full scene: three parallax layers, hover/focus wakes an
              object AND plays its micro-animation (brush paints, terminal
              types, letter opens, wooden man takes a strike, teapot pours,
              disc spins, scroll sways and gets its seal).
     < 720px  six large door-cards (single tap navigates; no hover layer).

   All motion is disabled under prefers-reduced-motion.
   ============================================================================= */


/* -----------------------------------------------------------------------------
   Section wrapper + header
   ----------------------------------------------------------------------------- */

.fd-study {
  max-width: 74rem;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 3rem;
}

@media (min-width: 900px) {
  .fd-study {
    padding: 3.5rem 2rem 4rem;
  }
}

.fd-study__header {
  text-align: center;
  margin-bottom: 1.25rem;
}

.fd-study__eyebrow {
  display: inline-block;
  font-family: var(--fd-font-sans);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--fd-accent);
  margin: 0 0 0.85rem 0;
}

.fd-study__heading {
  font-family: var(--fd-font-serif);
  font-size: 1.5rem;
  font-weight: 500;
  line-height: 1.2;
  color: var(--fd-text-strong);
  margin: 0;
  letter-spacing: -0.01em;
}

@media (min-width: 900px) {
  .fd-study__heading {
    font-size: 1.9rem;
  }
}


/* -----------------------------------------------------------------------------
   Scene shell + parallax layers
   ----------------------------------------------------------------------------- */

.fd-study__scene {
  position: relative;
}

.fd-study__svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.fd-study__layer-back,
.fd-study__layer-mid,
.fd-study__layer-front {
  will-change: transform;
}

/* Every animated SVG part measures its transform-origin against its own box */
.fd-study__svg [class^="fd-"],
.fd-study__svg [class*=" fd-"] {
  transform-box: fill-box;
}


/* -----------------------------------------------------------------------------
   Spots — resting and woken states
   ----------------------------------------------------------------------------- */

.fd-study__spot {
  color: var(--fd-accent);
  opacity: 0.62;
  cursor: pointer;
  outline: none;
  transition:
    opacity 240ms ease-out,
    filter 240ms ease-out,
    transform 300ms cubic-bezier(0.22, 1, 0.36, 1);
}

.fd-study__spot:hover,
.fd-study__spot:focus-visible {
  color: var(--fd-accent-strong);
  opacity: 1;
  filter: drop-shadow(0 0 8px var(--fd-accent-a55));
  transform: translateY(-2px);
}

.fd-study__spot:focus-visible {
  outline: 2px solid var(--fd-accent);
  outline-offset: 6px;
  border-radius: 6px;
}


/* -----------------------------------------------------------------------------
   Entrance — the room assembles as it scrolls into view
   ----------------------------------------------------------------------------- */

.fd-study .fd-study__spot,
.fd-study .fd-study__furniture,
.fd-study .fd-study__layer-back {
  opacity: 0;
  transform: translateY(10px);
}

.fd-study.is-inview .fd-study__layer-back {
  opacity: 1;
  transform: none;
  transition: opacity 900ms ease-out, transform 900ms cubic-bezier(0.22, 1, 0.36, 1);
}

.fd-study.is-inview .fd-study__furniture {
  opacity: 1;
  transform: none;
  transition: opacity 700ms ease-out 0.1s, transform 700ms cubic-bezier(0.22, 1, 0.36, 1) 0.1s;
}

.fd-study.is-inview .fd-study__spot {
  opacity: 0.62;
  transform: none;
  transition:
    opacity 700ms ease-out,
    transform 700ms cubic-bezier(0.22, 1, 0.36, 1),
    filter 240ms ease-out,
    color 240ms ease-out;
}

.fd-study.is-inview .fd-study__spot--scroll   { transition-delay: 0.1s; }
.fd-study.is-inview .fd-study__spot--ink      { transition-delay: 0.2s; }
.fd-study.is-inview .fd-study__spot--terminal { transition-delay: 0.3s; }
.fd-study.is-inview .fd-study__spot--letter   { transition-delay: 0.4s; }
.fd-study.is-inview .fd-study__spot--dummy    { transition-delay: 0.5s; }
.fd-study.is-inview .fd-study__spot--living   { transition-delay: 0.6s; }

.fd-study.is-inview .fd-study__spot:hover,
.fd-study.is-inview .fd-study__spot:focus-visible {
  opacity: 1;
  transform: translateY(-2px);
  transition-delay: 0s;
}


/* =============================================================================
   Micro-animations, object by object
   ============================================================================= */

/* ---- shared: self-drawing strokes (the paint line, the pour) ---- */

.fd-paint,
.fd-pour {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset 700ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- 1. Scroll: sways, seal stamps itself ---- */

@keyframes fd-anim-sway {
  0%   { transform: rotate(0deg); }
  35%  { transform: rotate(-1.6deg); }
  70%  { transform: rotate(1.1deg); }
  100% { transform: rotate(0deg); }
}

.fd-sway { transform-origin: 50% 0%; }

.fd-study__spot--scroll:hover .fd-sway,
.fd-study__spot--scroll:focus-visible .fd-sway {
  animation: fd-anim-sway 1.6s cubic-bezier(0.37, 0, 0.63, 1) both;
}

.fd-seal {
  opacity: 0;
  transform: scale(0.7);
  transform-origin: 50% 50%;
  transition: opacity 250ms ease-out, transform 250ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.fd-study__spot--scroll:hover .fd-seal,
.fd-study__spot--scroll:focus-visible .fd-seal {
  opacity: 0.95;
  transform: scale(1);
  transition-delay: 0.3s;
}

/* ---- 2. Ink and brush: the brush leans in, a stroke paints itself ---- */

.fd-brush {
  transform-origin: 15% 85%;
  transition: transform 350ms cubic-bezier(0.22, 1, 0.36, 1);
}

.fd-study__spot--ink:hover .fd-brush,
.fd-study__spot--ink:focus-visible .fd-brush {
  transform: rotate(5deg) translateY(2px);
}

.fd-study__spot--ink:hover .fd-paint,
.fd-study__spot--ink:focus-visible .fd-paint {
  stroke-dashoffset: 0;
  transition-delay: 0.15s;
}

/* ---- 3. Terminal: cursor always blinks; on hover it types ---- */

@keyframes fd-anim-blink {
  0%, 55%   { opacity: 1; }
  60%, 100% { opacity: 0; }
}

.fd-cursor {
  animation: fd-anim-blink 1.2s steps(1) infinite;
  transition: transform 250ms ease-out 0.75s;
}

.fd-type {
  opacity: 0.35;
  transform: scaleX(1);
  transform-origin: 0% 50%;
}

.fd-type-4 { opacity: 0; }

@keyframes fd-anim-type {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

.fd-study__spot--terminal:hover .fd-type,
.fd-study__spot--terminal:focus-visible .fd-type {
  opacity: 0.75;
  animation: fd-anim-type 320ms ease-out both;
}

.fd-study__spot--terminal:hover .fd-type-1 { animation-delay: 0s; }
.fd-study__spot--terminal:hover .fd-type-2 { animation-delay: 0.16s; }
.fd-study__spot--terminal:hover .fd-type-3 { animation-delay: 0.32s; }
.fd-study__spot--terminal:hover .fd-type-4 { animation-delay: 0.48s; }
.fd-study__spot--terminal:focus-visible .fd-type-2 { animation-delay: 0.16s; }
.fd-study__spot--terminal:focus-visible .fd-type-3 { animation-delay: 0.32s; }
.fd-study__spot--terminal:focus-visible .fd-type-4 { animation-delay: 0.48s; }

.fd-study__spot--terminal:hover .fd-cursor,
.fd-study__spot--terminal:focus-visible .fd-cursor {
  transform: translate(-4px, 58px);
}

/* ---- 4. Letter: the flap opens, the note (with the dragon's eye) rises ---- */

.fd-flap {
  transform-origin: 50% 3%;
  transition: transform 400ms cubic-bezier(0.22, 1, 0.36, 1);
}

.fd-note {
  transition: transform 450ms cubic-bezier(0.22, 1, 0.36, 1) 0.12s;
}

.fd-study__spot--letter:hover .fd-flap,
.fd-study__spot--letter:focus-visible .fd-flap {
  transform: rotate(-168deg);
}

.fd-study__spot--letter:hover .fd-note,
.fd-study__spot--letter:focus-visible .fd-note {
  transform: translateY(-24px);
}

/* ---- 5. Wooden man: takes a quick chain of strikes ---- */

@keyframes fd-anim-strike {
  0%   { transform: rotate(0deg); }
  30%  { transform: rotate(4deg); }
  65%  { transform: rotate(-2deg); }
  100% { transform: rotate(0deg); }
}

@keyframes fd-anim-shake {
  0%   { transform: translateX(0); }
  30%  { transform: translateX(1.6px); }
  60%  { transform: translateX(-1px); }
  100% { transform: translateX(0); }
}

.fd-arm { transform-origin: 100% 50%; }
.fd-leg { transform-origin: 85% 5%; }

.fd-study__spot--dummy:hover .fd-arm-1,
.fd-study__spot--dummy:focus-visible .fd-arm-1 {
  animation: fd-anim-strike 0.5s ease-out both;
}

.fd-study__spot--dummy:hover .fd-arm-2,
.fd-study__spot--dummy:focus-visible .fd-arm-2 {
  animation: fd-anim-strike 0.5s ease-out 0.12s both;
}

.fd-study__spot--dummy:hover .fd-arm-3,
.fd-study__spot--dummy:focus-visible .fd-arm-3 {
  animation: fd-anim-strike 0.5s ease-out 0.24s both;
}

.fd-study__spot--dummy:hover .fd-trunk,
.fd-study__spot--dummy:focus-visible .fd-trunk {
  animation: fd-anim-shake 0.5s ease-out 0.06s both;
}

/* ---- 6. Teapot pours into the cup; steam rises; the disc spins ---- */

.fd-pot {
  transform-origin: 88% 55%;
  transition: transform 380ms cubic-bezier(0.22, 1, 0.36, 1);
}

.fd-study__spot--living:hover .fd-pot,
.fd-study__spot--living:focus-visible .fd-pot {
  transform: rotate(12deg);
}

.fd-study__spot--living:hover .fd-pour,
.fd-study__spot--living:focus-visible .fd-pour {
  stroke-dashoffset: 0;
  transition-delay: 0.25s;
  transition-duration: 350ms;
}

.fd-steam {
  opacity: 0;
  transform: translateY(3px);
  transition: opacity 400ms ease-out, transform 500ms ease-out;
}

.fd-study__spot--living:hover .fd-steam,
.fd-study__spot--living:focus-visible .fd-steam {
  opacity: 0.65;
  transform: translateY(-3px);
  transition-delay: 0.55s;
}

@keyframes fd-anim-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.fd-disc { transform-origin: 50% 50%; }

.fd-study__spot--living:hover .fd-disc,
.fd-study__spot--living:focus-visible .fd-disc {
  animation: fd-anim-spin 1.6s linear infinite;
}


/* -----------------------------------------------------------------------------
   Caption bar
   ----------------------------------------------------------------------------- */

.fd-study__caption {
  min-height: 1.9em;
  margin: 1.4rem auto 0;
  text-align: center;

  font-family: var(--fd-font-serif);
  font-style: italic;
  font-size: 1.05rem;
  line-height: 1.5;
  color: var(--fd-text-muted);

  transition: color 200ms ease-out;
}

.fd-study__caption.is-active {
  color: var(--fd-accent-strong);
}

@media (min-width: 900px) {
  .fd-study__caption {
    font-size: 1.15rem;
  }
}


/* -----------------------------------------------------------------------------
   Mobile door-cards (< 720px): scene hides, cards take over
   ----------------------------------------------------------------------------- */

.fd-study__doors {
  display: none;
}

@media (max-width: 719px) {

  .fd-study__scene,
  .fd-study__caption {
    display: none;
  }

  .fd-study__doors {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.85rem;
    margin-top: 0.5rem;
  }

  .fd-study__door {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;

    padding: 1.1rem 0.75rem 1rem;
    background: var(--fd-bg-card);
    border: 1px solid var(--fd-line-soft);
    border-radius: var(--fd-card-radius);
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;

    transition: background var(--fd-transition), transform 160ms ease-out, border-color var(--fd-transition);
  }

  .fd-study__door:active {
    background: var(--fd-bg-card-hover);
    border-color: var(--fd-accent-line);
    transform: scale(0.975);
  }

  .fd-study__door svg {
    width: 100%;
    height: 108px;
    margin-bottom: 0.5rem;
  }

  .fd-study__door-name {
    font-family: var(--fd-font-sans);
    font-size: 0.74rem;
    font-weight: 500;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--fd-text-strong);
  }

  .fd-study__door-sub {
    font-family: var(--fd-font-serif);
    font-style: italic;
    font-size: 0.85rem;
    color: var(--fd-text-muted);
  }

  /* entrance stagger for the cards */
  .fd-study .fd-study__door {
    opacity: 0;
    transform: translateY(10px);
  }

  .fd-study.is-inview .fd-study__door {
    opacity: 1;
    transform: none;
    transition:
      opacity 600ms ease-out,
      transform 600ms cubic-bezier(0.22, 1, 0.36, 1),
      background var(--fd-transition),
      border-color var(--fd-transition);
  }

  .fd-study.is-inview .fd-study__door:nth-child(1) { transition-delay: 0.05s; }
  .fd-study.is-inview .fd-study__door:nth-child(2) { transition-delay: 0.12s; }
  .fd-study.is-inview .fd-study__door:nth-child(3) { transition-delay: 0.19s; }
  .fd-study.is-inview .fd-study__door:nth-child(4) { transition-delay: 0.26s; }
  .fd-study.is-inview .fd-study__door:nth-child(5) { transition-delay: 0.33s; }
  .fd-study.is-inview .fd-study__door:nth-child(6) { transition-delay: 0.4s; }

  .fd-study.is-inview .fd-study__door:active {
    transform: scale(0.975);
    transition-delay: 0s;
  }
}


/* -----------------------------------------------------------------------------
   Reduced motion — everything visible and finished, nothing moves
   ----------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {

  .fd-study .fd-study__spot,
  .fd-study .fd-study__furniture,
  .fd-study .fd-study__layer-back,
  .fd-study .fd-study__door {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .fd-study .fd-study__spot { opacity: 0.62; }

  .fd-cursor,
  .fd-study__spot:hover .fd-arm,
  .fd-study__spot:hover .fd-trunk,
  .fd-study__spot:hover .fd-disc,
  .fd-study__spot:hover .fd-sway {
    animation: none !important;
  }

  .fd-paint,
  .fd-pour {
    stroke-dashoffset: 0;
    transition: none;
  }

  .fd-seal { opacity: 0.9; transform: none; }
  .fd-steam { opacity: 0.4; transform: none; }

  .fd-brush, .fd-pot, .fd-flap, .fd-note, .fd-cursor, .fd-type {
    transition: none;
    animation: none;
  }

  .fd-type, .fd-type-4 { opacity: 0.45; }

  .fd-study__spot:hover,
  .fd-study__spot:focus-visible {
    transform: none;
  }

  .fd-study__spot:hover .fd-pot,
  .fd-study__spot:hover .fd-flap,
  .fd-study__spot:hover .fd-note,
  .fd-study__spot:hover .fd-brush {
    transform: none;
  }
}
