/* /clock/?c=... の再現性契約に直結する凍結領域。
   既存URLの見た目を変えるため、値の変更は互換ガード(tests/template-compat.test.mjs)と
   オーナー承認なしに行わないこと。 */

.clock-page {
  --clock-visual-safe-inset: 18px;
  width: 100vw;
  height: 100vh;
  margin: 0;
  overflow: hidden;
  background: transparent;
}

.clock-page #clockRoot {
  display: inline-grid;
  place-items: start;
  width: max-content;
  height: max-content;
  margin: 0;
  padding: var(--clock-visual-safe-inset);
  overflow: visible;
}

.clock-widget {
  --clock-font: "Noto Sans JP";
  --clock-text: #ffffff;
  --clock-bg: rgba(31, 41, 55, 0.72);
  --clock-border: rgba(255, 255, 255, 0.35);
  --clock-border-width: 1px;
  --clock-radius: 18px;
  --clock-padding-x: 24px;
  --clock-padding-y: 14px;
  --clock-font-size: 44px;
  --clock-date-size: 16px;
  --clock-label-size: 14px;
  --clock-letter-spacing: 0.5px;
  --clock-line-height: 1.08;
  --clock-font-weight: 700;
  --clock-gap: 6px;
  --clock-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  --clock-stroke-color: #000000;
  --clock-stroke-width: 0px;
  display: inline-flex;
  align-items: center;
  gap: var(--clock-gap);
  width: max-content;
  max-width: 100%;
  padding: var(--clock-padding-y) var(--clock-padding-x);
  border: var(--clock-border-width) solid var(--clock-border);
  border-radius: var(--clock-radius);
  background: var(--clock-bg);
  color: var(--clock-text);
  font-family: var(--clock-font), var(--fallback-fonts);
  font-weight: var(--clock-font-weight);
  letter-spacing: var(--clock-letter-spacing);
  line-height: var(--clock-line-height);
  text-shadow: var(--clock-shadow);
  white-space: nowrap;
}

.clock-widget[data-label-position="top"],
.clock-widget[data-label-position="bottom"],
.clock-widget[data-label-position="hidden"] {
  flex-direction: column;
}

.clock-widget[data-label-position="bottom"] .clock-label {
  order: 2;
}

.clock-widget[data-label-position="left"] {
  flex-direction: row;
}

.clock-widget[data-label-position="right"] {
  flex-direction: row;
}

.clock-widget[data-label-position="right"] .clock-label {
  order: 2;
}

.clock-label {
  font-size: var(--clock-label-size);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  -webkit-text-stroke: calc(var(--clock-stroke-width) * 0.35) var(--clock-stroke-color);
  paint-order: stroke fill;
}

.clock-main {
  display: grid;
  justify-items: center;
  gap: calc(var(--clock-gap) * 0.55);
  min-width: 0;
}

.clock-widget[data-label-position="left"] .clock-main,
.clock-widget[data-label-position="right"] .clock-main {
  justify-items: start;
}

.clock-date-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55em;
  font-size: var(--clock-date-size);
  font-weight: 700;
  -webkit-text-stroke: calc(var(--clock-stroke-width) * 0.45) var(--clock-stroke-color);
  paint-order: stroke fill;
}

.clock-time {
  display: inline-block;
  font-size: var(--clock-font-size);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  -webkit-text-stroke: var(--clock-stroke-width) var(--clock-stroke-color);
  paint-order: stroke fill;
}

/* 各数字を等幅スロットにして、配信中に時刻が変わっても外枠とコロン位置を固定する。
   1ch は数字「0」の送り幅。フォントが変わってもサイズ変更には連動する。 */
.clock-digit {
  display: inline-block;
  width: 1ch;
  text-align: center;
}

.clock-sep {
  display: inline-block;
  text-align: center;
}

.clock-date-row[hidden],
.clock-label[hidden] {
  display: none;
}

/* アナログ時計(SVG)。width/height は SVG 属性で指定されるため、
   ブロック要素として中身を縮めずに表示する。針の回転は SVG の transform 属性で行う。 */
.clock-analog {
  display: block;
}

.clock-analog text {
  user-select: none;
}

/* パタパタ(フリップ)時計。各カードを上下2枚の面に分け、上半分(古い値)が手前へ
   折れ、続いて下半分(新しい値)が起き上がる、本物のスプリットフラップ動作(独自実装)。 */
.clock-flip {
  display: inline-flex;
  align-items: center;
  gap: 0.16em;
  font-family: var(--flip-font), var(--fallback-fonts);
  font-size: var(--flip-size);
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.flip-card {
  position: relative;
  display: inline-block;
  width: 0.86em;
  height: 1.34em;
  perspective: 280px;
  filter: drop-shadow(0 0.08em 0.12em rgba(0, 0, 0, 0.28));
}

.flip-half {
  position: absolute;
  left: 0;
  right: 0;
  height: 0.67em;
  overflow: hidden;
  background: var(--flip-card-bg);
  color: var(--flip-ink);
  box-sizing: border-box;
}

.flip-half b {
  position: absolute;
  left: 0;
  right: 0;
  height: 1.34em;
  line-height: 1.34em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.flip-top {
  top: 0;
  border: var(--flip-border-width) solid var(--flip-border);
  border-bottom: 1px solid rgba(0, 0, 0, 0.34);
  border-radius: var(--flip-radius) var(--flip-radius) 0 0;
}

.flip-top b {
  top: 0;
}

.flip-bottom {
  bottom: 0;
  border: var(--flip-border-width) solid var(--flip-border);
  border-top: none;
  border-radius: 0 0 var(--flip-radius) var(--flip-radius);
}

.flip-bottom b {
  top: -0.67em;
}

.flip-flap-top {
  z-index: 3;
  transform-origin: bottom center;
  transform: rotateX(0deg);
}

.flip-flap-bottom {
  z-index: 3;
  transform-origin: top center;
  transform: rotateX(90deg);
}

.flip-card.is-flipping .flip-flap-top {
  animation: flip-fold-top 0.56s ease-in forwards;
}

.flip-card.is-flipping .flip-flap-bottom {
  animation: flip-fold-bottom 0.56s ease-out forwards;
}

@keyframes flip-fold-top {
  0% {
    transform: rotateX(0deg);
  }
  50%,
  100% {
    transform: rotateX(-90deg);
  }
}

@keyframes flip-fold-bottom {
  0%,
  50% {
    transform: rotateX(90deg);
  }
  100% {
    transform: rotateX(0deg);
  }
}

.flip-sep {
  color: var(--flip-ink);
  font-size: 0.7em;
  font-weight: 800;
}

@media (prefers-reduced-motion: reduce) {
  .flip-card.is-flipping .flip-flap-top,
  .flip-card.is-flipping .flip-flap-bottom {
    animation-duration: 0.01ms;
  }
}

.template-minimal-clear {
  backdrop-filter: none;
}

.template-neon-hud {
  text-transform: uppercase;
}

/* 作り込みの意匠(配信者向け素材の質感): カードの奥行き、形の個性、
   テンプレートごとのワンポイント。URLのtemplate値からclassで再現される。
   --clock-bg などの利用者調整値は土台として残し、装飾は重ねるだけにする。 */

/* 定番: 軽い奥行きと上面ハイライトでフラットさを解消 */
.template-mono-compact,
.template-minimal-clear {
  box-shadow: 0 7px 18px rgba(31, 36, 48, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

/* Studio Live: 下げパネル形 + 赤いLIVEバッジ(点滅ドット) + 時刻下線 */
.template-studio-live {
  position: relative;
  border-radius: 7px 7px 18px 18px;
  box-shadow: 0 9px 24px rgba(22, 24, 29, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.template-studio-live .clock-time {
  border-bottom: 3px solid #ff3b5c;
  padding-bottom: 3px;
}

.template-studio-live .clock-label {
  position: relative;
  padding: 2px 11px 2px 22px;
  border-radius: 6px;
  background: #ff3b5c;
  color: #ffffff;
  letter-spacing: 0.16em;
}

.template-studio-live .clock-label::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 9px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ffffff;
  transform: translateY(-50%);
  animation: clock-live-pulse 1.6s ease-in-out infinite;
}

/* Milk Tea: 温かみのある奥行き */
.template-milk-tea {
  box-shadow: 0 8px 20px rgba(150, 110, 80, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

/* Sakura: 桜の花びらワンポイント + 桜色の奥行き */
.template-sakura {
  position: relative;
  box-shadow: 0 8px 20px rgba(255, 150, 180, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.template-sakura::after {
  content: "";
  position: absolute;
  top: -9px;
  right: 12px;
  width: 22px;
  height: 22px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg fill='%23ff9ec0'%3E%3Cellipse cx='12' cy='4' rx='3.2' ry='4.2'/%3E%3Cellipse cx='19' cy='9.5' rx='3.2' ry='4.2' transform='rotate(72 19 9.5)'/%3E%3Cellipse cx='16' cy='18' rx='3.2' ry='4.2' transform='rotate(144 16 18)'/%3E%3Cellipse cx='8' cy='18' rx='3.2' ry='4.2' transform='rotate(216 8 18)'/%3E%3Cellipse cx='5' cy='9.5' rx='3.2' ry='4.2' transform='rotate(288 5 9.5)'/%3E%3Ccircle cx='12' cy='12' r='2.4' fill='%23ffd24d'/%3E%3C/g%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
}

/* Pastel Pop: 3色ドットのワンポイント */
.template-pastel-pop {
  position: relative;
  box-shadow: 0 8px 20px rgba(255, 140, 200, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.85);
}

.template-pastel-pop::after {
  content: "";
  position: absolute;
  top: 10px;
  right: 13px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ff9ed2;
  box-shadow: -11px 0 0 #ffd24d, -22px 0 0 #7fd6ee;
}

/* Soda: 泡のワンポイント + 艶 */
.template-soda {
  position: relative;
  box-shadow: 0 8px 20px rgba(60, 200, 230, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.template-soda::after {
  content: "";
  position: absolute;
  top: 9px;
  right: 12px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: -10px 6px 0 -1px rgba(255, 255, 255, 0.8), -4px 13px 0 -2px rgba(255, 255, 255, 0.7);
}

/* Night Studio: 暗い奥行き + 枠付きLIVEバッジ + シアン下線 */
.template-night-studio {
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.42), 0 0 0 1px rgba(95, 208, 224, 0.22);
}

.template-night-studio .clock-time {
  border-bottom: 2px solid #5fd0e0;
  padding-bottom: 3px;
}

.template-night-studio .clock-label {
  padding: 1px 10px;
  border: 2px solid currentColor;
  border-radius: 6px;
  letter-spacing: 0.18em;
}

/* Neon HUD: 角ブラケット + 走査線 */
.template-neon-hud {
  position: relative;
  box-shadow: 0 0 18px rgba(47, 255, 230, 0.25);
}

.template-neon-hud::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 14px;
  height: 14px;
  border-top: 2px solid #48ffe2;
  border-left: 2px solid #48ffe2;
}

.template-neon-hud::after {
  content: "";
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 14px;
  height: 14px;
  border-right: 2px solid #48ffe2;
  border-bottom: 2px solid #48ffe2;
}

/* Aqua Deck: 上面アクセント帯 + 水色バッジ */
.template-aqua-deck {
  position: relative;
  overflow: hidden;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}

.template-aqua-deck::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, #aedded, #5fd0e0);
}

.template-aqua-deck .clock-label {
  padding: 2px 11px;
  border-radius: 6px;
  background: #aedded;
  color: #1b3a45;
  letter-spacing: 0.16em;
}

@keyframes clock-live-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.25;
  }
}

@media (prefers-reduced-motion: reduce) {
  .template-studio-live .clock-label::before {
    animation: none;
  }
}
