/* TOBIRA shared primitives — approved Figma V1.1 component contracts. */

/* Brand / Door Mark
 * Canonical source grid: 120 × 164
 * Header: 22 px wide · Display: 76 px wide
 */
.tobira-door-svg {
  display: block;
  height: auto;
  overflow: visible;
}

.tobira-door-svg--header { width: 22px; }
.tobira-door-svg--display { width: 76px; }

.tobira-door-frame {
  fill: none;
  stroke: currentColor;
}

.tobira-door-leaf { fill: currentColor; }
.tobira-door-knob { fill: var(--tobira-accent); }

@media (prefers-reduced-motion: reduce) {
  .tobira-door-leaf,
  .tobira-door-knob {
    transition: none !important;
  }
}

/* Brand / Atelier Mark — the shutter warehouse
 * Canonical source grid: 64 × 64 · Header: 27 px
 * Closed it is a line drawing like its neighbours; on hover the walls
 * take paper, the shutter takes the accent and rolls up — the same
 * "a door opens" grammar as the door and shelf marks.
 */
.tobira-atelier-glyph {
  display: block;
  width: 27px;
  height: 27px;
  overflow: visible;
}

.tobira-atelier-roof {
  fill: none;
  stroke: var(--tobira-ink);
  stroke-width: 4;
  stroke-linejoin: round;
}

.tobira-atelier-body {
  fill: var(--tobira-bg-deep);
  stroke: var(--tobira-ink);
  stroke-width: 4;
  stroke-linejoin: round;
  transition: fill 190ms ease;
}

.tobira-atelier-opening {
  fill: var(--tobira-bg-deep);
  stroke: var(--tobira-ink);
  stroke-width: 4;
  stroke-linejoin: round;
}

.tobira-atelier-shutter {
  transform-box: fill-box;
  transform-origin: center top;
  transition: transform 190ms cubic-bezier(.23, 1, .32, 1);
}

.tobira-atelier-shutter-leaf {
  fill: var(--tobira-bg-deep);
  stroke: var(--tobira-ink);
  stroke-width: 4;
  stroke-linejoin: round;
  transition: fill 190ms ease;
}

.tobira-atelier-slats {
  fill: none;
  stroke: var(--tobira-ink);
  stroke-width: 4;
  transition: stroke 190ms ease;
}

/* On the paper island the walls speak in ink: dark roofline and dark
   silhouette, with the shutter's paper lines carved into it — the same
   inversion the door and shelf marks get inside the island. */
.tobira-door-island .tobira-atelier-roof,
.tobira-door-island .tobira-atelier-body {
  stroke: var(--tobira-bg-deep);
}

@media (hover: hover) and (pointer: fine) {
  .tobira-atelier-control:hover .tobira-atelier-body,
  .tobira-atelier-control:focus-visible .tobira-atelier-body {
    fill: var(--tobira-paper);
  }
  .tobira-atelier-control:hover .tobira-atelier-shutter,
  .tobira-atelier-control:focus-visible .tobira-atelier-shutter {
    transform: scaleY(.24);
  }
  .tobira-atelier-control:hover .tobira-atelier-shutter-leaf,
  .tobira-atelier-control:focus-visible .tobira-atelier-shutter-leaf {
    fill: var(--tobira-accent);
    stroke: var(--tobira-accent);
  }
  .tobira-atelier-control:hover .tobira-atelier-slats,
  .tobira-atelier-control:focus-visible .tobira-atelier-slats {
    stroke: var(--tobira-bg-deep);
  }
}

@media (prefers-reduced-motion: reduce) {
  .tobira-atelier-shutter,
  .tobira-atelier-shutter-leaf,
  .tobira-atelier-body,
  .tobira-atelier-slats {
    transition: none !important;
  }
}

/* Action / Shelf
 * Canonical source grid: 64 × 64
 * Targets: Header 30 · Control 40 · Touch 44
 */
.tobira-shelf-control {
  display: grid;
  flex: 0 0 auto;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: var(--tobira-radius-full);
  color: var(--tobira-ink);
  scale: 1;
  transition:
    scale 100ms var(--tobira-ease),
    background 150ms ease;
}

.tobira-shelf-control--header {
  width: var(--tobira-control-icon-sm);
  height: var(--tobira-control-icon-sm);
  background: transparent;
}

.tobira-shelf-control--control {
  width: var(--tobira-control-icon-md);
  height: var(--tobira-control-icon-md);
  background: var(--tobira-surface);
}

.tobira-shelf-control--touch {
  width: var(--tobira-control-icon-touch);
  height: var(--tobira-control-icon-touch);
  background: var(--tobira-surface);
}

.tobira-shelf-control[aria-pressed="true"]:not(.tobira-shelf-control--header) {
  background: var(--tobira-surface-warm);
}

.tobira-shelf-control:active { scale: .96; }

.tobira-shelf-glyph {
  display: block;
  width: 24px;
  height: 24px;
  overflow: visible;
}

.tobira-shelf-control--header .tobira-shelf-glyph {
  width: 27px;
  height: 27px;
}

.tobira-shelf-cabinet {
  fill: var(--tobira-bg-deep);
  stroke: var(--tobira-ink);
  stroke-width: 2;
  stroke-linejoin: round;
}

.tobira-shelf-frame-lines {
  fill: none;
  stroke: var(--tobira-ink);
  stroke-width: 2;
  stroke-linejoin: round;
}

.tobira-shelf-door {
  transform-box: fill-box;
  transform-origin: left center;
  transition:
    transform 140ms cubic-bezier(.23, 1, .32, 1)
    var(--tobira-shelf-close-delay, 0ms);
}

.tobira-shelf-door--top {
  --tobira-shelf-open-delay: 0ms;
  --tobira-shelf-close-delay: 70ms;
}

.tobira-shelf-door--middle {
  --tobira-shelf-open-delay: 55ms;
  --tobira-shelf-close-delay: 35ms;
}

.tobira-shelf-door--bottom {
  --tobira-shelf-open-delay: 110ms;
  --tobira-shelf-close-delay: 0ms;
}

.tobira-shelf-door-leaf {
  fill: var(--tobira-ink);
  stroke: var(--tobira-bg);
  stroke-width: 2;
  stroke-linejoin: round;
}

.tobira-shelf-handle { fill: var(--tobira-bg); }

.tobira-shelf-control[aria-pressed="true"] .tobira-shelf-door {
  transform: perspective(90px) rotateY(-52deg);
  transition-duration: 190ms;
  transition-delay: var(--tobira-shelf-open-delay);
}

@media (hover: hover) and (pointer: fine) {
  .tobira-shelf-control--header:hover .tobira-shelf-door,
  .tobira-shelf-control--header:focus-visible .tobira-shelf-door {
    transform: perspective(90px) rotateY(-52deg);
    transition-duration: 190ms;
    transition-delay: var(--tobira-shelf-open-delay);
  }
}

@media (prefers-reduced-motion: reduce) {
  .tobira-shelf-control { transition: none; }
  .tobira-shelf-control:active { opacity: .78; scale: 1; }
  .tobira-shelf-door { transition: none; }
}

/* Action / Icon Button
 * Fixed targets: Control 40 · Touch 44. The exported Figma assets sit on a
 * stable 20 px icon canvas; press feedback never changes the hit target.
 */
.tobira-icon-button {
  display: grid;
  flex: 0 0 auto;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: var(--tobira-radius-full);
  color: var(--tobira-ink);
  cursor: pointer;
  scale: 1;
  transition:
    scale 160ms var(--tobira-ease),
    background-color 180ms var(--tobira-ease),
    color 180ms var(--tobira-ease);
}

.tobira-icon-button--control {
  width: var(--tobira-control-icon-md);
  height: var(--tobira-control-icon-md);
}

.tobira-icon-button--touch {
  width: var(--tobira-control-icon-touch);
  height: var(--tobira-control-icon-touch);
}

.tobira-icon-button--quiet { background: transparent; }
.tobira-icon-button--filled { background: var(--tobira-surface); }

.tobira-icon-button > img,
.tobira-icon-button > svg {
  display: block;
  width: 20px;
  height: 20px;
  pointer-events: none;
}

.tobira-icon-button:hover { background: var(--tobira-surface); }
.tobira-icon-button--filled:hover { background: var(--tobira-surface-warm); }
.tobira-icon-button:active {
  scale: .94;
  transition-duration: 110ms;
  transition-timing-function: cubic-bezier(.23, 1, .32, 1);
}
.tobira-icon-button:focus-visible {
  outline: 2px solid var(--tobira-accent);
  outline-offset: 3px;
}

/* Utility / Key Cursor
 * Direct pointer tracking is implemented in gallery-unlock.js. The wrapper
 * stays 28 px while only the exported 24 px key glyph responds to press.
 */
html.has-gallery-smooth-cursor,
html.has-gallery-smooth-cursor * {
  cursor: none !important;
}

.gallery-smooth-cursor {
  position: fixed;
  z-index: 2147483646;
  top: 0;
  left: 0;
  width: 28px;
  height: 28px;
  color: var(--tobira-paper);
  opacity: 0;
  pointer-events: none;
  transform: translate3d(-60px, -60px, 0);
  will-change: transform;
}

.gallery-smooth-cursor.is-visible { opacity: 1; }
.gallery-smooth-cursor.is-light-surface { color: var(--tobira-bg); }
.gallery-smooth-cursor .gallery-cursor-key {
  position: absolute;
  top: 2px;
  left: 2px;
  display: block;
  width: 24px;
  height: 24px;
  scale: 1;
  transform-origin: center;
  transition: scale 120ms cubic-bezier(.23, 1, .32, 1);
}
.gallery-smooth-cursor.is-pressed .gallery-cursor-key { scale: .86; }

@media (prefers-reduced-motion: reduce) {
  .tobira-icon-button { transition: none; }
  .tobira-icon-button:active { opacity: .78; scale: 1; }
  .gallery-smooth-cursor .gallery-cursor-key { transition: none; }
}
