/* ==========================================================================
   The Tobo hero (home, top): Tobo in the colour room, wearing the frames.
   The room (wall, light pool, floor, vignette, grain) and the words are plain
   CSS, so the section looks finished before js/herotobo.js arrives. The module
   adds the canvas, the label card and the colour dots, and moves the wall
   through --th-hi / --th-wall / --th-lo (registered, so the colour glides).
   ========================================================================== */
@property --th-hi { syntax: "<color>"; inherits: true; initial-value: #EBE7E2; }
@property --th-wall { syntax: "<color>"; inherits: true; initial-value: #DAD5CE; }
@property --th-lo { syntax: "<color>"; inherits: true; initial-value: #C4BEB8; }

.th {
  --th-hi: #EBE7E2; --th-wall: #DAD5CE; --th-lo: #C4BEB8;  /* the gallery's warm stone; the module tints it per frame */
  --th-x: 67%; --th-y: 27%;                                  /* the light pool, behind Tobo's head */
  --th-ink2: #34344F;                                        /* small type on the wall: AA on every room tone */
  position: relative; isolation: isolate; overflow: hidden;
  display: flex; align-items: center;
  height: calc(100vh - var(--hdr)); height: calc(100svh - var(--hdr));
  min-height: 560px; max-height: 960px;
  background: var(--th-wall);
  background:
    radial-gradient(ellipse 42% 58% at var(--th-x) var(--th-y), var(--th-hi) 0%, transparent 74%),
    linear-gradient(180deg, var(--th-wall) 0%, var(--th-wall) 56%, var(--th-lo) 100%);
  border-bottom: 2px solid var(--ink);
  transition: --th-hi 1.6s var(--ease), --th-wall 1.6s var(--ease), --th-lo 1.6s var(--ease);
}
/* a soft vignette, centred on Tobo */
.th::before {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background: radial-gradient(ellipse 125% 105% at var(--th-x) 40%, transparent 50%, rgba(40, 31, 18, .2) 100%);
}
/* film grain, over the room and Tobo, under the words */
.th::after {
  content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none; opacity: .5;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .16  0 0 0 0 .13  0 0 0 0 .09  0 0 0 -1.6 1.02'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23g)' opacity='.18'/%3E%3C/svg%3E") 0 0 / 200px 200px;
}

/* ---------------------------------------------------------------- the words */
.th-copy {
  position: relative; z-index: 4; width: 100%; max-width: var(--maxw); margin: 0 auto;
  padding: 0 var(--pad) 3.5vh; pointer-events: none;
}
.th-copy > :not(.th-ctas), .th-ctas > * { pointer-events: auto; }
/* each line of words only as wide as its words: a full-width caps line ran across Tobo's face
   and swallowed the hover, the click and the drag there */
.th-copy > p, .th-copy > h1 { width: fit-content; }
.th-copy .caps { color: var(--th-ink2); margin-bottom: 18px; }
.th-copy h1 { font-size: clamp(44px, 5.5vw, 94px); max-width: 6.4em; }
.th-copy .lede { color: var(--th-ink2); max-width: 27ch; margin-top: 20px; font-size: clamp(17px, 1.5vw, 20px); }
.th-ctas { margin-top: 30px; width: max-content; max-width: 100%; }

/* ------------------------------------------------- Tobo (canvas or drawing) */
.th-stage { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.th-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; opacity: 0; transition: opacity 1.1s var(--ease); }
.th-canvas.on { opacity: 1; }
.th-draw { position: absolute; inset: 0; opacity: 0; transition: opacity .9s var(--ease); }
.th-draw.on { opacity: 1; }
.th-draw svg { position: absolute; display: block; overflow: visible; }
.th-specs { transition: opacity .18s ease; }
.th-specs.out { opacity: 0; }
/* the slow light that crosses the wall (the module runs it, every 8 s) */
.th-sweep { position: absolute; inset: 0; overflow: hidden; transition: opacity .6s var(--ease); }
.th-paused .th-sweep { opacity: 0; }
.th-sweep i {
  position: absolute; top: -30%; bottom: -30%; left: 0; width: 34%;
  transform: translateX(-100%) skewX(-16deg);
  background: linear-gradient(90deg, rgba(255, 251, 242, 0), rgba(255, 251, 242, .12) 26%, rgba(255, 251, 242, .3) 44%, rgba(255, 251, 242, .4) 50%, rgba(255, 251, 242, .3) 56%, rgba(255, 251, 242, .12) 74%, rgba(255, 251, 242, 0));
}
/* where hands land on Tobo: never over the words, the label or the dots */
.th-hit { position: absolute; z-index: 3; touch-action: pan-y; -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; }
.th-hit.over, .th-flat .th-hit { cursor: pointer; }
.th-hit.drag { cursor: grabbing; }

/* ------------------------------------------------ the label card (bottom right) */
.th-dock { display: contents; }
.th-label {
  position: absolute; z-index: 5; width: 286px;
  right: max(var(--pad), calc((100% - var(--maxw)) / 2 + var(--pad)));
  bottom: clamp(22px, 5.4vh, 54px);
  perspective: 1200px;
  animation: thIn .8s .1s var(--ease) both;
}
.th-lift .th-label { bottom: calc(clamp(16px, 3.4vh, 34px) + 50px); }
.th-card { display: grid; transform-style: preserve-3d; transition: transform .72s cubic-bezier(.45, .05, .3, 1); }
.th-face {
  grid-area: 1 / 1; display: flex; flex-direction: column; min-height: 216px;
  padding: 15px 18px 13px; background: #F8F5EF; color: var(--ink);
  border: 1px solid rgba(16, 16, 46, .14);
  box-shadow: 0 26px 48px -20px rgba(42, 32, 16, .38), 0 2px 6px rgba(42, 32, 16, .07);
  -webkit-backface-visibility: hidden; backface-visibility: hidden;
}
.th-back { transform: rotateY(180deg); }
.th-k { color: #5F5D7A; font-size: 10.5px; }
.th-name {                                  /* one line, however long the name: --th-em is its width in ems */
  margin: 10px 0 0; white-space: nowrap; font-weight: 900; font-variation-settings: "wdth" 118;
  font-size: min(25px, calc(248px / var(--th-em, 8))); line-height: 1; letter-spacing: -.02em; text-transform: uppercase;
}
.th-sub { margin: 5px 0 0; font-family: var(--f-mono); font-size: 12.5px; line-height: 1.2; color: #5F5D7A; }
.th-does {
  margin: 10px 0 0; font-family: var(--f-hand); color: #C42B22; font-size: 16.5px; line-height: 1.25;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.th-row { margin: auto 0 0; padding-top: 12px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.th-row .mono { font-size: 14.5px; white-space: nowrap; }
.th-row .link { padding: 6px 0; text-align: right; }

/* ------------------------------------------------- the colour dots (under Tobo) */
.th-sw {
  position: absolute; z-index: 5; left: var(--th-sx, 67%); bottom: clamp(16px, 3.4vh, 34px);
  translate: -50% 0; display: flex; align-items: center; gap: 4px;
  animation: thIn .8s .25s var(--ease) both;
}
.th-try { font-family: var(--f-hand); color: #3A3730; font-size: 17px; line-height: 1; margin-right: 6px; white-space: nowrap; }
.th-dots { display: flex; }
.th-dot {
  flex: 0 1 26px; width: 26px; min-width: 18px; height: 26px; padding: 0; border: 0; border-radius: 50%;
  background: none; display: grid; place-items: center; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.th-dot i {
  width: 15px; height: 15px; border-radius: 50%;
  box-shadow: 0 0 0 1.5px rgba(250, 248, 242, .95), 0 0 0 2.5px rgba(16, 16, 46, .3);
  transition: transform .3s var(--ease), box-shadow .3s;
}
.th-dot:hover i { transform: scale(1.18); }
.th-dot[aria-pressed="true"] i { transform: scale(1.14); box-shadow: 0 0 0 2px #FAF8F2, 0 0 0 3.5px var(--ink); }
.th-dot:focus-visible, .th-pause:focus-visible { outline: 2.5px solid var(--margin); outline-offset: 1px; border-radius: 50%; }
.th-pause {
  flex: none; width: 26px; height: 26px; margin-left: 6px; padding: 0; border-radius: 50%;
  border: 1.5px solid rgba(16, 16, 46, .55); background: rgba(250, 248, 242, .45); color: var(--ink);
  display: grid; place-items: center; cursor: pointer;
}
.th-pause svg { width: 12px; height: 12px; }
.th-pause .ps { fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.th-pause .pl { fill: currentColor; display: none; }
.th-pause.on .ps { display: none; }
.th-pause.on .pl { display: inline; }
.th-pause:hover { background: #FAF8F2; }

@media (min-width: 701px) and (max-width: 999px) { .th-try { display: none; } }

@keyframes thIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------------- phones */
/* words on top, Tobo below, the dots and a compact label at the foot: one screen */
@media (max-width: 700px) {
  .th { --th-x: 50%; --th-y: 52%; align-items: flex-start; min-height: 600px; max-height: 900px; }
  .th::before { background: radial-gradient(ellipse 120% 80% at 50% 56%, transparent 52%, rgba(40, 31, 18, .18) 100%); }
  .th-copy { padding: clamp(18px, 3.2svh, 30px) var(--pad) 0; }
  .th-copy .caps { margin-bottom: 12px; }
  .th-copy h1 { font-size: clamp(40px, 12.4vw, 60px); max-width: 7.2em; }
  .th-copy .lede { font-size: 16px; margin-top: 12px; max-width: 34ch; }
  .th-ctas { margin-top: 18px; gap: 8px; flex-wrap: nowrap; }
  .th-ctas .btn { min-height: 46px; padding: 0 16px; }

  .th-dock {
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    position: absolute; z-index: 5; left: var(--pad); right: var(--pad); bottom: 14px;
  }
  .th-sw, .th-label { position: relative; left: auto; right: auto; bottom: auto; translate: none; }
  .th-sw { width: calc(100% + 12px); justify-content: center; gap: 0; }
  .th-try { display: none; }
  .th-dot { flex: 0 1 24px; width: 24px; height: 28px; }
  .th-pause { position: absolute; right: 0; bottom: calc(100% + 10px); margin: 0; }
  .th-label { width: 100%; perspective: 900px; }
  .th-face { min-height: 0; padding: 10px 14px 9px; }
  .th-k { font-size: 10px; }
  .th-name { margin-top: 6px; font-size: min(22px, calc((100vw - 2 * var(--pad) - 32px) / var(--th-em, 8))); }
  .th-sub, .th-does { display: none; }
  .th-row { padding-top: 4px; }
  .th-row .mono { font-size: 14px; }
}
@media (max-width: 360px) { .th-ctas .btn { padding: 0 12px; letter-spacing: .08em; } }
