/* Secret Sharing shared secret should use normal body font (not monospace) */
#key.form-control {
  font-family: inherit;
}
/* === Layout: Header and Navbar === */
header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  z-index: 1000;
  background-color: rgb(250, 250, 250);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  color: #222c37;
}

/* Custom font for navbar marker; ensure /fonts/NotoSansMath-Regular.ttf exists at site root */
@font-face {
  font-family: "NavSymbols";
  src: url("/fonts/NotoSansMath-Regular.ttf") format("truetype");
  font-display: swap;
}

/* Site-wide Copperplate family (for lang switcher and headers) */
@font-face {
  font-family: "Copperplate";
  src: url("/fonts/Copperplate-01.ttf") format("truetype");
  font-display: swap;
  font-weight: 700;
  font-style: normal;
}

@font-face {
  font-family: "CopperplateGothicLight";
  src: url("/fonts/Copperplate-Gothic-Light-Regular.ttf") format("truetype");
  font-display: swap;
  font-weight: 700;
  font-style: normal;
}

/* Math font for consistent lowercase phi rendering */
@font-face {
  font-family: "NotoSansMath";
  src: url("/fonts/NotoSansMath-Regular.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

/* navbar fixed under header */
nav.navbar {
  position: fixed;
  top: 80px;
  /* adjust to match actual header height */
  left: 0;
  width: 100%;
  z-index: 999;
  background-color: rgb(250, 250, 250);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  margin-top: 1rem;
}

/* space to avoid content hidden behind fixed header + navbar */
/* body {
    padding-top: 150px;
    background-image: url("https://wallpapercave.com/wp/wp7123277.jpg");
    background-color: #FAFAFA;
/* use the same value on every page for consistent Y position
} */

*/ html {
  height: 100%;
  margin: 0;
}

/* Bitwise dynamic operand fade animations */
.fade-row {
  opacity: 1;
  transition: opacity 0.15s ease-in-out;
}

.fade-in,
.fade-in-initial {
  opacity: 0;
}

.fade-in {
  animation: fadeInRow 0.15s ease-in-out forwards;
}

.fade-out {
  opacity: 0;
}

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

body {
  /* Reserve vertical space for fixed header + navbar so content starts below */
  padding-top: 175px;
  background-image: url("https://wallpapercave.com/wp/wp7123277.jpg");
  background-position: center center;
  /* center the image */
  background-repeat: no-repeat;
  /* no tiling */
  background-size: cover;
  /* fill viewport, cropping if needed */
  background-attachment: fixed;
  /* optional: keeps image fixed for parallax effect */
  background-color: rgb(250, 250, 250);
  /* fallback color while image loads */
  color: #222c37;
}

/* === Footer font === */
@font-face {
  font-family: 'Edwardian';
  src: url('/fonts/EdwardianRegular.ttf') format('truetype');
  /* font-display: swap; */
  font-weight: 400;
  font-style: normal;
}

/* Augusta display font */
@font-face {
  font-family: "Augusta";
  src: url("/fonts/Augusta.otf") format("opentype");
  font-style: normal;
  font-weight: 400;
  /* font-display: swap; */
}

/* Local Copperplate (preferred for lang picker) */
@font-face {
  font-family: 'CopperplateGothicLight';
  src: url('/fonts/Copperplate-Gothic-Light-Regular.ttf') format('truetype');
  font-display: swap;
  font-weight: 400;
  font-style: normal;
}

/* UnifrakturMaguntia font for Spanish pages */
@font-face {
  font-family: "UnifrakturMaguntia";
  src: url("https://fonts.gstatic.com/s/unifrakturmaguntia/v20/WWXPlieVYwiGNomYU-ciRLRvEmK7oaVemGZM.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

/* === Language Switcher === */
.lang-switcher {
  position: static;
  margin-top: 1rem;
  margin-bottom: 2rem;
  z-index: 1001;
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: center;
}

.lang-switcher a {
  color: #a7b7c3;
  text-decoration: none;
  font-size: 1.1rem;
  padding: 0.25rem 0.5rem;
  display: inline-block;
  transition: color 120ms ease, transform 120ms ease;
  text-shadow: none;
  font-family: Copperplate, 'CopperplateGothicLight', "Copperplate Gothic Light", fantasy;
}

.lang-switcher a:hover {
  color: #222c37;
  text-shadow: none;
  transform: translateY(-2px);
}

.lang-switcher .separator {
  color: #a7b7c3;
  text-shadow: none;
  font-family: Copperplate, 'CopperplateGothicLight', "Copperplate Gothic Light", fantasy;
}

/* Language switcher on light background pages */
body:not(.dark-bg) .lang-switcher a,
body:not(.dark-bg) .lang-switcher .separator {
  color: #a7b7c3;
  text-shadow: none;
}

body:not(.dark-bg) .lang-switcher a:hover {
  color: #ffffff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}

@media (max-width: 768px) {
}

footer {
  font-family: "Augusta", "EdwardianRegular", "Edwardian Script ITC", Garamond, serif;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  /* Remove any fixed or absolute positioning so it stays at the bottom of content */
  position: static;
  bottom: unset;
  left: unset;
  right: unset;
  margin-top: 2rem;
  margin-bottom: 0.5rem;
  min-height: 2.5rem;
}

/* Horizontal scrollable navbar (desktop + mobile) */
.navbar-nav.flex-row {
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

.navbar-nav.flex-row::-webkit-scrollbar {
  height: 6px;
}

.navbar-nav.flex-row::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.15);
  border-radius: 3px;
}

.navbar-nav.flex-row::-webkit-scrollbar-track {
  background-color: transparent;
}

/* === Navbar links and hover marker === */
.navbar-nav .nav-link {
  font-weight: 500;
  padding: 0.75rem 1.25rem;
  position: relative;
  text-decoration: none;
  text-align: center;
}

.navbar-nav .nav-link::after {
  content: "🞁"; /* U+1F781 "UPWARDS TRIANGLE-HEADED ARROW TO BAR" */
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: -0.7em;
  font-size: 0.9em;
  color: #333;
  opacity: 0;
  transition: opacity 0.2s ease, bottom 0.2s ease;
  /* Force our embedded symbol font first; fall back to system fonts if it fails to load */
  font-family:
    "NavSymbols",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

.navbar-nav .nav-link:hover::after {
  opacity: 1;
}

/* === Dropdown sizing helpers === */
.algo-dropdown .btn {
  width: auto;
  white-space: nowrap;
}

.algo-dropdown .dropdown-menu {
  width: max-content;
  min-width: 0;
}

/* === Shared center layout for pages: ensures identical X/Y placement for labels ===
   Use this structure on all pages:
   <div class="container-fluid min-vh-100 overflow-auto py-5">
     <div class="center-column">
       <h2 class="converter-label">...</h2>
       <div class="card card-main">...</div>
     </div>
   </div>
*/
.center-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  /* centers children horizontally */
  gap: 1rem;
  padding: 1rem 0;
}

/* heading above the card: identical size, margin and alignment across pages */
.converter-label {
  font-size: 1rem;
  font-weight: 300;
  color: #222c37;
  margin: 0 0 0.75rem;
  /* matches spacing used on Number Base Converter */
  text-align: center;
  line-height: 1.2;
  width: 100%;
  max-width: 900px;
  /* match card-main max-width so centers visually */
  box-sizing: border-box;
}

.card-body {
  background-color: rgb(250, 250, 250);
  color: #222c37;
  padding-bottom: 2rem;
}

/* card sizing helper: keeps card the same visual width as w-50 while centering */
.card-main {
  width: 60%;
  /* wider than default */
  max-width: 1200px;
  /* increased visual cap */
  min-width: 320px;
  /* prevent collapse on narrow screens */
  margin: 0 auto;
  /* center horizontally */
  box-sizing: border-box;
}

/* === Form / card internals (shared) === */
.vertical-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

/* Default state: hidden */
.text-block {
  display: none; /* Hide the output box completely */
  width: 100%;
  max-width: 720px;
  flex-direction: column;
  gap: 0.5rem;
}

/* Visible state: show */
.text-block.visible {
  display: flex; /* Show the output box */
}

.text-block textarea {
  height: 260px;
  resize: vertical;
}

#output {
  height: 60px;
  resize: none;
}

.algo-center {
  display: flex;
  justify-content: center;
  align-items: center;
}

.algo-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

/* center-align labels inside text blocks */
.text-block>label.form-label,
.algo-center>label.form-label {
  display: block;
  width: 100%;
  text-align: center;
}

/* === Responsive adjustments (shared) === */
@media (max-width: 767.98px) {
  .card-main {
    width: 100%;
    max-width: 720px;
    padding: 0 1rem;
  }
}

/* Default: keep each section stacked so labels remain on top-left */
.card-body form>.mb-4,
.card-body form>.mb-0 {
  display: block;
  width: 100%;
  box-sizing: border-box;
}

/* keep input blocks full-width when stacked */
.card-body .row.g-2,
.card-body .mb-2 {
  width: 100%;
  min-width: 0;
}

/* Button container when stacked: center horizontally but keep it below inputs */
.card-body .mt-3.text-end {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  padding: 0.5rem 0;
  margin-left: 0;
  box-sizing: border-box;
}

/* On wider screens use a horizontal flex layout so labels/columns stay in place
   and the button is centered vertically in the row band */
@media (min-width: 768px) {

  .card-body form>.mb-4,
  .card-body form>.mb-0 {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
  }

  /* input area should take available horizontal space and keep Bootstrap columns */
  .card-body .row.g-2,
  .card-body .mb-2 {
    flex: 1 1 auto;
    min-width: 0;
  }

  /* center the button within the section's horizontal band without forcing label positions */
  .card-body .mt-3.text-end {
    display: flex;
    align-items: center;
    justify-content: center;
    width: auto;
    /* let flex placement handle positioning */
    margin-left: auto;
    padding: 0;
  }
}

/* Keep button intrinsic width and avoid label wrapping surprises */
.card-body .mt-3.text-end .btn {
  flex: 0 0 auto;
  white-space: nowrap;
  box-sizing: border-box;
}

@media (min-width: 768px) {

  .card-body form>.mb-4,
  .card-body form>.mb-0 {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
  }

  .card-body .row.g-2,
  .card-body .mb-2 {
    flex: 1 1 auto;
    min-width: 0;
  }

  /* Make the button container span the full flex line and center its contents */
  .card-body .mt-3.text-end {
    display: flex;
    align-items: center;
    justify-content: center;
    /* center horizontally */
    width: 100%;
    /* take whole row so centering is across the section */
    order: 2;
    /* ensure it sits after the inputs */
    padding: 0.5rem 0;
    margin-left: 0;
    box-sizing: border-box;
  }
}

/* center the text inside the menu */
.dropdown-menu {
  text-align: center;
  padding-left: 0.5rem;
  /* optional: tune horizontal padding */
  padding-right: 0.5rem;
}

/* center each dropdown item (works for anchor/button items and if items include icons) */
.dropdown-menu .dropdown-item {
  display: flex;
  justify-content: center;
  align-items: center;
  white-space: nowrap;
  /* optional: prevent unwanted wrapping */
}

/* persistent selected class (when added by JS) */
.dropdown-menu .dropdown-item.selected,
.dropdown-menu .dropdown-item.selected:focus,
.dropdown-menu .dropdown-item.selected:active {
  background-color: #333;
  /* dark gray */
  color: #fff;
}

/* override Bootstrap's momentary :focus/:active styling */
.dropdown-menu .dropdown-item:focus,
.dropdown-menu .dropdown-item:active,
.dropdown-menu .dropdown-item:focus:hover,
.dropdown-menu .dropdown-item:active:hover {
  background-color: #6C757D !important;
  color: #fff !important;
  box-shadow: none !important;
}

/* when dropdown is open Bootstrap may style items via .show on parent */
.dropdown.show .dropdown-menu .dropdown-item:focus,
.dropdown.show .dropdown-menu .dropdown-item:active {
  background-color: #6C757D !important;
  color: #fff !important;
}

/* if you use the .active class instead of .selected, include it too */
.dropdown-menu .dropdown-item.active,
.dropdown-menu .dropdown-item.active:focus,
.dropdown-menu .dropdown-item.active:active {
  background-color: #6C757D !important;
  color: #fff !important;
}

/* Case toggle button: override Bootstrap's active state to force outline style when not .active */
button#caseToggleBtn.btn.btn-outline-secondary.btn-sm:not(.active) {
  background-color: transparent !important;
  color: #6c757d !important;
  border-color: #6c757d !important;
}

button#caseToggleBtn.btn.btn-outline-secondary.btn-sm:not(.active):hover {
  background-color: #e2e6ea !important;
  color: #6c757d !important;
  border-color: #6c757d !important;
}

/* Case toggle button: ensure active state has filled background */
button#caseToggleBtn.btn.btn-outline-secondary.btn-sm.active {
  background-color: #6c757d !important;
  color: white !important;
  border-color: #6c757d !important;
}

button#caseToggleBtn.btn.btn-outline-secondary.btn-sm.active:hover {
  background-color: #5a6268 !important;
  color: white !important;
  border-color: #545b62 !important;
}

/* === Invalid Input Flash Animation === */
/* Softer, color-theory-compliant red with reduced saturation */
@keyframes flash-invalid {
  0% {
    border-color: #dc6b7a;
    box-shadow: 0 0 0 0.2rem rgba(220, 107, 122, 0.2);
  }
  50% {
    border-color: #dc6b7a;
    box-shadow: 0 0 0 0.3rem rgba(220, 107, 122, 0.25);
  }
  100% {
    border-color: #ced4da;
    box-shadow: none;
  }
}

.form-control.flash-invalid {
  animation: flash-invalid 0.5s ease-out;
}

/* Shared layout box used across calculators (matches Pairwise Key Establishment) */
.parameters-box {
  border: 1px solid #dee2e6;
  border-radius: 4px;
  background-color: transparent;
  width: 100%;
  max-width: 860px;
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin: 0 auto;
}

/* allow menu to size to its widest item */
.dropdown-menu {
  min-width: 0;           /* override Bootstrap default */
  width: max-content;     /* intrinsic width equals widest child */
  white-space: nowrap;    /* prevent wrapping so width reflects longest item */
}

/* keep the toggle at its natural size (no w-100) */
.dropdown-toggle {
  width: auto;
}

/* === CRT (Chinese Remainder Theorem) Widget Styling === */
#crt-systems-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#crt-systems-container .row {
  width: 100%;
}

/* Neutralize Bootstrap's red for .text-danger where app prefers default text color */
.text-danger {
  color: inherit !important;
}

.dropdown-menu {
  min-width: 100% !important;
}

/* === Page-specific card sizing === */
#ntp-card-main,
#hash-card-main {
  width: 50%;
  max-width: 900px;
  min-width: 320px;
  margin: 0 auto;
  box-sizing: border-box;
}

@media (max-width: 767.98px) {
  #ntp-card-main,
  #hash-card-main {
    width: 100%;
    max-width: 720px;
    padding: 0 0.5rem;
  }
}

/* === Keys label overlay above bordered key sections === */
.key-section {
  /* wrapper keeps label above the bordered box */
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
}

.key-section .keys-label {
  display: block;
  text-align: center;
  margin-bottom: 0.4rem;
  font-weight: 700;
}
