/**
 * Calculator page — iOS Calculator–inspired (black + #ff9f0a orange keys).
 * Scoped under .calc-page / .iphone-calc.
 */

.calc-page {
  padding-bottom: var(--section-y);
}

.calc-hero {
  padding-top: clamp(1.5rem, 5vw, 2.75rem);
  padding-bottom: 0.75rem;
}

.calc-hero h1 {
  margin: 0 0 0.4rem;
  font-family: var(--font-display);
  font-size: clamp(1.65rem, 3.5vw, 2rem);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.calc-hero__lead {
  margin: 0;
  max-width: 52ch;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.calc-page-stage {
  padding-top: clamp(0.75rem, 3vw, 1.5rem);
  padding-bottom: 0.5rem;
  display: flex;
  justify-content: center;
}

/* ——— Floating “phone” chassis ——— */
.iphone-calc-wrap {
  perspective: 1200px;
  width: 100%;
  max-width: 22.5rem;
}

.iphone-calc__device {
  --ip-black: #000000;
  --ip-key: #3a3a3c;
  --ip-fn: #a6a6a6;
  --ip-orange: #ff9f0a;
  --ip-line: rgba(255, 255, 255, 0.09);

  border-radius: 2.35rem;
  padding: 0.65rem;
  background: linear-gradient(150deg, #181818 0%, #000 45%, #0c0c0c 100%);
  box-shadow:
    0 4px 8px rgba(0, 0, 0, 0.35),
    0 28px 56px -16px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transform: rotateX(1.5deg);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

@media (hover: hover) and (pointer: fine) {
  .iphone-calc__device:hover {
    transform: rotateX(0deg) translateY(-2px);
    box-shadow:
      0 8px 16px rgba(0, 0, 0, 0.3),
      0 32px 60px -14px rgba(0, 0, 0, 0.58),
      inset 0 1px 0 rgba(255, 255, 255, 0.08);
  }
}

.iphone-calc__device {
  border-radius: 1.9rem;
  overflow: hidden;
}

/* LCD */
.iphone-calc__lcd {
  padding: 1rem 1rem 0.5rem;
  min-height: 10.5rem;
  background: var(--ip-black);
}

.iphone-calc__lcd-hint {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.38);
  text-align: right;
  margin-bottom: 0.4rem;
}

.iphone-calc__lcd-stack {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.7rem;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.42);
  text-align: right;
  max-height: 6.5rem;
  overflow-y: auto;
  margin-bottom: 0.35rem;
  scrollbar-width: thin;
  scrollbar-color: var(--ip-orange) transparent;
}

.iphone-calc__lcd-row {
  display: grid;
  grid-template-columns: 4.5rem 1fr;
  gap: 0.35rem;
  margin-bottom: 0.12rem;
}

.iphone-calc__lcd-k {
  text-align: left;
  color: rgba(255, 255, 255, 0.32);
}

.iphone-calc__lcd-v {
  color: rgba(255, 255, 255, 0.78);
  word-break: break-word;
}

.iphone-calc__lcd-row--sub {
  margin-top: 0.35rem;
  padding-top: 0.4rem;
  border-top: 1px solid var(--ip-line);
}

.iphone-calc__lcd-row--sub .iphone-calc__lcd-k {
  color: rgba(255, 255, 255, 0.55);
}

.iphone-calc__lcd-row--svc .iphone-calc__lcd-k {
  color: rgba(255, 159, 10, 0.85);
}

.iphone-calc__lcd-row--svc .iphone-calc__lcd-v {
  color: #ffb84d;
}

.iphone-calc__lcd-total {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: clamp(2rem, 9vw, 2.6rem);
  font-weight: 300;
  color: #fafafa;
  text-align: right;
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.iphone-calc__lcd-note {
  margin: 0.45rem 0 0;
  font-size: 0.65rem;
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.34);
  text-align: right;
}

/* Keypad */
.iphone-calc__pad {
  padding: 0.65rem 0.75rem 0.85rem;
  background: var(--ip-black);
  border-top: 1px solid var(--ip-line);
}

.iphone-calc__lbl {
  display: block;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.35);
  margin: 0.45rem 0 0.35rem;
}

.iphone-calc__lbl:first-child {
  margin-top: 0;
}

.iphone-calc__fs {
  margin: 0;
  padding: 0;
  border: none;
  min-width: 0;
}

.iphone-calc__fs .iphone-calc__lbl {
  padding: 0;
}

.iphone-calc__inset {
  width: 100%;
  margin: 0 0 0.2rem;
  padding: 0.6rem 1rem;
  border: none;
  border-radius: 999px;
  background: #1c1c1e;
  color: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.28rem;
  text-align: right;
  outline: none;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.5);
}

.iphone-calc__inset:focus {
  box-shadow:
    inset 0 2px 10px rgba(0, 0, 0, 0.5),
    0 0 0 2px rgba(255, 159, 10, 0.45);
}

.iphone-calc__grid {
  display: grid;
  gap: 0.55rem;
}

.iphone-calc__grid--4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.iphone-calc-key {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 3.1rem;
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.iphone-calc-key:active {
  transform: scale(0.96);
  filter: brightness(1.1);
}

.iphone-calc-key:focus-within {
  outline: 2px solid var(--ip-orange);
  outline-offset: 2px;
  border-radius: 999px;
}

.iphone-calc-key--ghost {
  visibility: hidden;
  pointer-events: none;
  min-height: 3.1rem;
}

/* Period = circular dark keys; selected = orange like operators */
.iphone-calc-key--period .iphone-calc-key__face {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 3.1rem;
  border-radius: 999px;
  background: var(--ip-key);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  transition: background 0.12s ease, color 0.12s ease;
}

.iphone-calc-key--period:has(input:checked) .iphone-calc-key__face {
  background: var(--ip-orange);
  color: #fff;
}

/* Toggle rows */
.iphone-calc-key--tog .iphone-calc-key__tog {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 2.85rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  background: var(--ip-key);
  color: rgba(255, 255, 255, 0.92);
  font-size: 0.74rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.2;
  transition: background 0.12s ease, box-shadow 0.12s ease;
}

.iphone-calc-key--tog:has(input:checked) .iphone-calc-key__tog {
  background: var(--ip-orange);
  color: #fff;
  box-shadow: 0 0 0 1px rgba(255, 200, 120, 0.35);
}

.iphone-calc-key--2 {
  grid-column: span 2;
}

.iphone-calc-key--4 {
  grid-column: span 4;
}

.iphone-calc__micro {
  margin: 0.35rem 0 0.5rem;
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.35);
  text-align: center;
}

.iphone-calc__micro a {
  color: rgba(125, 211, 252, 0.95);
}

.iphone-calc__fine {
  margin: 0;
  padding: 0.5rem 0.85rem 0.65rem;
  font-size: 0.66rem;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.38);
  background: var(--ip-black);
}

.iphone-calc__fine strong {
  color: rgba(255, 255, 255, 0.55);
}

main .iphone-calc__fine a {
  color: #ffb84d;
  font-weight: 600;
}

main .iphone-calc__fine a:hover {
  color: #ffd18a;
}

/* Breakdown */
.iphone-calc__details {
  margin: 0;
  padding: 0 0.65rem 0.65rem;
  background: var(--ip-black);
  border-top: 1px solid var(--ip-line);
}

.iphone-calc__details[hidden] {
  display: none !important;
}

.iphone-calc__details summary {
  list-style: none;
  padding: 0.55rem 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.55);
  cursor: pointer;
  user-select: none;
}

.iphone-calc__details summary::-webkit-details-marker {
  display: none;
}

.iphone-calc__details-body {
  padding: 0 0.35rem 0.5rem;
}

.iphone-calc__details-note {
  margin: 0 0 0.5rem;
  font-size: 0.68rem;
  color: rgba(255, 255, 255, 0.4);
}

.iphone-calc__details .table-wrap {
  border-radius: 0.55rem;
  overflow: hidden;
  border: 1px solid var(--ip-line);
}

.iphone-calc__details table {
  width: 100%;
  font-size: 0.68rem;
  border-collapse: collapse;
  background: #111;
}

.iphone-calc__details th,
.iphone-calc__details td {
  padding: 0.35rem 0.45rem;
  border-bottom: 1px solid var(--ip-line);
  color: rgba(255, 255, 255, 0.82);
}

.iphone-calc__details thead th {
  background: #1a1a1a;
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.iphone-calc__cite {
  margin: 0;
  padding: 0.45rem 0.85rem 0.65rem;
  font-size: 0.6rem !important;
  line-height: 1.4 !important;
  color: rgba(255, 255, 255, 0.28) !important;
  background: var(--ip-black);
  border-top: 1px solid var(--ip-line);
}

/* Equals-row CTAs */
.iphone-calc__cta-row {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0 0.75rem 0.85rem;
  background: var(--ip-black);
}

.iphone-calc__cta {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 3.1rem;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none;
  letter-spacing: 0.02em;
  transition: filter 0.12s ease, transform 0.08s ease;
}

.iphone-calc__cta:active {
  transform: scale(0.98);
}

.iphone-calc__cta--eq {
  background: var(--ip-orange);
  color: #fff !important;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.28);
}

.iphone-calc__cta--eq:hover {
  color: #fff !important;
  filter: brightness(1.08);
}

.iphone-calc__cta--fn {
  background: var(--ip-key);
  color: rgba(255, 255, 255, 0.95) !important;
  font-weight: 600;
}

.iphone-calc__cta--fn:hover {
  color: #fff !important;
  filter: brightness(1.12);
}

@media (max-width: 400px) {
  .iphone-calc-wrap {
    max-width: 100%;
  }

  .iphone-calc__device {
    transform: none;
  }

  .iphone-calc-key--period .iphone-calc-key__face {
    font-size: 0.7rem;
  }
}
