/* fonts */
@font-face {
  font-family: "Kiwi Soda";
  src: url("fonts/KiwiSoda.ttf") format("truetype");
  font-display: swap;
}

:root {
  --font-body: "MS Gothic", "ＭＳ ゴシック", "MS PGothic", "Osaka-Mono", "Osaka", monospace;
  --font-title: "Kiwi Soda", var(--font-body);
  --bg: #1f2422;
  --ink: #f4f1e8;
  --muted: #c9c4b4;
  --accent: #e9f27a;
  --accent-ink: #1f2422;
  --line: rgba(255, 255, 255, 0.14);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font-body);
}

.joy, .zoom, .orbit, .gizmo, #diorama {
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* scene */
#diorama {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  touch-action: none;
}

/* watermark */
.corner {
  position: fixed;
  top: 14px;
  right: 20px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: clamp(6px, 1.5vh, 12px);
  pointer-events: none;
  user-select: none;
}

.watermark {
  text-align: right;
  font-family: var(--font-title);
  font-size: clamp(1.6rem, 4vw, 3rem);
  letter-spacing: 0.04em;
  line-height: 0.95;
  color: rgba(255, 255, 255, 0.45);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.55);
}

.counter {
  width: 0;
  min-width: 100%;
  font-family: var(--font-body);
  font-weight: bold;
  line-height: 1;
  white-space: nowrap;
  text-align: center;
  color: rgba(255, 255, 255, 0.45);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.55);
}

.corner img {
  width: 0;
  min-width: 100%;
  height: auto;
  max-height: 10vh;
  object-fit: contain;
  opacity: 0.45;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.55));
}

/* +1 */
.plus {
  position: fixed;
  left: 0;
  top: 0;
  font-family: var(--font-body);
  font-weight: bold;
  font-size: 13px;
  line-height: 1;
  color: rgba(216, 240, 214, 0.8);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  user-select: none;
  will-change: transform, opacity;
}

/* card */
.card {
  position: fixed;
  top: 50%;
  left: clamp(64px, 5vw, 72px);
  transform: translateY(-50%);
  width: min(440px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 24px 26px;
  background:
    linear-gradient(rgba(18, 22, 20, 0.1), rgba(18, 22, 20, 0.1)),
    url("img/chainfence.png") repeat center / 90px auto,
    rgba(18, 22, 20, 0.08);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 1), 0 0 6px rgba(0, 0, 0, 0.9), 0 0 12px rgba(0, 0, 0, 0.7);
  border: 1px solid var(--line);
  border-radius: 0;
  animation: float 7s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(-50%); }
  50%      { transform: translateY(calc(-50% - 6px)); }
}

.card.collapsed #cardBody { display: none; }

@media (min-width: 761px) {
  .card.collapsed { top: auto; bottom: 24px; transform: none; animation-name: float-low; }
}

@keyframes float-low {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

/* title */
.brand { display: flex; justify-content: center; }
.title {
  margin: 0;
  width: 100%;
  display: flex;
  align-items: flex-start;
}
.title img {
  width: 0;
  height: auto;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.8));
}
.title img:nth-child(1) { flex: 400 1 0; }
.title img:nth-child(2) { flex: 301 1 0; }
.title img:nth-child(3) { flex: 471 1 0; }

.card.collapsed { padding: 12px 14px; }
h2 { margin: 1.4em 0 0.5em; font-family: var(--font-title); font-weight: normal; font-size: 1.3rem; color: var(--accent); text-transform: uppercase; letter-spacing: 0.08em; }

p { margin: 0.6em 0; }
.lede { color: var(--muted); margin-top: 1em; }

.header-img {
  width: 100%;
  height: auto;
  border-radius: 0;
  display: block;
  border: 1px solid var(--line);
}

.tags { font-size: 0.85rem; color: var(--muted); }

a { color: var(--ink); }
.contact ul { list-style: none; padding: 0; margin: 0; }
.contact li { margin: 4px 0; }

.hint { margin-top: 1.4em; font-size: 0.8rem; color: var(--muted); opacity: 0.8; }
.credit { margin: 0.4em 0 0; font-size: 0.7rem; color: var(--muted); opacity: 0.7; }
.credit a { color: inherit; }

/* buttons */
.btn {
  display: inline-block;
  margin-top: 4px;
  padding: 10px 18px;
  background: var(--accent);
  color: var(--accent-ink);
  text-shadow: none;
  border-radius: 0;
  font-weight: 700;
  text-decoration: none;
}
.btn:hover { filter: brightness(1.08); }

.hide-btn {
  position: absolute;
  top: 4px;
  right: 6px;
  z-index: 1;
  background: none;
  border: 0;
  padding: 2px 4px;
  color: rgba(216, 240, 214, 0.9);
  font: 16px/1 var(--font-body);
  cursor: pointer;
}
.hide-btn:hover { color: #fff; }

/* joystick */
.joy {
  display: none;
  position: fixed;
  left: 64px;
  bottom: 120px;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  border: 2px solid rgba(216, 240, 214, 0.45);
  background: radial-gradient(circle, rgba(18, 22, 20, 0.3) 0%, rgba(18, 22, 20, 0.15) 65%, rgba(18, 22, 20, 0) 100%);
  box-shadow: 0 0 14px rgba(216, 240, 214, 0.25), inset 0 0 14px rgba(216, 240, 214, 0.25);
  touch-action: none;
  opacity: 0.6;
  transition: opacity 0.35s, visibility 0.35s;
}
.joy.active { opacity: 1; }
.card:not(.collapsed) ~ .joy { opacity: 0; visibility: hidden; pointer-events: none; }

.joy-knob, .orbit-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 72px;
  height: 72px;
  margin: -36px 0 0 -36px;
  background: url("img/ui/joy-knob.png") center / contain no-repeat;
  pointer-events: none;
}

/* zoom */
.zoom {
  position: fixed;
  left: 12px;
  top: 16px;
  bottom: 16px;
  width: 36px;
  cursor: ns-resize;
  border: 6px solid transparent;
  border-image: url("img/ui/zoom-box.png") 14 / 6px stretch;
  touch-action: none;
  opacity: 0.6;
  transition: opacity 0.35s, visibility 0.35s;
}
.zoom.active, .zoom:hover { opacity: 1; }

.zoom-knob {
  position: absolute;
  left: 50%;
  top: 0;
  width: 80px;
  height: 20px;
  margin-left: -40px;
  background: url("img/ui/zoom-knob.png") center / contain no-repeat;
  pointer-events: none;
}

/* orbit */
.orbit {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  border: 2px solid rgba(216, 240, 214, 0.45);
  background: radial-gradient(circle, rgba(18, 22, 20, 0.3) 0%, rgba(18, 22, 20, 0.15) 65%, rgba(18, 22, 20, 0) 100%);
  box-shadow: 0 0 14px rgba(216, 240, 214, 0.25), inset 0 0 14px rgba(216, 240, 214, 0.25);
  cursor: grab;
  touch-action: none;
  opacity: 0.6;
  transition: opacity 0.35s, visibility 0.35s;
}
.orbit:hover, .orbit.active { opacity: 1; }
.orbit.active { cursor: grabbing; }

/* gizmo */
.gizmo {
  display: none;
  width: 0;
  min-width: 100%;
  aspect-ratio: 1;
  pointer-events: auto;
  cursor: grab;
  touch-action: none;
}
.gizmo.active { cursor: grabbing; }

@media (pointer: fine) {
  .gizmo { display: block; }
  .orbit { display: none; }
  #diorama { cursor: grab; }
}
body.dragging, body.dragging * { cursor: grabbing !important; }

/* mobile */
@media (max-width: 760px), (pointer: coarse) {
  .card:not(.collapsed) ~ .zoom,
  .card:not(.collapsed) ~ .orbit { opacity: 0; visibility: hidden; pointer-events: none; }
}

@media (pointer: coarse) {
  .joy { display: block; }
}

@media (max-width: 760px) {
  .card {
    top: auto;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    max-height: 62vh;
    animation: none;
  }
}

/* landscape */
@media (pointer: coarse) and (max-height: 519px) {
  .card, .card.collapsed {
    top: auto;
    bottom: 16px;
    left: 192px;
    right: 152px;
    width: auto;
    max-height: calc(100vh - 32px);
    padding: 14px 16px;
    transform: none;
    animation: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .card, .card.collapsed { animation: none; }
}
