/* Studio panel: the white page between the two photo sections.
   js/studio.js sizes the name; everything else is layout and reveal. */

.studio {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: clamp(20px, 4vh, 56px);
  padding: calc(var(--header-h) + 1vh) var(--gutter) calc(var(--gutter) + 54px);
  background: var(--paper);
  color: var(--ink);
}

/* Hidden until the first fit so the fallback size never shows. */
.studio-name {
  /* Set flush right, clear of the section rail on the left; studio.js fits each line to this width. */
  width: calc(100% - var(--rail-space));
  margin: 0 0 auto auto;
  font-family: var(--font-sans);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: -0.045em;
  line-height: 0.86;
  font-size: 8.5vw;
  visibility: hidden;
}

.panel--studio.is-fitted .studio-name {
  visibility: visible;
}

/* Letter-spacing is repeated in em on every level that changes font-size.
   An inherited letter-spacing is an absolute length, so it would otherwise
   stay at the h1's size and the fit would drift. */
.fit-line {
  display: block;
  width: max-content;
  white-space: nowrap;
  letter-spacing: -0.045em;
}

.fit-word {
  display: inline-block;
  overflow: hidden;
  vertical-align: top;
  /* Negative tracking lands after the last glyph, so its ink can overhang the
     word's box, and overflow:hidden would clip it. The padding gives the mask
     room; the matching negative margin keeps the layout unchanged. */
  padding-right: 0.08em;
  padding-bottom: 0.02em;
  margin-right: -0.08em;
  letter-spacing: -0.045em;
}

.fit-inner {
  display: inline-block;
  transform: translateY(105%);
  transition: transform var(--dur-reveal) var(--ease-out);
  transition-delay: calc(80ms + var(--i, 0) * 75ms);
}

.panel.is-revealed .fit-inner {
  transform: none;
}

/* Stacked (phones): each word is its own block and is fitted on its own. */
.studio-name.is-stacked .fit-line {
  width: auto;
}

.studio-name.is-stacked .fit-word {
  display: block;
  width: max-content;
}

/* Grid */

/* The lower block shares the name's column: the blurb starts at the name's left edge and the
   contact ends at its right edge. When the two can't sit side by side (tablets), the contact
   wraps underneath and stays flush right. */
.studio-grid {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 22px var(--gutter);
  margin-left: var(--rail-space);
  padding-top: clamp(22px, 3.2vh, 38px);
}

.studio-grid::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--hair);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 1.4s var(--ease-out) 0.3s;
}

.panel.is-revealed .studio-grid::before {
  transform: none;
}

.studio-blurb {
  flex: 0 1 31ch;
  max-width: 31ch;
  margin: 0;
  font-family: var(--font-sans);
  font-weight: 400;
  font-size: var(--fs-body);
  line-height: 1.32;
  letter-spacing: -0.012em;
  text-wrap: pretty;
}

/* Email on the first row (the hover-only copy button just left of it, in the open space),
   Instagram beneath, everything flush right. */
.studio-contact {
  display: grid;
  grid-template-columns: auto auto;
  justify-content: end;
  align-items: center;
  column-gap: 18px;
  row-gap: 14px;
  margin-left: auto;
}

.studio-contact .studio-email {
  grid-column: 2;
  grid-row: 1;
}

.studio-contact .studio-copy {
  grid-column: 1;
  grid-row: 1;
}

.studio-contact .studio-social {
  grid-column: 1 / -1;
  grid-row: 2;
  justify-self: end;
}

/* Stays on one line when it fits; wraps only as a last resort. */
.studio-email {
  display: inline-block;
  max-width: 100%;
  padding-bottom: 3px;
  overflow-wrap: anywhere;
  background: linear-gradient(currentColor, currentColor) no-repeat 0 100% / 100% 1px;
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: var(--fs-body);
  letter-spacing: -0.012em;
  color: var(--ink);
  text-decoration: none;
  transition: background-size 0.55s var(--ease-out);
}

.studio-email:hover {
  background-size: 0% 1px;
  background-position: 100% 100%;
}

.studio-email:focus-visible {
  outline: 1px solid currentColor;
  outline-offset: 4px;
}

/* Instagram: a quieter line under the email. The handle underlines on hover. */
.studio-social {
  display: flex;
  align-items: center;
  gap: 10px;
  width: max-content;
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: clamp(15px, 1.15vw, 18px);
  letter-spacing: -0.005em;
  color: var(--ink);
  text-decoration: none;
}

.studio-social-icon {
  flex: none;
  width: 1.15em;
  height: 1.15em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
}

.studio-social-dot {
  fill: currentColor;
  stroke: none;
}

.studio-social-handle {
  padding-bottom: 2px;
  background: linear-gradient(currentColor, currentColor) no-repeat 0 100% / 0% 1px;
  transition: background-size 0.55s var(--ease-out);
}

.studio-social:hover .studio-social-handle,
.studio-social:focus-visible .studio-social-handle {
  background-size: 100% 1px;
}

/* Copy button: added by studio.js; hidden until the contact is hovered or focused. */
.studio-copy {
  padding: 0;
  border: 0;
  background: none;
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: var(--fs-label);
  line-height: 1;
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: var(--ink-soft);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.3s ease, color 0.3s ease;
}

.studio-contact:hover .studio-copy,
.studio-contact:focus-within .studio-copy {
  opacity: 1;
}

.studio-copy:hover {
  color: var(--ink);
}

.studio-copy[hidden] {
  display: none;
}

/* Touch screens (phones, iPads): tapping the email opens Mail, so there's no copy button,
   which would otherwise show permanently with no hover to reveal it. */
@media (hover: none) {
  .studio-copy {
    display: none;
  }
}

.studio-foot {
  display: flex;
  justify-content: space-between;
  margin: 0;
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: var(--fs-label);
  letter-spacing: var(--ls-label);
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* Reveal */

.studio-blurb,
.studio-contact,
.studio-foot {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.9s ease, transform 0.9s var(--ease-out);
}

.panel.is-revealed .studio-blurb {
  opacity: 1;
  transform: none;
  transition-delay: 0.5s;
}

.panel.is-revealed .studio-contact {
  opacity: 1;
  transform: none;
  transition-delay: 0.6s;
}

.panel.is-revealed .studio-foot {
  opacity: 1;
  transform: none;
  transition-delay: 0.75s;
}

/* ---- Contact slide: the studio page inverted ----------------------------------------
   Swapping the colour tokens turns everything above white-on-black. The contact block
   moves to the left, under the headline's left edge, and the email reads larger: it is
   the call to action here. */

.studio--ink {
  --paper: #0e0e0e;
  --ink: #ffffff;
  --ink-soft: rgba(255, 255, 255, 0.58);
  --hair: rgba(255, 255, 255, 0.2);
}

/* The call to action is set off from the statement by a pause above it and a heavy rule
   beneath it, the same underline language as the email link. Both are measured in its own
   size, so they scale with the fit. The rule sits on .fit-inner so it rises in with the words. */
.contact-cta {
  margin-top: 0.3em;
  color: inherit;
  text-decoration: none;
  transition: opacity 0.4s ease;
}

.contact-cta .fit-inner {
  --rule: max(2px, 0.045em);
  position: relative;
  padding-bottom: calc(0.05em + var(--rule));
}

/* Starts where the ink starts (studio.js gives each fitted line its --ink-left), so the
   rule is flush with the type and the column, not with the first glyph's sidebearing. */
.contact-cta .fit-inner::after {
  content: "";
  position: absolute;
  left: var(--ink-left, 0);
  right: 0;
  bottom: 0;
  height: var(--rule);
  background: currentColor;
}

.studio-name.is-stacked .contact-cta {
  margin-top: 0;
}

.studio-name.is-stacked .contact-cta .fit-word {
  margin-top: 0.34em;
}

@media (hover: hover) {
  .contact-cta:hover {
    opacity: 0.6;
  }
}

.contact-cta:focus-visible {
  outline: 1px solid currentColor;
  outline-offset: 6px;
}

.studio--ink .studio-contact {
  justify-content: start;
  margin-left: 0;
}

.studio--ink .studio-contact .studio-email {
  grid-column: 1;
  font-size: clamp(22px, 2.1vw, 34px);
}

.studio--ink .studio-contact .studio-copy {
  grid-column: 2;
}

.studio--ink .studio-contact .studio-social {
  justify-self: start;
}

/* Phones: one column, four-line name, shorter footer. */
@media (max-width: 719px) and (min-height: 501px) {
  /* Bottom room for the fixed scroll cue, which sits above the home indicator. */
  .studio {
    padding-bottom: calc(var(--gutter) + 52px + env(safe-area-inset-bottom));
  }

  .studio-name {
    width: 100%;
  }

  .studio-grid {
    flex-direction: column;
    gap: 20px;
  }

  .studio-blurb {
    flex: none;
    max-width: none;
  }

  /* Left-aligned under the blurb. Tapping the email already opens Mail, so the copy
     button is redundant on a phone; the footer only costs height the name could use. */
  .studio-contact {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    margin-left: 0;
  }

  .studio-foot,
  .studio-copy {
    display: none;
  }

  /* The contact slide is the last panel: no scroll cue to clear, so the footer returns. */
  .studio--ink {
    padding-bottom: calc(var(--gutter) + env(safe-area-inset-bottom));
  }

  .studio--ink .studio-foot {
    display: flex;
  }
}

/* Short landscape screens: tighten the spacing so the name and grid fit. */
@media (max-height: 620px) and (min-width: 720px) {
  .studio {
    gap: 16px;
    padding-top: calc(var(--header-h) + 0.5vh);
    padding-bottom: calc(var(--gutter) + 48px);
  }

  .studio-grid {
    padding-top: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html:not(.force-motion) .fit-inner,
  html:not(.force-motion) .studio-blurb,
  html:not(.force-motion) .studio-contact,
  html:not(.force-motion) .studio-foot {
    transform: none;
    transition: none;
  }

  html:not(.force-motion) .studio-blurb,
  html:not(.force-motion) .studio-contact,
  html:not(.force-motion) .studio-foot {
    opacity: 1;
  }

  html:not(.force-motion) .studio-grid::before {
    transform: none;
    transition: none;
  }

  html:not(.force-motion) .studio-email,
  html:not(.force-motion) .studio-copy {
    transition: none;
  }
}
