/* ===================================================
   GRAFTCRAFT PRICING APP — Final Stylesheet
   Font rules:
     • ALL text: Arial (buttons, labels, headings, menus)
     • ALL numbers: Croteau (prices, money, debt, stats)
   =================================================== */

@font-face {
  font-family: 'Croteau';
  src: url("Croteau Regular.ttf") format('truetype');
}

:root {
  --bg-color: #f1ebd8;
  --text-color: #2b1f1a;
  --heart-color: #f17290;
  --lungs-color: #79bee2;
  --liver-color: #6bbe63;
  --kidney-color: #edcc6a;
  --pills-color: #a4aeb3;
  --dark-green: #14532d;
  --light-green: #4ade80;
  --dark-red: #7f1d1d;
  --light-red: #f87171;
  --blue: #2563eb;
  /* Font shorthands */
  --font-text: 'Inter', Arial, Helvetica, sans-serif;
  --font-num: 'Croteau', sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  font-family: var(--font-text);
  margin: 0;
  padding: 10px;
  background-image: radial-gradient(circle, #f1ebd8 20%, #d8caa5 100%);
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}


/* ===================== TOPBAR ===================== */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 5px;
  border-bottom: 2px dashed rgba(43, 31, 26, 0.3);
  padding-bottom: 5px;
  gap: 8px;
  flex-shrink: 0;
}

.menu-btn {
  background: rgba(255, 255, 255, 0.5);
  border: 2px solid var(--text-color);
  color: var(--text-color);
  font-size: 22px;
  width: 40px;
  height: 40px;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--text-color);
  display: flex;
  align-items: center;
  justify-content: center;
}
.menu-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 var(--text-color);
}

/* — Money display — */
.money-display {
  flex: 1;
  text-align: center;
}
.money-row {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 10px;
}
.money-display .label {
  font-family: var(--font-text);
  font-size: clamp(14px, 3.5vw, 18px);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-right: 2px;
}
.money-display .amount {
  font-family: var(--font-num);
  font-size: clamp(30px, 7vw, 42px);
  color: var(--dark-green);
}
.money-display .debt {
  font-family: var(--font-num);
  font-size: clamp(20px, 5vw, 28px);
  color: var(--dark-red);
}

/* Hidden money (locked state) */
.hidden-money .amount,
.hidden-money .debt {
  color: var(--text-color);
  font-size: 16px;
}
.hidden-money .amount::after,
.hidden-money .debt::after { content: "•••"; }
.hidden-money .amount-value,
.hidden-money .debt-value { display: none; }

/* — Phase toggle — */
.phase-toggle {
  display: flex;
  background: rgba(255, 255, 255, 0.5);
  border: 2px solid var(--text-color);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 2px 2px 0 var(--text-color);
}
.phase-toggle button {
  background: transparent;
  border: none;
  color: var(--text-color);
  padding: 8px 12px;
  font-family: var(--font-text);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 1px;
  cursor: pointer;
}
.phase-toggle button.active.buy { background: var(--blue); color: white; }
.phase-toggle button.active.sell { background: var(--dark-red); color: white; }


/* ===================== LOCK BAR ===================== */

.lock-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  flex-shrink: 0;
  width: 100%;
}

.btn-lock {
  flex: 1;
  background-color: #b22222;
  color: #fff;
  border: 2px solid #600;
  padding: 10px 15px;
  font-family: var(--font-text);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 2px;
  cursor: pointer;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.8);
  transition: transform 0.1s, box-shadow 0.1s;
}
.btn-lock:active {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 rgba(0,0,0,0.8);
}
.btn-lock.unlock-btn {
  background-color: #2ecc71;
  border-color: #27ae60;
  color: var(--text-color);
}

.undo-btn {
  background: #374151;
  color: white;
  border: 2px solid #1f2937;
  padding: 10px 15px;
  font-family: var(--font-text);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1px;
  border-radius: 4px;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.8);
  cursor: pointer;
}
.undo-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
  transform: translate(2px, 2px);
}


/* ===================== GRID ===================== */

.grid {
  display: grid;
  gap: 10px;
  width: 100%;
  flex: 1;
  min-height: 0;
  grid-auto-rows: minmax(0, 1fr);
}

@media (max-aspect-ratio: 1/1) {
  .grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-aspect-ratio: 1/1) {
  .grid { grid-template-columns: repeat(4, 1fr); }
}


/* ===================== CARDS ===================== */

.card {
  background: rgba(255, 255, 255, 0.5);
  border: 2px solid var(--text-color);
  border-radius: 4px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  box-shadow: 3px 3px 0 var(--text-color);
  position: relative;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  min-height: 0;
}
.med-card {
  grid-column: 1 / -1;
}

.pill-images {
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: 20px;
  flex: 1 1 auto;
  height: 0;
  min-height: 0;
  width: 100%;
}

.card > img {
  height: 0;
  flex: 1 1 auto;
  max-width: 90%;
  object-fit: contain;
  filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.3));
  transition: all 0.2s ease;
}
.pill-images img {
  flex: 1 1 0;
  min-width: 0;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.3));
  transition: all 0.2s ease;
}

/* Titles hidden — images are self-explanatory */
.card h2 {
  display: none;
}

/* Price numbers — always Croteau */
.price {
  font-family: var(--font-num);
  font-size: clamp(1.8rem, 6vh, 2.8rem);
  font-weight: bold;
  margin: 5px 0;
  line-height: 1;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  flex-shrink: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* — Slider row — */
.slider-container {
  width: 100%;
  transition: opacity 0.3s ease;
  min-height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 5px;
}

.price-btn {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  border: 2px solid var(--text-color);
  background: #e1e1e1;
  font-family: var(--font-num);
  font-size: 1.4rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.price-btn:active { background: #ccc; }

input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  background: transparent;
  flex: 1;
}
input[type="range"]:focus { outline: none; }
input[type="range"]::-webkit-slider-runnable-track {
  width: 100%;
  height: 10px;
  cursor: pointer;
  border-radius: 5px;
  border: 2px solid var(--text-color);
  box-shadow: inset 1px 1px 2px rgba(0,0,0,0.2);
}
input[type="range"]::-webkit-slider-thumb {
  border: 2px solid var(--text-color);
  height: 24px;
  width: 16px;
  border-radius: 4px;
  background: #e1e1e1;
  cursor: pointer;
  -webkit-appearance: none;
  margin-top: -8px;
  box-shadow: 2px 2px 0 var(--text-color);
}

.slider-heart::-webkit-slider-runnable-track  { background: var(--heart-color); }
.slider-lungs::-webkit-slider-runnable-track  { background: var(--lungs-color); }
.slider-liver::-webkit-slider-runnable-track  { background: var(--liver-color); }
.slider-kidney::-webkit-slider-runnable-track { background: var(--kidney-color); border: 2px solid #8e7421; }
.slider-pills::-webkit-slider-runnable-track  { background: var(--pills-color); border: 1px solid #777; }


/* ===================== LOCKED STATE ===================== */

body.locked .slider-container {
  display: none;
}
body.locked .card {
  box-shadow: 6px 6px 0 var(--text-color);
  background: #fff;
  justify-content: center;
}

body.locked .card[data-organ="heart"]  { background-color: var(--heart-color);  border-color: var(--heart-color);  box-shadow: 6px 6px 0 rgba(0,0,0,0.5); }
body.locked .card[data-organ="lungs"]  { background-color: var(--lungs-color);  border-color: var(--lungs-color);  box-shadow: 6px 6px 0 rgba(0,0,0,0.5); }
body.locked .card[data-organ="liver"]  { background-color: var(--liver-color);  border-color: var(--liver-color);  box-shadow: 6px 6px 0 rgba(0,0,0,0.5); }
body.locked .card[data-organ="kidney"] { background-color: var(--kidney-color); border-color: var(--kidney-color); box-shadow: 6px 6px 0 rgba(0,0,0,0.5); }
body.locked .card[data-organ="pills"]  { background-color: var(--pills-color);  border-color: #666;                box-shadow: 6px 6px 0 rgba(0,0,0,0.5); }

body.locked .card h2       { display: none; }
body.locked .card > img    { max-width: 100%; transform: scale(1.1); margin-bottom: 5px; }
body.locked .pill-images img { transform: scale(1.1); }

body.locked .price {
  font-family: var(--font-num);
  font-size: min(15vh, 6rem);
  margin: 0;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.15);
  flex: 1;
}

/* — Action button (Buy/Sell in locked state) — */
.action-controls {
  display: none;
  width: 100%;
}
body.locked .action-controls {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 100%;
  margin-top: 10px;
}

.action-btn {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--text-color);
  border-radius: 4px;
  font-family: var(--font-text);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 1px;
  color: white;
  cursor: pointer;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.2;
  transition: transform 0.1s, box-shadow 0.1s, filter 0.1s;
}
.action-btn:active {
  transform: translate(3px, 3px);
  box-shadow: 0 0 0 rgba(0,0,0,0.8);
  filter: brightness(0.85);
}
.action-btn.flash {
  filter: brightness(0.6) contrast(1.2);
  transform: scale(0.97) translate(2px, 2px);
  box-shadow: 0 0 0 rgba(0,0,0,0.8);
}
.action-btn.buy  { background: var(--dark-red); }
.action-btn.sell { background: var(--blue); }
.action-btn:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; transform: none; }

/* The amount inside the action button is a number → Croteau */
.action-amount {
  font-family: var(--font-num);
  font-size: 1.4rem;
  opacity: 0.9;
  margin-top: 2px;
}


/* ===================== TX FEEDBACK ===================== */

.tx-feedback {
  position: absolute;
  pointer-events: none;
  font-family: var(--font-num);
  font-size: clamp(48px, 10vw, 70px);
  font-weight: 900;
  z-index: 50;
  animation: floatUp 1s ease-out forwards;
  text-shadow: 2px 2px 0 var(--text-color);
  white-space: nowrap;
}
.tx-feedback.gain { color: var(--light-green); }
.tx-feedback.loss { color: var(--light-red); }
@keyframes floatUp {
  0%   { opacity: 0; transform: translate(-50%, 0) scale(0.7); }
  15%  { opacity: 1; transform: translate(-50%, -10px) scale(1.1); }
  30%  { transform: translate(-50%, -20px) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -90px) scale(1); }
}


/* ===================== MODALS ===================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal {
  background: var(--bg-color);
  border: 4px solid var(--text-color);
  border-radius: 8px;
  padding: 20px;
  width: 100%;
  max-width: 380px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 8px 8px 0 var(--text-color);
}

.modal h2 {
  font-family: var(--font-text);
  margin: 0 0 14px 0;
  font-size: 22px;
  font-weight: 800;
  text-align: center;
  letter-spacing: 1px;
  border-bottom: 2px dashed var(--text-color);
  padding-bottom: 10px;
}

/* Money display inside modals */
.modal-money {
  text-align: center;
  margin-bottom: 12px;
  font-family: var(--font-text);
  font-size: 16px;
  font-weight: 600;
}
.modal-money .amount {
  font-family: var(--font-num);
  color: var(--dark-green);
  font-size: 24px;
}
.modal-money .debt {
  font-family: var(--font-num);
  color: var(--dark-red);
  font-size: 24px;
}

/* Salary tier buttons (1, 2, 3) — numbers → Croteau */
.modal-btn-row { display: flex; gap: 8px; margin-bottom: 10px; }
.modal-btn {
  flex: 1;
  padding: 16px;
  font-family: var(--font-num);
  font-size: 2rem;
  border: 2px solid var(--text-color);
  border-radius: 4px;
  cursor: pointer;
  color: white;
  background: var(--blue);
  box-shadow: 3px 3px 0 var(--text-color);
}
.modal-btn:active { transform: translate(3px,3px); box-shadow: none; }
.modal-btn:disabled { background: #374151; color: #aaa; box-shadow: none; transform: translate(3px,3px); }

/* Generic modal buttons (DONE, CANCEL, CONFIRM etc.) — text → Arial */
.modal-close, .secondary-btn, .confirm-no, .confirm-yes {
  width: 100%;
  padding: 12px;
  font-family: var(--font-text);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 1px;
  border: 2px solid var(--text-color);
  border-radius: 4px;
  cursor: pointer;
  color: white;
  background: #16a34a;
  box-shadow: 3px 3px 0 var(--text-color);
  margin-top: 8px;
}
.modal-close:active, .secondary-btn:active, .confirm-no:active, .confirm-yes:active {
  transform: translate(3px,3px); box-shadow: none;
}
.secondary-btn     { background: #374151; }
.confirm-no        { background: #374151; }
.confirm-yes       { background: #b22222; }
.confirm-yes.green { background: #16a34a; }

/* Confirm dialog text */
.confirm-text {
  font-family: var(--font-text);
  font-size: 15px;
  line-height: 1.5;
  text-align: center;
  margin-bottom: 12px;
}
.confirm-buttons { display: flex; gap: 8px; }
.confirm-buttons button { flex: 1; }

/* Menu list */
.menu-list { display: flex; flex-direction: column; gap: 8px; }
.menu-item {
  padding: 14px;
  background: rgba(255,255,255,0.6);
  border: 2px solid var(--text-color);
  border-radius: 4px;
  color: var(--text-color);
  font-family: var(--font-text);
  font-size: 15px;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 2px 2px 0 var(--text-color);
}
.menu-item:active { transform: translate(2px,2px); box-shadow: none; }
.menu-item.danger { color: var(--dark-red); }
.menu-value {
  font-family: var(--font-num);
  font-size: 14px;
  color: var(--dark-green);
}

/* Toggle switch */
.toggle-switch {
  width: 40px;
  height: 24px;
  background: #444;
  border-radius: 12px;
  position: relative;
  transition: background 0.2s;
}
.toggle-switch.on { background: #16a34a; }
.toggle-switch::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: left 0.2s;
}
.toggle-switch.on::after { left: 19px; }

/* Salary running total */
.salary-running {
  text-align: center;
  margin: 8px 0;
  padding: 10px;
  background: rgba(255,255,255,0.4);
  border: 2px solid var(--text-color);
  border-radius: 4px;
  font-family: var(--font-text);
  font-size: 15px;
}
.salary-running .running-total {
  font-family: var(--font-num);
  color: var(--dark-red);
  font-size: 2rem;
}

/* Endgame */
.endgame-result {
  text-align: center;
  padding: 12px 0;
  font-family: var(--font-text);
  font-size: 16px;
  line-height: 1.6;
}
.endgame-result .pos { color: var(--dark-green); font-family: var(--font-num); font-weight: 700; }
.endgame-result .neg { color: var(--dark-red);   font-family: var(--font-num); font-weight: 700; }
.endgame-result .net {
  font-family: var(--font-num);
  font-size: 4rem;
  color: var(--dark-green);
  margin-top: 10px;
}
.endgame-result .net-label {
  font-family: var(--font-text);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-color);
}

/* Loan info */
.loan-info {
  text-align: center;
  margin-bottom: 12px;
  padding: 12px;
  border: 2px solid var(--text-color);
  background: rgba(255,255,255,0.4);
  border-radius: 4px;
  font-family: var(--font-text);
  font-size: 15px;
  line-height: 1.6;
}
.loan-info .green { color: var(--dark-green); font-family: var(--font-num); font-weight: 700; }
.loan-info .red   { color: var(--dark-red);   font-family: var(--font-num); font-weight: 700; }

/* Stats table */
.stats-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 8px;
  font-family: var(--font-text);
  font-size: 14px;
}
.stats-table th {
  text-align: left;
  padding: 8px 6px;
  font-family: var(--font-text);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 2px solid var(--text-color);
}
.stats-table td {
  padding: 9px 6px;
  border-bottom: 1px solid rgba(43, 31, 26, 0.3);
}
.stats-table td span[style] {
  font-family: var(--font-num);
}
.stats-empty {
  text-align: center;
  padding: 24px 8px;
  font-style: italic;
  font-size: 14px;
  color: #666;
}
