/* ===================================
   CANATUS Engineering - Main Stylesheet
   Django Template Styles
   =================================== */

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(100%); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

.animate-fade-in {
  animation: fadeIn 0.5s ease-out both;
}

.animate-fade-in-delay-1 {
  animation: fadeIn 0.6s ease-out 0.1s both;
}

.animate-fade-in-delay-2 {
  animation: fadeIn 0.6s ease-out 0.2s both;
}

.animate-fade-in-delay-3 {
  animation: fadeIn 0.6s ease-out 0.3s both;
}

/* Toast auto-dismiss */
.toast-message {
  animation: slideIn 0.3s ease-out, fadeOut 0.3s ease-in 4.7s forwards;
}

/* Smooth scroll for anchor links */
html {
  scroll-behavior: smooth;
}

/* Focus styles */
*:focus-visible {
  outline: 2px solid hsl(211 65% 45%);
  outline-offset: 2px;
}

/* Selection color */
::selection {
  background: hsl(211 65% 45% / 0.2);
}

/* ===================================
   Hero gradient overlay
   =================================== */
.hero-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, hsl(215 25% 15%) 0%, hsl(211 50% 25%) 100%);
}

/* ===================================
   Calculator Page
   Scoped to body.calculator-page so these
   rules win over Tailwind CDN's injected styles.
   =================================== */
body.calculator-page .section-header {
  background: hsl(215 25% 20%);
  color: white;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 6px 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

body.calculator-page .field-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 4px 12px;
  border-bottom: 1px solid hsl(214 20% 92%);
  min-height: 36px;
  font-size: 0.82rem;
}

body.calculator-page .field-row.hidden { display: none; }

body.calculator-page .field-row.stress-header-row {
  gap: clamp(12px, 3vw, 40px);
}

body.calculator-page .field-row:last-child { border-bottom: none; }
body.calculator-page .field-row label { flex: 1; min-width: 0; color: hsl(215 25% 15%); }
body.calculator-page .field-row .symbol { width: 50px; text-align: center; color: hsl(215 10% 50%); font-style: italic; flex-shrink: 0; }
body.calculator-page .field-row .unit { width: 48px; text-align: center; color: hsl(215 10% 50%); flex-shrink: 0; font-size: 0.78rem; }
body.calculator-page .field-row input,
body.calculator-page .field-row select {
  width: 90px;
  text-align: right;
  border: 1px solid hsl(214 20% 88%);
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 0.82rem;
  background: hsl(210 40% 96%);
  flex-shrink: 0;
}
body.calculator-page .field-row input:focus,
body.calculator-page .field-row select:focus {
  outline: none;
  border-color: hsl(211 65% 45%);
  box-shadow: 0 0 0 2px hsla(211, 65%, 45%, 0.15);
}
body.calculator-page .field-row select { width: 130px; text-align: left; }
body.calculator-page .field-row .val2 { width: 80px; text-align: right; flex-shrink: 0; }

body.calculator-page .result-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 3px 12px;
  font-size: 0.82rem;
  min-height: 28px;
}
body.calculator-page .result-row .rlabel { flex: 1; }
body.calculator-page .result-row .rsym { width: 56px; text-align: center; color: hsl(215 10% 50%); font-style: italic; }
body.calculator-page .result-row .runit { width: 52px; text-align: center; color: hsl(215 10% 50%); font-size: 0.78rem; }
body.calculator-page .result-row .rval { width: 80px; text-align: right; font-weight: 600; font-family: ui-monospace, SFMono-Regular, monospace; }
body.calculator-page .result-row .rval2 { width: 80px; text-align: right; font-weight: 600; font-family: ui-monospace, SFMono-Regular, monospace; }

/* Result-row cells rendered as editable inputs should match the input-form fields */
body.calculator-page .result-row input.rval,
body.calculator-page .result-row input.rval2,
body.calculator-page .result-row select.rval {
  border: 1px solid hsl(214 20% 88%);
  border-radius: 4px;
  padding: 3px 6px;
  background: hsl(210 40% 96%);
  box-sizing: border-box;
  flex-shrink: 0;
}
body.calculator-page .result-row select.rval { width: 80px; text-align: right; font-weight: 600; font-family: ui-monospace, SFMono-Regular, monospace; }
body.calculator-page .result-row input.rval:focus,
body.calculator-page .result-row input.rval2:focus,
body.calculator-page .result-row select.rval:focus {
  outline: none;
  border-color: hsl(211 65% 45%);
  box-shadow: 0 0 0 2px hsla(211, 65%, 45%, 0.15);
}

body.calculator-page .result-row--margin-header { padding-top: 4px; }
body.calculator-page .result-row--margin-header .rval,
body.calculator-page .result-row--margin-header .rval2 { font-weight: 600; font-size: 0.75rem; }
body.calculator-page .result-row--accept-row { padding: 8px 12px; }

body.calculator-page .result-section-header {
  background: hsl(0 0% 96%);
  font-weight: 700;
  font-size: 0.8rem;
  padding: 5px 12px;
  border-top: 2px solid hsl(215 25% 20%);
  border-bottom: 1px solid hsl(214 20% 88%);
}

body.calculator-page .pass { color: hsl(142 71% 35%); }
body.calculator-page .fail { color: hsl(0 72% 51%); }

body.calculator-page .highlight-cell {
  background: hsl(0 85% 95%);
  border: 1px solid hsl(0 72% 51%);
  border-radius: 3px;
  padding: 1px 6px;
}

@media print {
  .no-print { display: none !important; }
  body { font-size: 11px; }
}

/* ===================================
   Calculator Page - Responsive
   Below desktop (lg = 1024px) the input
   and results panels stack vertically.
   These rules shrink the dense form rows
   so they fit tablet and phone widths
   without horizontal overflow.
   =================================== */

/* Tablet (<= 1023px): mild gap tightening */
@media (max-width: 1023px) {
  body.calculator-page .field-row { gap: 0.4rem; }
  body.calculator-page .result-row { gap: 0.4rem; }
}

/* Medium (<= 767px): shrink fixed widths */
@media (max-width: 767px) {
  body.calculator-page .section-header {
    font-size: 0.75rem;
    padding: 5px 10px;
  }
  body.calculator-page .field-row {
    padding: 4px 10px;
    font-size: 0.78rem;
  }
  body.calculator-page .field-row .symbol { width: 42px; }
  body.calculator-page .field-row .unit { width: 42px; font-size: 0.72rem; }
  body.calculator-page .field-row input { width: 80px; }
  body.calculator-page .field-row select { width: 110px; }
  body.calculator-page .field-row .val2 { width: 70px; }

  body.calculator-page .result-row {
    padding: 3px 10px;
    font-size: 0.78rem;
  }
  body.calculator-page .result-row .rsym { width: 48px; }
  body.calculator-page .result-row .runit { width: 44px; font-size: 0.72rem; }
  body.calculator-page .result-row .rval { width: 70px; }
  body.calculator-page .result-row .rval2 { width: 70px; }
  body.calculator-page .result-row select.rval { width: 70px; }
  body.calculator-page .result-section-header {
    font-size: 0.75rem;
    padding: 5px 10px;
  }
}

/* Small (<= 639px): wrap labels, smaller fields */
@media (max-width: 639px) {
  body.calculator-page .section-header {
    font-size: 0.72rem;
    padding: 5px 8px;
    letter-spacing: 0.03em;
  }
  body.calculator-page .field-row {
    padding: 4px 8px;
    gap: 0.35rem;
    font-size: 0.75rem;
    flex-wrap: wrap;
  }
  body.calculator-page .field-row label {
    flex: 1 1 130px;
    min-width: 0;
  }
  body.calculator-page .field-row .symbol { width: 34px; font-size: 0.72rem; }
  body.calculator-page .field-row .unit { width: 38px; font-size: 0.68rem; }
  body.calculator-page .field-row input {
    width: 70px;
    padding: 3px 5px;
    font-size: 0.75rem;
  }
  body.calculator-page .field-row select {
    width: 100px;
    padding: 3px 5px;
    font-size: 0.75rem;
  }
  body.calculator-page .field-row .val2 { width: 60px; }
  body.calculator-page .field-row.stress-header-row {
    gap: clamp(6px, 2vw, 16px);
  }

  body.calculator-page .result-row {
    padding: 3px 8px;
    gap: 0.35rem;
    font-size: 0.75rem;
    flex-wrap: wrap;
  }
  body.calculator-page .result-row .rlabel { flex: 1 1 130px; min-width: 0; }
  body.calculator-page .result-row .rsym { width: 42px; }
  body.calculator-page .result-row .runit { width: 38px; font-size: 0.68rem; }
  body.calculator-page .result-row .rval { width: 60px; font-size: 0.75rem; }
  body.calculator-page .result-row .rval2 { width: 60px; font-size: 0.75rem; }
  body.calculator-page .result-row input.rval,
  body.calculator-page .result-row input.rval2,
  body.calculator-page .result-row select.rval {
    padding: 3px 5px;
    font-size: 0.75rem;
  }
  body.calculator-page .result-row select.rval { width: 70px; }
  body.calculator-page .result-section-header {
    font-size: 0.72rem;
    padding: 5px 8px;
  }
}

/* Very small (<= 380px): stack label above row */
@media (max-width: 380px) {
  body.calculator-page .field-row {
    padding: 4px 6px;
  }
  body.calculator-page .field-row label,
  body.calculator-page .result-row .rlabel {
    flex: 1 1 100%;
  }
  body.calculator-page .field-row input,
  body.calculator-page .field-row select {
    flex: 1 1 auto;
  }
}
