/* css/tile.css — Solari split-flap tile */

:root {
  --tile-body:     #0b0b0b;
  --tile-char:     #f2e8cf;
  --tile-seam:     #000000;
  --tile-highlight: rgba(255,255,255,0.04);
  --flip-step-ms:  50ms;
  --flip-land-ms:  120ms;
}

.tile {
  --aspect-w: 3;
  --aspect-h: 4;
  position: relative;
  width: var(--tile-size, 56px);
  aspect-ratio: var(--aspect-w) / var(--aspect-h);
  perspective: 500px;
  font-family: var(--tile-font, 'Antonio'), 'Oswald', 'Barlow Condensed', system-ui, sans-serif;
  font-weight: 700;
  color: var(--tile-char);
}

.tile .half {
  position: absolute;
  left: 0;
  right: 0;
  height: 50%;
  background: var(--tile-body);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px #000;
  display: flex;
  justify-content: center;
}

.tile .half.top {
  top: 0;
  border-radius: 2px 2px 0 0;
  align-items: flex-end;
  padding-bottom: 2%;
  box-shadow:
    inset 0 1px 0 var(--tile-highlight),
    inset 0 0 0 1px #000;
}

.tile .half.bot {
  bottom: 0;
  border-radius: 0 0 2px 2px;
  align-items: flex-start;
  padding-top: 2%;
  box-shadow:
    inset 0 -1px 0 rgba(0,0,0,0.8),
    inset 0 0 0 1px #000;
}

.tile .half .glyph {
  font-size: calc(var(--tile-size, 56px) * 0.96);
  line-height: 1;
  letter-spacing: 0;
  user-select: none;
}

.tile .half.top .glyph { transform: translateY(50%); }
.tile .half.bot .glyph { transform: translateY(-50%); }

.tile .seam {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(50% - 1px);
  height: 1.5px;
  background: var(--tile-seam);
  box-shadow: 0 -0.3px 0 var(--tile-highlight);
  z-index: 5;
  pointer-events: none;
}

.tile .flap {
  position: absolute;
  left: 0;
  right: 0;
  height: 50%;
  background: var(--tile-body);
  z-index: 3;
  overflow: hidden;
  will-change: transform;
  backface-visibility: hidden;
  transform-origin: bottom center;
  top: 0;
  border-radius: 2px 2px 0 0;
  box-shadow: inset 0 1px 0 var(--tile-highlight), inset 0 0 0 1px #000;
}

.tile .flap .face {
  position: absolute;
  left: 0; right: 0; top: 0; bottom: 0;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  padding-bottom: 2%;
  backface-visibility: hidden;
  overflow: hidden;
}

.tile .flap .face.back {
  transform: rotateX(180deg);
  align-items: flex-start;
  padding-bottom: 0;
  padding-top: 2%;
}

.tile .flap .face .glyph {
  font-size: calc(var(--tile-size, 56px) * 0.96);
  line-height: 1;
  color: var(--tile-char);
}

.tile .flap .face.front .glyph { transform: translateY(50%); }
.tile .flap .face.back  .glyph { transform: translateY(-50%); }

/* Flip primitive — 0° → -180° around seam */
.tile .flap.step-running { animation: flap-step var(--flip-step-ms) ease-in-out forwards; }
.tile .flap.land-running { animation: flap-step var(--flip-land-ms) cubic-bezier(.3,0,.2,1.1) forwards; }

@keyframes flap-step {
  0%   { transform: rotateX(0deg); }
  50%  { transform: rotateX(-90deg); }
  100% { transform: rotateX(-180deg); }
}

/* Color tiles — scope the glyph-hide to the static halves only.
   Flap glyphs must stay visible so the target character appears during a
   color→char transition's back face. */
.tile.color .half.top { background: var(--tile-color); }
.tile.color .half.bot { background: var(--tile-color); }
.tile.color .half .glyph { display: none; }
