/* =========================================================
   Vintage calculator models (original designs, inspired by the classics).
   These represent physical devices, so they keep fixed colors in every theme.
   ========================================================= */

.vintage-wrap { display: flex; justify-content: center; }

/* Shared key structure: a printed "shift" legend above each key */
.vkey-cell { display: flex; flex-direction: column; align-items: stretch; gap: 3px; min-width: 0; }
.vkey-cell.wide { grid-column: span 2; }
.vkey-shift {
  height: 13px;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  line-height: 13px;
}
.vkey {
  font: inherit;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  padding: 0;
  min-width: 0;
  transition: transform 0.05s ease, filter 0.08s ease;
}
.vkey:active, .vkey.pressed { transform: translateY(1px) scale(0.98); filter: brightness(0.9); }
.vkey:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ---------------------------------------------------------
   Classic RPN — landscape layout: graphite bezel, LCD, slate keypad,
   gold f-shift legends above keys, blue g-shift legends on the key fronts
   --------------------------------------------------------- */
.rpn-calc {
  --gold: #e8ad45;
  --blue: #79bdf0;
  width: 100%;
  max-width: 760px;
  background: linear-gradient(180deg, #34363b 0%, #26282c 100%);
  border-radius: 14px;
  padding: 12px;
  box-shadow: 0 2px 0 #4a4d53 inset, 0 -3px 0 #141518 inset, 0 18px 40px rgba(0, 0, 0, 0.35);
  color: #eef0f3;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
.rpn-head { display: flex; gap: 14px; align-items: stretch; padding: 6px 8px 12px; }
.rpn-lcd-bezel {
  flex: 0 1 58%;
  background: #101113;
  border-radius: 6px;
  padding: 7px;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.8), 0 1px 0 #4a4d53;
  display: flex;
}
.rpn-lcd {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: linear-gradient(180deg, #c3c8b2, #a9b096);
  border-radius: 3px;
  padding: 4px 10px 5px;
  color: #1e2219;
  font-family: "Share Tech Mono", ui-monospace, Menlo, Consolas, monospace;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.35);
}
.rpn-x {
  text-align: right;
  font-size: 2.1rem;
  letter-spacing: 0.06em;
  white-space: nowrap;
  overflow: hidden;
  line-height: 1.15;
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.08);
}
.rpn-ann { display: flex; gap: 12px; height: 13px; font-size: 0.64rem; letter-spacing: 0.06em; }
.rpn-ann span { visibility: hidden; }
.rpn-ann span.on { visibility: visible; }
.rpn-side { flex: 1 1 auto; display: flex; flex-direction: column; justify-content: space-between; min-width: 0; }
.rpn-brand { display: flex; justify-content: flex-end; gap: 8px; align-items: baseline; font-size: 0.66rem; letter-spacing: 0.18em; color: #aeb3bb; text-transform: uppercase; }
.rpn-brand strong { color: var(--gold); letter-spacing: 0.12em; }
.rpn-stack {
  font-family: "Share Tech Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.74rem;
  color: #c9ced6;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 6px;
  padding: 4px 8px;
}
.rpn-stack div { display: flex; justify-content: space-between; gap: 8px; }
.rpn-stack b { color: var(--gold); font-weight: 400; }
.rpn-stack span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rpn-stack-toggle { display: flex; justify-content: flex-end; align-items: center; gap: 6px; font-size: 0.7rem; color: #aeb3bb; cursor: pointer; }
.rpn-stack-toggle input { accent-color: var(--gold); }

.rpn-face {
  background: linear-gradient(180deg, #3b4350, #2d343f);
  border-radius: 8px;
  padding: 8px 10px 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), inset 0 -2px 4px rgba(0, 0, 0, 0.3);
}
.rpn-keys { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 2px 8px; }
.rpn-calc .vkey-cell { gap: 2px; }
.rpn-calc .vkey-cell.tall { grid-column: 6; grid-row: 3 / span 2; }
.rpn-calc .vkey-shift { color: var(--gold); font-size: 0.6rem; height: 12px; line-height: 12px; }
.rpn-calc .vkey {
  position: relative;
  height: 46px;
  border: 0;
  border-radius: 5px 5px 6px 6px;
  /* key top + slanted front face (where the blue g legend sits) */
  background: linear-gradient(180deg, #43464d 0%, #2f3136 60%, #1f2024 60%, #18191c 100%);
  color: #f4f5f7;
  box-shadow: 0 2px 0 #0b0c0e, inset 0 1px 0 rgba(255, 255, 255, 0.14);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 5px;
}
.rpn-calc .vkey .p { font-size: 0.84rem; font-weight: 600; line-height: 1.1; white-space: nowrap; }
.rpn-calc .vkey .g { position: absolute; bottom: 2px; left: 0; right: 0; text-align: center; font-size: 0.58rem; font-weight: 700; color: var(--blue); white-space: nowrap; }
.rpn-calc .vkey.num .p { font-size: 1.05rem; }
.rpn-calc .vkey.tall { flex: 1; height: auto; }
.rpn-calc .vkey.tall .p { writing-mode: vertical-rl; transform: rotate(180deg); letter-spacing: 0.12em; margin: auto 0; font-size: 0.82rem; }
.rpn-calc .vkey.fkey { background: linear-gradient(180deg, #f1bd5f, #c98d2e); color: #2d1f08; }
.rpn-calc .vkey.gkey { background: linear-gradient(180deg, #8fcaf5, #4f97cf); color: #0d2234; }
.rpn-calc .vkey.fkey .p, .rpn-calc .vkey.gkey .p { font-size: 1rem; font-weight: 800; margin-top: 4px; }
.rpn-calc .vkey.fkey.active, .rpn-calc .vkey.gkey.active { box-shadow: 0 0 0 2px #fff, 0 2px 0 #0b0c0e; }

@media (max-width: 620px) {
  .rpn-calc { padding: 8px; }
  .rpn-head { flex-direction: column; gap: 8px; padding: 2px 2px 8px; }
  .rpn-lcd-bezel { flex-basis: auto; }
  .rpn-face { padding: 6px 5px 8px; }
  .rpn-keys { gap: 1px 3px; }
  .rpn-calc .vkey { height: 40px; padding-top: 4px; overflow: hidden; }
  .rpn-calc .vkey .p { font-size: 0.58rem; letter-spacing: -0.02em; max-width: 100%; overflow: hidden; }
  .rpn-calc .vkey.num .p { font-size: 0.9rem; }
  .rpn-calc .vkey .g { font-size: 0.48rem; }
  .rpn-calc .vkey-shift { font-size: 0.48rem; }
  .rpn-calc .vkey.fkey .p, .rpn-calc .vkey.gkey .p { font-size: 0.85rem; }
}

/* ---------------------------------------------------------
   Classic algebraic — silver solar scientific, gray LCD
   --------------------------------------------------------- */
.classic-calc {
  --second: #e8782a;
  width: 100%;
  max-width: 380px;
  background: linear-gradient(180deg, #d9d9d4 0%, #c4c4be 55%, #b3b3ad 100%);
  border-radius: 14px 14px 22px 22px;
  padding: 14px 16px 22px;
  box-shadow: 0 2px 0 #eeeeea inset, 0 -3px 0 #8e8e88 inset, 0 18px 40px rgba(0, 0, 0, 0.3);
  color: #2b2b2b;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
.classic-head { display: flex; justify-content: space-between; align-items: center; margin: 0 2px 10px; gap: 10px; }
.classic-brand { font-size: 0.68rem; font-weight: 700; letter-spacing: 0.16em; color: #4a4a48; text-transform: uppercase; }
.classic-brand em { font-style: normal; color: var(--second); }
.classic-solar {
  width: 96px; height: 22px;
  border-radius: 3px;
  background:
    repeating-linear-gradient(90deg, transparent 0 23px, rgba(255, 255, 255, 0.12) 23px 24px),
    linear-gradient(180deg, #3b2a22, #20150f);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.7), 0 1px 0 #f2f2ee;
}
.classic-bezel { background: #3c3c3a; border-radius: 8px; padding: 8px; margin-bottom: 14px; box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.6); }
.classic-lcd {
  background: linear-gradient(180deg, #c2cbb0, #aab595);
  border-radius: 4px;
  padding: 4px 10px 6px;
  font-family: "Share Tech Mono", ui-monospace, Menlo, Consolas, monospace;
  color: #1f2619;
  box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.35);
}
.classic-ann { display: flex; gap: 10px; height: 13px; font-size: 0.62rem; letter-spacing: 0.06em; }
.classic-ann span { visibility: hidden; }
.classic-ann span.on { visibility: visible; }
.classic-row { display: flex; justify-content: flex-end; align-items: baseline; gap: 8px; }
.classic-val { font-size: 2.1rem; letter-spacing: 0.05em; white-space: nowrap; overflow: hidden; line-height: 1.15; text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.08); }
.classic-exp { font-size: 1.1rem; min-width: 2.4ch; text-align: right; }

.classic-keys { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px 8px; }
.classic-calc .vkey-shift { color: var(--second); }
.classic-calc .vkey {
  height: 36px;
  border: 0;
  border-radius: 7px;
  background: linear-gradient(180deg, #6a6a68, #4b4b49);
  color: #fafafa;
  font-size: 0.8rem;
  font-weight: 600;
  box-shadow: 0 2px 0 #2c2c2a, inset 0 1px 0 rgba(255, 255, 255, 0.15);
}
.classic-calc .vkey.num { background: linear-gradient(180deg, #2f2f2e, #1c1c1b); font-size: 1.15rem; height: 40px; }
.classic-calc .vkey.op { background: linear-gradient(180deg, #8a8a86, #6c6c69); font-size: 1.2rem; height: 40px; }
.classic-calc .vkey.second { background: linear-gradient(180deg, #f08b3e, #c9631d); color: #fff; }
.classic-calc .vkey.second.active { box-shadow: 0 0 0 2px #fff, 0 2px 0 #2c2c2a; }
.classic-calc .vkey.clear { background: linear-gradient(180deg, #b84a3a, #8f3427); }
.classic-calc .vkey.eq { background: linear-gradient(180deg, #8a8a86, #6c6c69); font-size: 1.3rem; height: 40px; }

/* ---------- Style switcher ---------- */
.style-switch { margin: 0 0 16px; flex-wrap: wrap; }
.vintage-guide h3 { font-size: 0.95rem; margin: 14px 0 6px; }
.vintage-guide p, .vintage-guide li { font-size: 0.92rem; }
.vintage-guide ul { padding-left: 18px; margin: 6px 0; }
.vintage-guide code { background: var(--surface-2); padding: 1px 6px; border-radius: 5px; font-size: 0.88em; }

@media (max-width: 400px) {
  .rpn-calc, .classic-calc { padding-left: 10px; padding-right: 10px; }
  .rpn-keys-top, .classic-keys { gap: 5px 5px; }
  .rpn-calc .vkey, .classic-calc .vkey { font-size: 0.74rem; }
}
