/* ==========================================================================
   SCIVOLI VACANZE ESTATE 2026 — Retro CRT / Airport-Board stylesheet
   ========================================================================== */

:root {
  --bg: #030907;
  --bg-panel: #05130d;
  --green: #4dffa0;
  --green-dim: #1c5a3a;
  --green-soft: rgba(77, 255, 160, 0.5);
  --cyan: #4de8ff;
  --amber: #ffb545;
  --orange: #ff8a3d;
  --text-dim: #6f9d8a;
  --border: #143d2b;
  --font-mono: "Courier New", ui-monospace, "SFMono-Regular", Consolas, Menlo, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(ellipse at 50% 0%, #06170f 0%, var(--bg) 70%);
  color: var(--green);
  font-family: var(--font-mono);
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
}

/* ---------------------------------------------------------------------- */
/* CRT overlay effects                                                     */
/* ---------------------------------------------------------------------- */

.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 60;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0px,
    rgba(0, 0, 0, 0) 1px,
    rgba(0, 0, 0, 0.22) 2px,
    rgba(0, 0, 0, 0) 3px
  );
  mix-blend-mode: multiply;
  animation: scan-drift 9s linear infinite;
}

@keyframes scan-drift {
  0% { background-position: 0 0; }
  100% { background-position: 0 120px; }
}

.noise-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 55;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 58;
  box-shadow: inset 0 0 160px 40px rgba(0, 0, 0, 0.75);
}

@keyframes crt-flicker {
  0%, 100% { opacity: 1; }
  92% { opacity: 1; }
  93% { opacity: 0.82; }
  94% { opacity: 1; }
  97% { opacity: 0.88; }
  98% { opacity: 1; }
}

/* ---------------------------------------------------------------------- */
/* Boot screen (first phase — plain black page before the main animation)  */
/* ---------------------------------------------------------------------- */

.boot-screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: #000000;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 6vh 8vw;
  opacity: 1;
  transition: opacity 1.4s ease;
}

.boot-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

.boot-lines {
  width: 100%;
  max-width: 780px;
  font-family: var(--font-mono);
  font-size: 1rem;
  line-height: 1.9;
  color: var(--green);
}

.boot-line {
  white-space: pre-wrap;
  text-shadow: 0 0 5px var(--green-soft);
}

.boot-banner {
  color: var(--amber);
  text-shadow: 0 0 8px rgba(255, 181, 69, 0.6);
  letter-spacing: 0.04em;
  margin-bottom: 0.4em;
}

.boot-run {
  color: var(--cyan);
  text-shadow: 0 0 8px rgba(77, 232, 255, 0.6);
}

.boot-ok {
  color: var(--green);
}

.boot-ready {
  color: var(--amber);
  text-shadow: 0 0 8px rgba(255, 181, 69, 0.6);
  margin-top: 0.4em;
}

.boot-cursor {
  display: inline-block;
  margin-left: 2px;
  animation: cursor-blink 1s steps(1) infinite;
}

@media (max-width: 620px) {
  .boot-lines { font-size: 0.8rem; }
  .boot-screen { padding: 6vh 6vw; }
}

.app {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 14px 18px 10px;
  animation: crt-flicker 6s infinite;
}

body.glitch .app {
  animation: crt-flicker 6s infinite, glitch-shift 0.15s steps(2, end) 1;
}

@keyframes glitch-shift {
  0% { transform: translate(0, 0); filter: hue-rotate(0deg); }
  25% { transform: translate(-2px, 1px); filter: hue-rotate(20deg); }
  50% { transform: translate(2px, -1px); filter: hue-rotate(-15deg); }
  75% { transform: translate(-1px, 0); filter: hue-rotate(10deg); }
  100% { transform: translate(0, 0); filter: hue-rotate(0deg); }
}

/* ---------------------------------------------------------------------- */
/* Header                                                                  */
/* ---------------------------------------------------------------------- */

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 4px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
  flex-shrink: 0;
}

.header-title {
  font-size: 1.15rem;
  font-weight: bold;
  letter-spacing: 0.14em;
  color: var(--green);
  text-shadow: 0 0 6px var(--green-soft), 0 0 14px rgba(77, 255, 160, 0.35);
}

.header-status {
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  color: var(--amber);
  text-shadow: 0 0 6px rgba(255, 181, 69, 0.6);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 2px;
  background: rgba(255, 181, 69, 0.06);
}

/* ---------------------------------------------------------------------- */
/* Body layout                                                             */
/* ---------------------------------------------------------------------- */

.app-body {
  flex: 1;
  display: flex;
  gap: 14px;
  min-height: 0;
}

.terminal-panel,
.map-panel {
  background: linear-gradient(180deg, var(--bg-panel), #030b07);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.6), inset 0 0 40px rgba(0, 40, 20, 0.25);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.terminal-panel { flex: 1.15; }
.map-panel { flex: 1; position: relative; }

.panel-chrome {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: rgba(20, 61, 43, 0.18);
}

.chrome-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green-dim);
  box-shadow: 0 0 4px rgba(77, 255, 160, 0.5);
}

.chrome-title {
  margin-left: 8px;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: var(--text-dim);
}

/* ---------------------------------------------------------------------- */
/* Terminal                                                                */
/* ---------------------------------------------------------------------- */

.terminal-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  font-size: 0.86rem;
  line-height: 1.55;
  scrollbar-width: thin;
  scrollbar-color: var(--green-dim) transparent;
}

.terminal-scroll::-webkit-scrollbar { width: 6px; }
.terminal-scroll::-webkit-scrollbar-thumb { background: var(--green-dim); border-radius: 3px; }

.term-line {
  color: var(--green);
  text-shadow: 0 0 4px var(--green-soft);
  white-space: pre-wrap;
  word-break: break-word;
}

.day-block {
  margin-bottom: 14px;
  padding-left: 10px;
  border-left: 2px solid var(--border);
  transition: opacity 0.6s ease;
}

.day-block.active { opacity: 1; border-left-color: var(--green-dim); }
.day-block.faded { opacity: 0.28; }

.term-line.emphasis {
  color: var(--amber);
  text-shadow: 0 0 6px rgba(255, 181, 69, 0.55);
  font-weight: bold;
}

.cursor {
  display: inline-block;
  color: var(--green);
  animation: cursor-blink 1s steps(1) infinite;
  margin-left: 2px;
}

@keyframes cursor-blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

body.story-complete .cursor { display: none; }

/* ---------------------------------------------------------------------- */
/* Map                                                                     */
/* ---------------------------------------------------------------------- */

#mapSvg {
  flex: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  display: block;
}

.landmass path {
  fill: none;
  stroke: var(--border);
  stroke-width: 1.4;
  opacity: 0.85;
}

.landmass .island-shape {
  stroke: var(--green-dim);
  stroke-dasharray: 3 3;
}

.landmass .switzerland-shape {
  stroke: var(--green-dim);
  stroke-dasharray: 3 3;
}

.landmass .corridor-line {
  stroke: var(--border);
  stroke-dasharray: 2 5;
}

.route-preview {
  stroke-width: 1.6;
  opacity: 0.4;
  transition: opacity 1.4s ease;
}

.route-preview.route-old { opacity: 0.14; }

.route-preview.route-flight { stroke: var(--cyan); stroke-dasharray: 6 5; }
.route-preview.route-car { stroke: var(--orange); }

.route-progress {
  stroke-width: 2.4;
  filter: url(#glowSoft);
}

.route-progress.route-flight { stroke: var(--cyan); }
.route-progress.route-car { stroke: var(--orange); }

.route-progress.route-progress-done { opacity: 0.55; }

.travel-icon { filter: url(#glowIcon); }

.icon-plane .plane-body {
  fill: var(--cyan);
  stroke: #d9fbff;
  stroke-width: 0.6;
}

.icon-car .car-body {
  fill: var(--orange);
  stroke: #3a1c00;
  stroke-width: 0.6;
}

.icon-car .car-cabin {
  fill: #14100a;
  stroke: var(--orange);
  stroke-width: 0.6;
  opacity: 0.85;
}

.icon-car .car-wheel {
  fill: #0a0a0a;
  stroke: var(--orange);
  stroke-width: 0.7;
}

.map-marker .marker-dot {
  fill: var(--green);
  filter: url(#glowSoft);
}

.map-marker .marker-halo {
  fill: none;
  stroke: var(--green-dim);
  stroke-width: 1;
  opacity: 0.7;
}

.map-marker .marker-label {
  fill: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 0.06em;
  text-shadow: none;
}

.map-marker.pulse .marker-halo {
  animation: marker-pulse 0.9s ease-out 1;
}

.map-marker.pulse .marker-dot {
  animation: marker-flash 0.9s ease-out 1;
}

@keyframes marker-pulse {
  0% { r: 6; opacity: 1; stroke: var(--amber); }
  100% { r: 22; opacity: 0; stroke: var(--amber); }
}

@keyframes marker-flash {
  0%, 100% { fill: var(--green); }
  30% { fill: var(--amber); }
}

.map-caption {
  position: absolute;
  bottom: 8px;
  left: 12px;
  right: 12px;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  text-align: center;
  pointer-events: none;
}

/* ---------------------------------------------------------------------- */
/* Counter footer                                                          */
/* ---------------------------------------------------------------------- */

.counter-panel {
  flex-shrink: 0;
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: linear-gradient(180deg, var(--bg-panel), #030b07);
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.6), inset 0 0 40px rgba(0, 40, 20, 0.25);
  padding: 10px 16px;
}

.counter-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}

.counter-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 4px 2px;
  border-right: 1px solid var(--border);
}

.counter-item:last-child { border-right: none; }

.counter-label {
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.counter-value {
  font-size: 1.05rem;
  font-weight: bold;
  color: var(--amber);
  text-shadow: 0 0 8px rgba(255, 181, 69, 0.55);
  letter-spacing: 0.03em;
  font-variant-numeric: tabular-nums;
}

body.story-complete .counter-value {
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(77, 232, 255, 0.7);
}

/* ---------------------------------------------------------------------- */
/* Responsive                                                              */
/* ---------------------------------------------------------------------- */

@media (max-width: 1000px) {
  .counter-grid { grid-template-columns: repeat(3, 1fr); row-gap: 12px; }
  .counter-item:nth-child(3) { border-right: none; }
}

@media (max-width: 860px) {
  html, body { overflow-y: auto; overflow-x: hidden; }
  .app { animation: none; height: auto; }
  .app-body { flex-direction: column; }
  .terminal-panel { flex: none; height: 46vh; }
  .map-panel { flex: none; height: 40vh; }
  .counter-panel { position: sticky; bottom: 0; }
}

@media (max-width: 520px) {
  .header-title { font-size: 0.85rem; }
  .counter-grid { grid-template-columns: repeat(2, 1fr); }
  .counter-item:nth-child(odd) { border-right: 1px solid var(--border); }
  .counter-item:nth-child(even) { border-right: none; }
  .counter-value { font-size: 0.85rem; }
  .terminal-scroll { font-size: 0.76rem; }
}
