/* =========================================
   AccuLens Cross Cylinder Calculator – Styles (Cleaned)
   ========================================= */

/* ---------- Base ---------- */
* { box-sizing: border-box; }

:root{
  --ink:#0d2a54;
  --sub:#6b7b8f;
  --primary:#0a63ff;
  --primary-20:#98b8ff;
  --card:#ffffff;
  --panel:#f6fbff;
  --line:#cfe8ff;
  --panel-soft:#f1f7ff;
}

body{
  margin:0;
  padding:2rem;
  background:#f0f2f5;
  color:#333;
  font-family:'Segoe UI','Roboto','Helvetica Neue',Arial,sans-serif;
}

.logo{
  display:block;
  max-width:200px;
  margin:0 auto 1rem;
}

/* Main container */
.container{
  max-width:700px;
  width:100%;
  margin:0 auto;
  padding:2rem;
  background:var(--card);
  border-radius:10px;
  box-shadow:0 4px 12px rgba(0,0,0,.08);
}

/* Headings */
h2{
  margin:0 0 1.5rem;
  text-align:center;
  color:#00478f;
}

/* ---------- Form layout ---------- */
.form-group{
  display:flex;
  align-items:center;
  gap:1rem;
  flex-wrap:wrap;
  margin-bottom:1rem;
}
.form-group label{
  flex:1 0 100%;
  font-weight:600;
  margin-bottom:.25rem;
}
.form-group.inline{ flex-wrap:nowrap; gap:1rem; }
.form-group.inline input,
.form-group.inline select{ flex:1; min-width:0; }

/* Inputs & selects */
.form-group input,
.form-group select{
  width:100%;
  padding:.5rem;
  font-size:1rem;
  background:#fff;
  border:1px solid #ccc;
  border-radius:4px;
  transition:border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
input:focus, select:focus{
  outline:none;
  border-color:#1e90ff;
  box-shadow:0 0 5px rgba(30,144,255,.5);
  background:#eef5ff;
}

/* Vertex distance input tweaks */
#vertexDistance{
  flex:0 0 auto !important;
  width:80px !important; max-width:80px !important;
  text-align:center;
  font-size:1rem; padding:.4rem .5rem;
  border:1px solid #ccc; border-radius:4px;
  background:#fff;
}
#vertexDistance::-webkit-outer-spin-button,
#vertexDistance::-webkit-inner-spin-button{ -webkit-appearance:none; margin:0; }
#vertexDistance{ -moz-appearance:textfield; }
.form-group.inline label[for="vertexDistance"]{ flex:0 0 auto !important; margin-right:10px; }

/* ---------- Lens rotation mini-visual ---------- */
#lens-visual-wrapper{
  display:flex; align-items:center; justify-content:center;
  margin-left:.75rem; max-width:60px; max-height:60px; flex-shrink:0;
  height:48px;
}
#lens-visual-img{
  display:block;
  width:52px;
  height:52px;
  object-fit:contain;
  transform:rotate(0deg);
  transition:transform .35s ease;
}

/* ---------- Rotation choice cards ---------- */
.rot-flow{ display:flex; gap:1rem; margin:.5rem 0 .75rem; }
.rot-card{
  flex:1; padding:.85rem 1rem;
  border:2px solid #cce0ff; border-radius:8px;
  background:#fff; cursor:pointer;
  transition:border-color .2s, box-shadow .2s, background .2s;
  position:relative;
}
.rot-card:hover{ border-color:#007bff; box-shadow:0 2px 8px rgba(0,0,0,.04); }
.rot-card.active{ border-color:#007bff; background:#e9f2ff; }
.rot-title{ font-weight:700; margin-bottom:.25rem; color:var(--ink); }
.rot-desc{ font-size:.9rem; color:#555; }

/* Badge lives under the title; hide by default */
.rot-badge{
  position: static;
  display: none;                 /* don't render unless active */
  margin: .3rem 0 .25rem;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(0,123,255,.12);
  color: var(--ink);
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .2px;
  transform: none !important;
}

/* Only show when the card is active AND you've toggled .show in JS */
.rot-card.active .rot-badge.show{
  display: inline-block;
}

/* Extra guard: if somehow empty, hide it */
.rot-badge:empty{
  display: none !important;
}

.rot-card.active .rot-badge.show{ opacity:1; transform:translateY(0) scale(1); }

/* Soft-mute rotation row when “Keep original rotation” selected */
.rot-muted{ opacity:.6; }

/* ---------- Buttons ---------- */
.btn-primary{
  background:var(--primary); color:#fff;
  border:none; border-radius:10px;
  padding:.9rem 1.25rem;
  font-weight:700; font-size:1.05rem;
  min-width:200px;
  cursor:pointer;
  transition:transform .1s, box-shadow .2s, background .2s;
}
.btn-primary:hover{ transform:translateY(-1px); box-shadow:0 4px 10px rgba(0,0,0,.12); }
.btn-primary:disabled{ background:var(--primary-20); cursor:not-allowed; box-shadow:none; transform:none; }

.btn-ghost{
  background:transparent;
  border:1px solid var(--line);
  color:var(--ink);
  border-radius:8px;
  font-weight:600;
  padding:.55rem .9rem;
  cursor:pointer;
  transition:background .15s ease, border-color .15s ease;
}
.btn-ghost:hover{ background:var(--panel-soft); }
.btn-ghost--sm{ padding:.45rem .75rem; font-size:.95rem; }

/* Make the big button lift a touch on hover */
button:hover{
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0,0,0,.15);
  transition: .2s ease;
}
#calcBtn:disabled{
  background:var(--primary-20);
  cursor:not-allowed;
  box-shadow:none;
  transform:none;
}

/* ---------- Results & actions ---------- */
.result-wrap{
  margin-top:1rem;
  display:block; width:100%;
  flex:0 0 100%; clear:both;
}
.result-card{
  display:block; width:100%;
  margin:0; padding:.9rem 1rem;
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:8px;
  animation: fadeIn .18s ease-out;
}
@keyframes fadeIn{ from{opacity:0; transform:translateY(2px);} to{opacity:1; transform:none;} }

.final-line{
  font-size:1.25rem; font-weight:800; color:var(--ink);
  margin:.25rem 0 .35rem;
  font-feature-settings:"tnum" 1; font-variant-numeric:tabular-nums;
}
.final-line .label{ color:#224b92; margin-right:.25rem; font-weight:700; }

.result-card .note{ margin-top:.35rem; color:var(--sub); font-size:.9rem; }

/* Copy + help row (appears after result) */
.post-actions{ display:none; width:100%; margin-top:.6rem; transition:opacity .3s ease; }
.help-link{ margin-top:.6rem; text-align:left; width:100%; }
.help-link a{ font-size:.85rem; color:#007bff; text-decoration:none; }
.help-link a:hover{ text-decoration:underline; }

/* ---------- Misc legacy ---------- */
.checkbox-wrapper{ display:flex; align-items:center; gap:.5rem; margin-bottom:.5rem; }
.checkbox-wrapper input[type="checkbox"]{ margin:0; transform:scale(1.2); }
.note{ font-size:.85rem; color:#666; line-height:1.4; }
#output em{ display:block; font-size:.8rem; color:#666; margin-bottom:.5rem; }
.vertex-block{ display:block; font-size:.75rem; color:#666; line-height:1.2; margin:0 0 .5rem; }
.transpose-note{ display:block; font-size:.75rem; color:#888; margin-bottom:.5rem; line-height:1.2; }

/* Toast */
.toast{
  position:fixed; right:16px; bottom:16px;
  background:var(--primary); color:#fff;
  padding:.5rem .75rem; border-radius:8px;
  box-shadow:0 6px 20px rgba(0,0,0,.15);
  opacity:0; transform:translateY(6px);
  transition:.2s ease;
}
.toast.show{ opacity:1; transform:translateY(0); }

/* ---------- Top row alignment ---------- */
.top-row { align-items: center !important; }

.micro-label{
  font-size: .82rem;
  color: var(--sub);
  margin-bottom: .25rem;
  line-height: 1;
}

.rot-chunk{
  display: flex;
  flex-direction: column;
  gap: .25rem;
  margin-left: 1rem;
  padding-left: 1rem;
  border-left: 1px solid var(--line);
}

.rot-controls{ display:flex; align-items:center; gap:.6rem; }

#rotation{ max-width:80px; text-align:center; }
#rotationDirection{ max-width:220px; white-space:nowrap; }

/* ---------- Responsive tweaks ---------- */
@media (max-width:600px){
  body{ padding:1rem; }
  .container{ padding:1rem; }

  .form-group.inline{ flex-wrap:wrap; }
  .form-group.inline input,
  .form-group.inline select{ flex:0 0 35%; min-width:0; }

  .post-actions{ display:block; } /* still faded by JS until result exists */

  /* Mobile: remove divider on rotation chunk */
  .rot-chunk{ border-left:none; margin-left:0; padding-left:0; }
  #rotationDirection{ max-width:100%; }

  /* Fix badge overlap on mobile and center it under the title */
  .rot-badge{
    position:static;
    display:block;
    margin:.25rem auto 0;  /* centered under title */
    transform:none !important;
  }
  .rot-title{ display:block; }
}

/* ===== Desktop compaction (>=1100px) ===== */
@media (min-width:1100px){
  /* Card sizing */
  .container{ display:block !important; max-width:820px; margin:0 auto; padding:1.25rem 1.5rem; }
  .logo{ max-width:150px; margin:0 auto .4rem; }
  h2{ margin:.2rem 0 .8rem; font-size:1.45rem; }

  /* Rows & inputs */
  .form-group{ margin-bottom:.6rem; gap:.6rem; }
  .form-group.inline{ gap:.6rem; flex-wrap:nowrap; align-items:center; }

  .form-group.inline input[type="text"],
  .form-group.inline input[type="number"],
  .form-group.inline select{
    flex:0 0 auto;
    max-width:92px;
    text-align:center;
    font-size:.95rem;
    padding:.38rem .55rem;
  }
  #vertexDistance{ max-width:70px !important; padding:.35rem .5rem; }

  /* Rotation cards row */
  .rot-flow{ gap:.75rem; margin:.4rem 0 .6rem; }
  .rot-card{ padding:.7rem .85rem; }

  /* Rotation direction select wider for text */
  #rotationDirection{ max-width:160px; }

  /* Lens mini-visual size */
  #lens-visual-wrapper{ max-width:60px; max-height:60px; }

  /* Vertex label spacing */
  .form-group.inline label[for="vertexDistance"]{
    margin:0 0 0 .5rem; font-weight:600;
  }

  /* Action row + result alignment */
  .action-row{ display:flex; align-items:center; gap:.75rem; flex-wrap:nowrap; margin-bottom:.5rem; }
  .result-wrap{ margin-top:0; flex:1 1 auto; }

  /* Buttons */
  .btn-primary{ min-width:160px; padding:.7rem 1rem; font-size:1rem; }
  .btn-ghost{ padding:.45rem .75rem; }

  /* Footer spacing */
  .post-actions{ margin-top:.4rem; }
  .help-link{ margin-top:.5rem; }
}

.input-disabled {
  background: #f5f5f7 !important;
  color: #7a7a7a !important;
  cursor: not-allowed !important;
}

.rot-card.rot-card-disabled {
  opacity: .5;
  pointer-events: none;
  filter: grayscale(10%);
}


/* .axis-note {
  font-size: 0.8rem;
  color: #667085;
  margin-top: 4px;
  visibility: hidden; 
} */

.micro-note {
  font-size: 0.85rem;
  color: #667085;
  margin-top: 6px;
}


.dev-tools {
  margin: 8px 4px 0;
  display: flex;
  gap: 12px;
}

.btn-secondary {
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  color: #1e40af;
  padding: 8px 12px;
  border-radius: 10px;
  font-weight: 600;
}

.btn-link {
  background: transparent;
  border: none;
  color: #475467;
  text-decoration: underline;
  padding: 8px 0;
}

.test-results {
  margin-top: 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px;
  overflow: auto;
  max-height: 360px;
}

.test-results table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.test-results th, .test-results td {
  border-bottom: 1px solid #e5e7eb;
  padding: 8px 10px;
  text-align: left;
  white-space: nowrap;
}

.test-results th { background: #f1f5f9; }
