/* Reusable UI components */

/* Header */
.siteHeader{
  padding-top: var(--safe-top);

  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: linear-gradient(180deg, color-mix(in srgb, var(--bg) 84%, transparent) 0%, color-mix(in srgb, var(--bg) 60%, transparent) 100%);
  border-bottom: 1px solid var(--border);
}

.headerRow{
  height: var(--header-h);
  display:flex;
  align-items:center;
  /* Keep the brand locked to the left on desktop */
  justify-content:flex-start;
  gap: var(--space-4);
  flex-wrap: nowrap;
}

.brand{
  display:flex;
  align-items:center;
  gap: 12px;
  min-width: auto;
  flex-shrink: 0;
  margin-right: 6px;
}

.brandMark{
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.85), rgba(255,255,255,0.15) 45%, transparent 70%),
              linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 0 6px rgba(100,210,255,0.08), 0 0 40px rgba(100,210,255,0.18);
}

.brandName{
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.82rem;
  color: var(--muted);
}

.nav{
  display:flex;
  align-items:center;
  gap: 10px;
  padding: 6px;
  border:1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  flex-shrink: 1;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  /* Center nav between brand and actions (desktop) */
  margin-inline: auto;
}

.nav::-webkit-scrollbar{ display:none; }

.nav a{
  position:relative;
  padding: 10px 14px;
  border-radius: 999px;
  color: var(--muted);
  transition: background var(--dur-2) var(--ease), color var(--dur-2) var(--ease);
  white-space: nowrap;
}

.nav a:hover{ background: var(--surface-2); color: var(--text); }

.nav a[aria-current="page"]{
  background: linear-gradient(135deg, rgba(100,210,255,0.16), rgba(167,139,250,0.12));
  color: var(--text);
  box-shadow: 0 0 0 1px var(--border) inset;
}

.headerActions{
  display:flex;
  align-items:center;
  justify-content:flex-end;
  gap: 10px;
  min-width: auto;
  flex-shrink: 0;
  flex-wrap: wrap;
  margin-left: auto;
}

/* Mobile menu */
.menuBtn{
  display:none;
  border:1px solid var(--border);
  background: var(--surface);
  padding: 10px 12px;
  border-radius: 14px;
}

.mobileNav{
  display:none;
  padding: var(--space-5) 0 var(--space-6);
}

.mobileNav .nav{
  flex-wrap: wrap;
  justify-content:flex-start;
  border-radius: 18px;
}

/* Buttons */
.btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap: 10px;
  border-radius: 999px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: transform var(--dur-1) var(--ease), background var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease);
  user-select:none;
}

.btn:hover{ background: var(--surface-2); transform: translateY(-1px); }
.btn:active{ transform: translateY(0px) scale(0.99); }

.btn--primary{
  border-color: rgba(100,210,255,0.25);
  background: linear-gradient(135deg, rgba(100,210,255,0.22), rgba(167,139,250,0.16));
  box-shadow: var(--shadow-glow);
}

.btn--ghost{
  background: transparent;
}

.btn--small{
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 0.95rem;
}

.badge{
  display:inline-flex;
  align-items:center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.88rem;
}

.card{
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}

.card--glass{
  background: linear-gradient(180deg, var(--surface-2) 0%, var(--surface) 100%);
  box-shadow: var(--shadow-glow);
}

.cardPad{ padding: clamp(18px, 2.1vw, 26px); }

.grid{
  display:grid;
  gap: var(--space-6);
}

.grid2{ grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid3{ grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid4{ grid-template-columns: repeat(4, minmax(0,1fr)); }

.sectionTitle{
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  gap: var(--space-6);
  margin-bottom: var(--space-7);
}
.sectionTitle p{ max-width: 56ch; }

/* Footer */
.siteFooter{
  border-top: 1px solid var(--border);
  padding: var(--space-7) 0;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
}

.footerGrid{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap: var(--space-6);
  flex-wrap:wrap;
}

.footerLinks{
  display:flex;
  gap: 12px;
  flex-wrap:wrap;
}

.footerLinks a{
  color: var(--muted);
  padding: 8px 10px;
  border-radius: 12px;
}

.footerLinks a:hover{ background: var(--surface-2); color: var(--text); }

/* Modal */
.modal{
  position:fixed;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 24px;
  background: rgba(0,0,0,0.62);
  opacity:0;
  pointer-events:none;
  transition: opacity var(--dur-2) var(--ease);
  z-index: 100;
}

.modal[aria-hidden="false"]{ opacity:1; pointer-events:auto; }

.modalCard{
  width: min(640px, 100%);
  border:1px solid var(--border);
  background: color-mix(in srgb, var(--bg-2) 78%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 22px;
  box-shadow: var(--shadow-md);
}

.modalTop{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 12px;
  padding: 18px 18px 0;
}

.modalTop b{ font-size: 1.05rem; }

.iconBtn{
  border:1px solid var(--border);
  background: var(--surface);
  border-radius: 14px;
  padding: 8px 10px;
  cursor:pointer;
  color: var(--text);
}

.iconBtn:hover{ background: var(--surface-2); }

.modalBody{ padding: 16px 18px 18px; }

.textarea{
  width:100%;
  min-height: 160px;
  resize:none;
  padding: 14px 14px;
  border-radius: 16px;
  border:1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.modalActions{
  display:flex;
  flex-wrap:wrap;
  gap: 10px;
  margin-top: 12px;
}

/* Input fields */
.input{
  width: 100%;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--dur-2) var(--ease);
}

.input:focus{
  outline: none;
  border-color: var(--accent);
}

.input::placeholder{
  color: var(--muted-2);
}

/* Responsive breakpoints */
@media (max-width: 980px){
  .headerRow{
    height: auto;
    flex-wrap: wrap;
    padding: 10px 0;
    gap: var(--space-3);
  }

  .brand{ 
    min-width: 0;
    flex: 0 0 auto;
  }
  
  .headerActions{ 
    min-width: 0; 
    flex-wrap: wrap;
    gap: 8px;
  }

  .nav{
    order: 3;
    width: 100%;
    justify-content: center;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  .grid4{ grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid3{ grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 760px){
  .headerRow > .nav{ 
    display:none; 
  }
  
  .menuBtn{ 
    display:inline-flex; 
  }
  
  .mobileNav{ 
    display:none; 
  }
  
  .mobileNav[data-open="true"]{ 
    display:block; 
  }
  
  .mobileNav .nav{ 
    display:flex; 
  }
  
  .headerActions{
    gap: 8px;
    flex-wrap: wrap;
  }
  
  .headerActions > a.btn:not(.btn--primary){ 
    display:none; 
  }
  
  .headerActions .menuBtn,
  .headerActions [data-theme-toggle],
  .headerActions .btn--primary,
  .headerActions .badge,
  .headerActions .clock,
  .headerActions .terminalStatus {
    display: inline-flex !important;
  }
  
  .grid2{ 
    grid-template-columns: 1fr; 
  }
  
  #requestKeyBtn{ 
    display:none; 
  }

  .brand{ min-width: unset; }
  .headerActions{ min-width: unset; }
}

@media (max-width: 520px){
  .grid3, .grid4{ grid-template-columns: 1fr; }
  
  .sectionTitle{
    flex-direction: column;
    align-items: flex-start;
  }
  
  .footerGrid{
    flex-direction: column;
  }
}

/* Theme helpers */
:root[data-theme="light"] .siteHeader{
  padding-top: var(--safe-top);
 
  backdrop-filter: blur(14px); 
}

:root[data-theme="light"] .modal{ 
  background: rgba(10,12,18,0.45); 
}


/* Autofill Safari/Chrome lisible */
input:-webkit-autofill,
textarea:-webkit-autofill{
  -webkit-text-fill-color: var(--text);
  transition: background-color 9999s ease-in-out 0s;
  box-shadow: 0 0 0 1000px color-mix(in srgb, var(--surface) 85%, transparent) inset;
}
