/* style.css — оформление HTML-оверлея поверх Three.js сцены. */

/* Основной шрифт игры */
@font-face {
  font-family: 'Gothic';
  src: url('res/gothic-2.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #140e0a;
  --panel: rgba(6, 17, 38, 0.88);
  --panel-border: rgba(76, 140, 235, 0.45);
  /* Панели заказа и корзины: от сильно тёмно-синего к тёмно-синему */
  --panel-gradient: linear-gradient(160deg, #020a1c 0%, #071731 52%, #0d2a55 100%);
  --accent: #ffc14d;
  --text: #f5ece2;
  --muted: #b9a894;
  --danger: #ff6b5e;
  --ok: #7fd18b;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: 'Gothic', 'Segoe UI', 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Сцена занимает всё окно, оверлей лежит поверх неё */
#app {
  position: fixed;
  inset: 0;
}

#scene-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: default;
}

/* ---------- Постобработка: виньетка ---------- */

/* Края окна плавно затемнены, максимум света — на полках и продавце */
.vignette {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: radial-gradient(
    ellipse 74% 68% at 61% 43%,
    rgba(0, 0, 0, 0) 0%,
    rgba(0, 0, 0, 0) 38%,
    rgba(0, 0, 0, 0.12) 48%,
    rgba(0, 0, 0, 0.3) 58%,
    rgba(0, 0, 0, 0.5) 68%,
    rgba(0, 0, 0, 0.72) 80%,
    rgba(0, 0, 0, 0.9) 92%,
    rgba(0, 0, 0, 0.98) 100%
  );
  pointer-events: none;
}

/* ---------- Верхняя панель со счётчиками ---------- */

.hud {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  pointer-events: none;
  z-index: 2;
}

.hud__stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 116px;
  padding: 8px 18px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  backdrop-filter: blur(6px);
}

.hud__label {
  font-size: 13.2px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

.hud__value {
  font-size: 28.8px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.hud__stat--error .hud__value {
  color: var(--danger);
}

.hud__stat--penalty .hud__value {
  color: var(--accent);
}

/* В плюсе: та же ячейка показывает заработок */
.hud__stat--earned .hud__value {
  color: var(--ok);
}

.hud__stat--earned .hud__label {
  color: rgba(127, 209, 139, 0.85);
}

/* ---------- Боковые панели ---------- */

/* Левая колонка: собранный заказ сверху, заказ клиента снизу.
   Верх панели совпадает с верхом блока ОБСЛУЖЕНО / ОШИБОК / ШТРАФ */
.sidebar {
  position: absolute;
  left: 28px;
  top: 16px;
  bottom: 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(420px, 34vw);
  pointer-events: none;
  z-index: 2;
}

/* На узких окнах HUD смещается левее — опускаем колонку под него */
@media (max-width: 1270px) {
  .sidebar {
    top: 96px;
  }
}

.panel {
  padding: 14px 18px;
  background: var(--panel-gradient);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  box-shadow: inset 0 0 30px rgba(40, 100, 210, 0.16);
  backdrop-filter: blur(8px);
  pointer-events: none;
}

.panel__title {
  margin: 0 0 12px;
  font-size: 14.4px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.panel--basket {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel--order {
  /* прижимается к низу колонки, под панелью собранного заказа */
  margin-top: auto;
}

/* ---------- Монолог клиента ---------- */

.speech {
  margin: 0 0 16px;
  font-size: 25.2px;
  line-height: 1.45;
  min-height: 3em;
}

/* ---------- Визуальные модели заказа ---------- */

.order-visual {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.dish {
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px;
}

.dish__name {
  margin: 0 0 6px;
  font-size: 15.6px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--text);
}

.dish__models {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* Модель ингредиента: та же форма и цвет, что и объект на полке */
.model {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 10px;
  cursor: pointer;
  /* панель не перехватывает клики, но модель обязана */
  pointer-events: auto;
  transition: transform 0.12s ease, border-color 0.2s ease;
}

.model:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 193, 77, 0.6);
}

.model:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.model--active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px rgba(255, 193, 77, 0.28);
}

.caption {
  margin: 0 0 12px;
  min-height: 1.4em;
  font-size: 18px;
  line-height: 1.35;
  color: var(--muted);
}

.caption--active {
  color: var(--accent);
  animation: caption-pulse 0.4s ease;
}

@keyframes caption-pulse {
  from {
    opacity: 0.45;
    transform: scale(0.97);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ---------- Таймер ---------- */

.timer {
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.timer__fill {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #8bd17c, #ffd166);
  transition: width 90ms linear;
}

.timer__fill--danger {
  background: linear-gradient(90deg, #ff8a65, #ff5252);
}

.timer__text {
  margin: 6px 0 0;
  font-size: 16.8px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.status {
  margin: 10px 0 0;
  min-height: 1.4em;
  font-size: 18px;
  line-height: 1.35;
  color: var(--accent);
}

/* ---------- Корзина ---------- */

.basket {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 18vh;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.basket__item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  font-size: 18px;
}

.basket__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.basket__price {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.basket__empty {
  margin: 0;
  font-size: 16.8px;
  line-height: 1.4;
  color: var(--muted);
}

/* Атрибут hidden не должен проигрывать правилу display выше */
.basket__empty[hidden] {
  display: none;
}

/* ---------- Итог и кнопка ---------- */

.total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.total__label {
  font-size: 15.6px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

.total__value {
  font-size: 31.2px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.submit {
  width: 100%;
  margin: 0 0 14px;
  padding: 12px 18px;
  font-family: inherit;
  font-size: 20.4px;
  font-weight: 700;
  color: #2a1a0d;
  background: var(--accent);
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.12s ease;
  /* Кнопка — единственный интерактивный элемент панели заказа */
  pointer-events: auto;
}

.submit:hover:not(:disabled) {
  background: #ffd27a;
  transform: translateY(-1px);
}

.submit:active:not(:disabled) {
  transform: translateY(0);
}

.submit:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

.submit:disabled {
  color: rgba(255, 255, 255, 0.35);
  background: rgba(255, 255, 255, 0.14);
  cursor: not-allowed;
}

/* ---------- Подсказка ---------- */

/* ---------- Кнопка правил ---------- */

.help-btn {
  position: absolute;
  top: 62px;
  right: 28px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  font-family: inherit;
  font-size: 21.6px;
  font-weight: 700;
  color: var(--accent);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  backdrop-filter: blur(6px);
  cursor: pointer;
  pointer-events: auto;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.12s ease;
}

.help-btn:hover {
  background: rgba(255, 193, 77, 0.16);
  border-color: rgba(255, 193, 77, 0.55);
  transform: translateY(-1px);
}

.help-btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

/* ---------- Панель правил ---------- */

.modal {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(2, 7, 18, 0.72);
  backdrop-filter: blur(3px);
  pointer-events: auto;
}

.modal[hidden] {
  display: none;
}

/* Панель: 60 % ширины и 80 % высоты окна */
.modal__panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: 60vw;
  height: 80vh;
  padding: 28px 32px;
  overflow-y: auto;
  /* от тёмно-синего к почти чёрному */
  background: linear-gradient(165deg, #01040d 0%, #030b1e 42%, #051227 72%, #071a35 100%);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6), inset 0 0 40px rgba(40, 100, 210, 0.18);
}

.modal__title {
  margin: 0;
  font-size: 31.2px;
  font-weight: 700;
  color: var(--text);
}

.modal__text {
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 19.2px;
  line-height: 1.55;
  color: var(--text);
}

.modal__text p {
  margin: 0;
}

.modal__text strong {
  color: var(--accent);
}

.modal__actions {
  display: flex;
  gap: 12px;
  margin-top: auto;
  padding-top: 8px;
}

/* Объёмные кнопки: светлая кромка сверху, толстая «подошва» снизу */
.modal__btn {
  flex: 1;
  padding: 14px 18px;
  font-family: inherit;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.24) 0%, rgba(255, 255, 255, 0.06) 100%);
  border: 1px solid rgba(110, 165, 255, 0.55);
  border-radius: 14px;
  cursor: pointer;
  transform: translateY(0);
  box-shadow:
    0 6px 0 #0a1730,
    0 10px 18px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.18s ease;
}

.modal__btn:hover {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.32) 0%, rgba(255, 255, 255, 0.1) 100%);
  transform: translateY(-2px);
  box-shadow:
    0 8px 0 #0a1730,
    0 14px 22px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.modal__btn:active {
  transform: translateY(4px);
  box-shadow:
    0 2px 0 #0a1730,
    0 4px 10px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.modal__btn--primary {
  color: #2a1a0d;
  background: linear-gradient(180deg, #ffdb92 0%, #f0a92c 100%);
  border-color: #ffe3a8;
  box-shadow:
    0 6px 0 #8a5a10,
    0 10px 18px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.modal__btn--primary:hover {
  background: linear-gradient(180deg, #ffe5a8 0%, #ffb43c 100%);
  box-shadow:
    0 8px 0 #8a5a10,
    0 14px 22px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.modal__btn--primary:active {
  box-shadow:
    0 2px 0 #8a5a10,
    0 4px 10px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.modal__btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

/* ---------- Кнопка «В отдельной вкладке» ---------- */

.newtab {
  position: absolute;
  top: 16px;
  right: 28px;
  z-index: 2;
  padding: 10px 16px;
  font-size: 14.4px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  text-decoration: none;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  backdrop-filter: blur(6px);
  pointer-events: auto;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.12s ease;
}

.newtab:hover {
  background: rgba(255, 193, 77, 0.16);
  border-color: rgba(255, 193, 77, 0.55);
  transform: translateY(-1px);
}

.newtab:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

/* ---------- Подпись над ингредиентом в 3D ---------- */

.ingredient-label {
  position: fixed;
  z-index: 5;
  padding: 6px 12px;
  font-size: 16.8px;
  font-weight: 600;
  white-space: nowrap;
  color: #2a1a0d;
  background: var(--accent);
  border-radius: 8px;
  opacity: 0;
  transform: translate(-50%, -125%);
  pointer-events: none;
}

.ingredient-label.is-visible {
  animation: label-fade 1.8s ease forwards;
}

@keyframes label-fade {
  0% {
    opacity: 0;
    transform: translate(-50%, -100%) scale(0.92);
  }

  12% {
    opacity: 1;
    transform: translate(-50%, -125%) scale(1);
  }

  70% {
    opacity: 1;
    transform: translate(-50%, -135%) scale(1);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -160%) scale(1);
  }
}

/* ---------- Узкие окна ---------- */

@media (max-width: 820px) {
  .sidebar {
    left: 12px;
    top: 88px;
    bottom: 12px;
    width: min(330px, 64vw);
  }

  .speech {
    font-size: 20.4px;
  }

  .hud__stat {
    min-width: 92px;
    padding: 6px 12px;
  }

  .hud__value {
    font-size: 24px;
  }
}
