/* style.css — Pranav's World */

@font-face {
  font-family: 'DotGothic16';
  src: url('/assets/fonts/DotGothic16-subset.woff2') format('woff2');
  font-display: swap;
}

:root {
  --ink: #303038;
  --paper: #fcfcfc;
  --paper-border: #c8c8d0;
  --bg: #0c0a12;
  --cream: #f4ecd8;
  --red: #e04848;
  --blue: #3a6ad8;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  overflow: hidden;
  height: 100%;
}

body {
  font-family: 'DotGothic16', ui-monospace, monospace;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ---------- canvas ---------- */
#game {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
  background: var(--bg);
}

/* ---------- UI root overlay ---------- */
#ui {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}
#ui .hud,
#ui .banner,
#ui .fade {
  pointer-events: none;
}

/* ---------- HUD ---------- */
.hud {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  pointer-events: none;
}

.hud-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 2px solid #b8b8c0;
  background: var(--paper);
  color: var(--ink);
  font-family: inherit;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  pointer-events: auto;
}
.hud-btn:active { transform: translateY(1px); }

.bag-glyph {
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.hud-clock {
  margin-left: auto;
  background: var(--paper);
  border: 2px solid #b8b8c0;
  border-radius: 999px;
  color: var(--ink);
  font-size: 14px;
  padding: 6px 12px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  white-space: nowrap;
  pointer-events: none;
}

.text-version {
  position: absolute;
  right: 10px;
  bottom: max(8px, env(safe-area-inset-bottom));
  color: #9a94a8;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-decoration: none;
  background: rgba(12, 10, 18, 0.55);
  padding: 4px 8px;
  border-radius: 6px;
  pointer-events: auto;
}
.text-version:hover { color: #fcfcfc; }

/* ---------- Banner ---------- */
.banner {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translate(-50%, -160%);
  background: rgba(20, 16, 28, 0.78);
  color: #fcfcfc;
  font-size: 18px;
  letter-spacing: 0.12em;
  padding: 10px 22px;
  border-radius: 999px;
  border: 2px solid rgba(252, 252, 252, 0.25);
  transition: transform 0.35s ease;
  pointer-events: none;
  white-space: nowrap;
}
.banner.show { transform: translate(-50%, 0); }

/* ---------- Fade ---------- */
.fade {
  position: fixed;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none !important;
  transition: opacity 0.2s ease;
  z-index: 60;
}
.fade.on { opacity: 1; }

/* ---------- Modal layer (mini-games, passport) ---------- */
.modal-layer {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(12, 10, 18, 0.6);
  z-index: 50;
  pointer-events: none;
}
.modal-layer.open { display: flex; }
.modal-layer.open { pointer-events: auto; }

.modal-panel {
  pointer-events: auto;
  background: var(--paper);
  border: 3px solid var(--paper-border);
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  outline: none;
}

/* ---------- Passport & Bag ---------- */
.bag-panel {
  position: relative;
  width: min(560px, 92vw);
  max-height: min(640px, 86vh);
  display: flex;
  flex-direction: column;
  font-family: 'DotGothic16', ui-monospace, monospace;
  color: var(--ink);
  outline: none;
}

.bag-title {
  font-size: 20px;
  letter-spacing: 0.1em;
  padding: 14px 18px 10px;
  border-bottom: 2px solid #e2e2ea;
  flex: 0 0 auto;
}

.bag-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 2px solid var(--paper-border);
  background: #f0f0f4;
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.bag-close:hover { background: #e2e2ea; }

.bag-scroll {
  overflow-y: auto;
  padding: 12px 18px 16px;
  -webkit-overflow-scrolling: touch;
}

.bag-section { margin-bottom: 16px; }
.bag-section:last-of-type { margin-bottom: 8px; }

.bag-heading {
  font-size: 13px;
  letter-spacing: 0.14em;
  color: #7a7484;
  margin-bottom: 8px;
  border-bottom: 1px dashed #d8d8e0;
  padding-bottom: 4px;
}

.bag-grid {
  display: grid;
  gap: 10px;
}

.stamps-grid {
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
}

.souvenirs-grid {
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
}

.collect-grid {
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
}

.stamp-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 8px 4px;
  border-radius: 8px;
  background: #f6f6fa;
  border: 1px solid #e6e6ee;
  min-height: 84px;
  justify-content: flex-start;
}

.stamp-circle {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid var(--stamp-c, #7a1f2e);
  color: var(--stamp-c, #7a1f2e);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  letter-spacing: 0.04em;
  background:
    radial-gradient(circle at 50% 50%, transparent 55%, var(--stamp-c, #7a1f2e) 56%, transparent 58%);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.6);
  flex: 0 0 auto;
}

.stamp-missing {
  border: 2px dashed #b8b8c0;
  color: #9a94a8;
  background: transparent;
  box-shadow: none;
  font-size: 11px;
}

.stamp-name,
.souvenir-name,
.collect-name {
  font-size: 12px;
  text-align: center;
  line-height: 1.2;
  word-break: break-word;
}

.souvenir-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 8px 4px;
  border-radius: 8px;
  background: #f6f6fa;
  border: 1px solid #e6e6ee;
  min-height: 84px;
  justify-content: flex-start;
}

.souvenir-flag {
  position: relative;
  width: 40px;
  height: 30px;
  flex: 0 0 auto;
}

.flag-pole {
  position: absolute;
  left: 4px;
  top: 0;
  width: 3px;
  height: 30px;
  background: #7a5030;
  border-radius: 1px;
}

.flag-cloth {
  position: absolute;
  left: 7px;
  top: 2px;
  width: 26px;
  height: 16px;
  background: var(--flag-c, #cc092f);
  border: 1px solid rgba(0, 0, 0, 0.25);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
}

.flag-sil {
  background: #d8d8e0;
  border-color: #c0c0ca;
}

.souvenir-missing .souvenir-name { color: #9a94a8; }

.collect-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  border-radius: 8px;
  background: #f6f6fa;
  border: 1px solid #e6e6ee;
  min-height: 78px;
  justify-content: flex-start;
}

.collect-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 30px;
  flex: 0 0 auto;
  image-rendering: pixelated;
}

.collect-missing .collect-name { color: #9a94a8; }

.bag-empty {
  grid-column: 1 / -1;
  color: #9a94a8;
  font-size: 13px;
  text-align: center;
  padding: 10px 0;
}

.bag-progress {
  font-size: 13px;
  color: #55505c;
  text-align: center;
  padding: 8px 0 4px;
  border-top: 1px dashed #d8d8e0;
}

.bag-reset-row {
  text-align: center;
  padding-top: 4px;
}

.bag-reset {
  background: none;
  border: none;
  color: #9a94a8;
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-decoration: underline;
  cursor: pointer;
  padding: 8px 12px;
  min-height: 32px;
}
.bag-reset:hover { color: var(--red); }

/* ---------- Tooltip ---------- */
.tooltip {
  position: fixed;
  left: 0;
  top: 0;
  display: none;
  background: var(--paper);
  border: 2px solid var(--paper-border);
  border-radius: 6px;
  color: var(--ink);
  font-family: 'DotGothic16', ui-monospace, monospace;
  font-size: 14px;
  line-height: 1.3;
  padding: 5px 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  z-index: 55;
  max-width: 260px;
  white-space: nowrap;
}
.tooltip.show { display: block; }
.tooltip .tt-line { white-space: nowrap; }
.tooltip .tt-desc { color: #7a7484; font-size: 12px; }

/* ---------- Dialogue ---------- */
.dialogue {
  position: absolute;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(900px, 92vw);
  display: none;
  pointer-events: none;
  outline: none;
  z-index: 30;
}
.dialogue.open { display: block; pointer-events: auto; }

.dlg-name {
  display: none;
  position: relative;
  width: fit-content;
  background: var(--paper);
  border: 3px solid var(--paper-border);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  color: var(--ink);
  font-size: 16px;
  padding: 4px 14px 2px;
  margin-left: 10px;
  box-shadow: 0 -2px 6px rgba(0, 0, 0, 0.25);
}

.dlg-box {
  position: relative;
  background: var(--paper);
  border: 3px solid var(--paper-border);
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  padding: 10px 14px 12px;
  min-height: 76px;
}
.dlg-box::before {
  content: '';
  position: absolute;
  inset: 2px;
  border: 2px solid #ffffff;
  border-radius: 4px;
  pointer-events: none;
}

.dlg-text {
  color: var(--ink);
  font-size: 22px;
  line-height: 1.35;
  min-height: 60px;
  max-height: 96px;
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-word;
}

.dlg-arrow {
  position: absolute;
  right: 14px;
  bottom: 6px;
  color: var(--red);
  font-size: 14px;
  animation: dlg-blink 0.8s steps(2, start) infinite;
  display: none;
}
@keyframes dlg-blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

.dlg-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.dlg-link {
  display: inline-block;
  background: #f0f0f4;
  border: 2px solid var(--paper-border);
  border-radius: 999px;
  color: var(--ink);
  font-size: 14px;
  padding: 4px 12px;
  text-decoration: none;
}
.dlg-link:hover { background: #e2e2ea; }

.dlg-play {
  background: var(--red);
  border-color: #b83038;
  color: #fcfcfc;
  font-family: inherit;
  cursor: pointer;
}
.dlg-play:hover { background: #c83838; }

/* ---------- Touch controls ---------- */
.touch { position: absolute; touch-action: none; }

.joy {
  left: max(18px, env(safe-area-inset-left));
  bottom: max(24px, env(safe-area-inset-bottom));
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: rgba(252, 252, 252, 0.28);
  border: 2px solid rgba(252, 252, 252, 0.5);
  z-index: 20;
  pointer-events: auto;
}
.joy.hidden { display: none; }
.joy-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(30, 26, 38, 0.85);
  border: 2px solid rgba(252, 252, 252, 0.6);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.btns {
  right: max(18px, env(safe-area-inset-right));
  bottom: max(24px, env(safe-area-inset-bottom));
  width: 140px;
  height: 110px;
  z-index: 20;
  pointer-events: none;
}
.btns.hidden { display: none; }
.touch-btn {
  position: absolute;
  border-radius: 50%;
  color: #fcfcfc;
  font-family: inherit;
  border: 2px solid rgba(252, 252, 252, 0.55);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.4);
  cursor: pointer;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  touch-action: none;
}
.a-btn {
  width: 64px;
  height: 64px;
  background: var(--red);
  font-size: 22px;
  right: 0;
  top: 0;
}
.b-btn {
  width: 56px;
  height: 56px;
  background: var(--blue);
  font-size: 19px;
  left: 0;
  bottom: 0;
}
.touch-btn:active { filter: brightness(0.9); }

/* ---------- sr-only ---------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Portfolio readable mode ---------- */
body.portfolio-mode {
  overflow: auto;
  background: var(--cream);
  -webkit-user-select: auto;
  user-select: auto;
}
body.portfolio-mode #game,
body.portfolio-mode #ui {
  display: none;
}
body.portfolio-mode #portfolio {
  position: static;
  width: auto;
  height: auto;
  margin: 0 auto;
  padding: 48px 20px 80px;
  max-width: 760px;
  overflow: visible;
  clip: auto;
  white-space: normal;
  color: #2c2830;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.6;
}
body.portfolio-mode #portfolio h1,
body.portfolio-mode #portfolio h2,
body.portfolio-mode #portfolio h3 {
  font-family: 'DotGothic16', ui-monospace, monospace;
  color: #1f1a24;
  line-height: 1.25;
}
body.portfolio-mode #portfolio h1 {
  font-size: 40px;
  margin: 0 0 8px;
  letter-spacing: 0.04em;
}
body.portfolio-mode #portfolio h2 {
  font-size: 24px;
  margin: 36px 0 10px;
  border-bottom: 2px solid #d8c8b8;
  padding-bottom: 6px;
}
body.portfolio-mode #portfolio h3 {
  font-size: 18px;
  margin: 18px 0 2px;
}
body.portfolio-mode #portfolio p { margin: 6px 0 14px; }
body.portfolio-mode #portfolio .meta {
  color: #7a6a58;
  font-size: 14px;
  margin: 0 0 8px;
}
body.portfolio-mode #portfolio ul { padding-left: 22px; margin: 0 0 14px; }
body.portfolio-mode #portfolio li { margin: 4px 0; }
body.portfolio-mode #portfolio a { color: #7a1f2e; }
body.portfolio-mode #portfolio .summary { font-size: 17px; }
body.portfolio-mode #portfolio .back-link {
  display: inline-block;
  font-family: 'DotGothic16', ui-monospace, monospace;
  font-size: 14px;
  color: #7a1f2e;
  text-decoration: none;
  border: 2px solid #d8c8b8;
  border-radius: 6px;
  padding: 6px 12px;
  margin-bottom: 20px;
  background: #fcfcfc;
}
body.portfolio-mode #portfolio .back-link:hover { background: #f0e8d4; }
body.portfolio-mode #portfolio footer {
  margin-top: 48px;
  padding-top: 16px;
  border-top: 2px solid #d8c8b8;
  color: #7a6a58;
  font-size: 14px;
}

/* ---------- Phones ---------- */
@media (max-width: 600px) {
  .dlg-text { font-size: 16px; min-height: 48px; }
  .dlg-box { min-height: 64px; }
  .banner { font-size: 15px; padding: 8px 16px; }

  .dialogue.open {
    bottom: calc(max(24px, env(safe-area-inset-bottom)) + 124px);
  }

  .bag-panel {
    width: 94vw;
    max-height: 84vh;
  }
  .bag-title { font-size: 17px; padding: 12px 14px 8px; }
  .bag-scroll { padding: 10px 12px 14px; }
  .stamps-grid,
  .souvenirs-grid { grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); }
  .collect-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }
  .stamp-item,
  .souvenir-item { min-height: 92px; }
  .bag-reset { min-height: 40px; }
}
