/* ===========================
   Global layout
   =========================== */

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-color: #0f172a;
  color: #e5e7eb;
  line-height: 1.6;
}

/* Global link colors (avoid purple visited links on dark bg) */
a {
  color: #38bdf8;
  text-decoration: none;
}

a:visited {
  color: #38bdf8;
}

a:hover {
  color: #0ea5e9;
}

/* ===========================
   Header / Navigation
   =========================== */

header {
  background: #111827;
  padding: 1rem 2rem;
  border-bottom: 1px solid #1f2937;
  display: flex;
  justify-content: center;
}

.nav-container {
  width: 100%;
  max-width: 1200px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header h1 {
  font-size: 1.25rem;
  margin: 0;
  color: #f9fafb;
}

/* Main nav links (Home, Tutorials, etc.) */
.nav-links {
  display: flex;
  align-items: center;
  gap: 1.75rem;
  font-size: 0.95rem;
}

.nav-links > a {
  color: #9ca3af;
  text-decoration: none;
}

.nav-links > a:hover {
  color: #38bdf8;
}

/* ===========================
   Profile avatar + dropdown
   =========================== */

.nav-profile {
  position: relative;
  display: inline-flex;
  align-items: center;
}

/* The avatar button itself */
.nav-profile-trigger {
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Avatar image */
.nav-avatar-img {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  object-fit: cover;
  border: 2px solid #38bdf8;
}

/* Initials fallback */
.nav-avatar-fallback {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: #1e293b;
  border: 2px solid #38bdf8;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: #e5e7eb;
}

/* Dropdown menu panel */
.nav-profile-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.5rem;
  min-width: 190px;
  background: #020617;
  border-radius: 0.75rem;
  border: 1px solid #1f2937;
  padding: 0.5rem 0;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.7);
  display: none;
  z-index: 50;
}

/* KEEP OPEN while hovering avatar OR menu, or when focused */
.nav-profile:hover .nav-profile-menu,
.nav-profile:focus-within .nav-profile-menu {
  display: block;
}

/* Links inside the menu */
.nav-profile-menu a {
  display: block;
  padding: 0.55rem 1.1rem;
  font-size: 0.9rem;
  color: #e5e7eb;
  text-decoration: none;
}

.nav-profile-menu a:hover {
  background: #0f172a;
  color: #38bdf8;
}

/* ===========================
   Main layout
   =========================== */

main {
  max-width: 960px;
  margin: 2rem auto;
  padding: 0 1.5rem;
}

h2 {
  color: #f9fafb;
  font-size: 1.4rem;
  margin-top: 0;
}

p {
  color: #9ca3af;
  font-size: 1rem;
  max-width: 720px;
}

/* ===========================
   Feature card
   =========================== */

section.feature {
  background: #111827;
  border: 1px solid #1f2937;
  border-radius: 1rem;
  padding: 2rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  margin-bottom: 2rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

section.feature:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(56, 189, 248, 0.16);
}

/* ===========================
   Buttons
   =========================== */

a.btn,
button.btn {
  display: inline-block;
  margin-top: 1rem;
  background: #38bdf8;
  color: #0f172a;
  padding: 0.6rem 1.25rem;
  border-radius: 999px;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  font-size: 0.95rem;
  transition: background 0.3s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

a.btn:hover,
button.btn:hover {
  background: #0ea5e9;
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(56, 189, 248, 0.22);
}

a.btn:active,
button.btn:active {
  transform: translateY(0);
  box-shadow: none;
}

/* ===========================
   Footer
   =========================== */

footer {
  text-align: center;
  padding: 2rem 1rem;
  font-size: 0.85rem;
  color: #6b7280;
  border-top: 1px solid #1f2937;
  margin-top: 3rem;
}

/* ===========================
   Code styling
   =========================== */

code {
  background: #1f2937;
  padding: 0.15rem 0.4rem;
  border-radius: 0.4rem;
  color: #93c5fd;
  font-family: "Fira Code", Consolas, monospace;
}

/* ===========================
   C++ demo specific
   =========================== */

.editor-label {
  font-size: 0.9rem;
  color: #9ca3af;
  margin-bottom: 0.4rem;
}

#code-editor {
  width: 100%;
  min-height: 260px;
  padding: 1rem;
  border-radius: 0.75rem;
  border: 1px solid #1f2937;
  background: #020817;
  color: #e5e7eb;
  font-family: "Fira Code", Consolas, monospace;
  font-size: 0.95rem;
  resize: vertical;
  box-sizing: border-box;
  outline: none;
  box-shadow: inset 0 0 0 1px transparent;
  transition: box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

#code-editor:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 1px #38bdf8;
  background: #020617;
}

.output-container {
  margin-top: 1.8rem;
}

.output-label {
  font-size: 0.9rem;
  color: #9ca3af;
  margin-bottom: 0.4rem;
}

#output {
  background: #111827;
  border-radius: 0.75rem;
  border: 1px solid #1f2937;
  padding: 1rem 1.25rem;
  font-family: "Fira Code", Consolas, monospace;
  font-size: 0.9rem;
  color: #e5e7eb;
  min-height: 60px;
  display: flex;
  align-items: center;
  box-sizing: border-box;
  white-space: pre-wrap;
  word-break: break-word;
}

.status-pill {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  margin-right: 0.6rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: #111827;
  color: #9ca3af;
  border: 1px solid #1f2937;
}

.status-ok {
  background: rgba(22, 163, 74, 0.12);
  border-color: #22c55e;
  color: #bbf7d0;
}

.status-error {
  background: rgba(248, 113, 113, 0.1);
  border-color: #f97316;
  color: #fed7aa;
}

/* ===========================
   Auth pages (signup / login)
   =========================== */

.auth-page {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 3rem 1.5rem 4rem;
}

.auth-card {
  width: 100%;
  max-width: 720px;
  background: #111827;
  border-radius: 1rem;
  padding: 2.5rem 2.75rem;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.45);
}

.auth-card h2 {
  font-size: 1.75rem;
  margin-bottom: 0.75rem;
}

.auth-subtitle {
  margin: 0 0 1.75rem;
  color: #9ca3af;
  max-width: 36rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem 1.5rem;
  margin-bottom: 2rem;
}

.form-field {
  display: flex;
  flex-direction: column;
}

.form-field label {
  font-size: 0.95rem;
  margin-bottom: 0.35rem;
  color: #e5e7eb;
}

.form-field input,
.form-field select,
.form-field textarea {
  border-radius: 0.6rem;
  border: 1px solid #1f2937;
  background: #020617;
  padding: 0.55rem 0.75rem;
  color: #e5e7eb;
  font-size: 0.95rem;
  outline: none;
  box-shadow: 0 0 0 1px transparent;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 1px #38bdf8;
  background: #020617;
}

.form-help {
  margin-top: 0.3rem;
  font-size: 0.8rem;
  color: #9ca3af;
}

.form-errors {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: #fecaca;
}

.auth-footnote {
  margin-top: 1.5rem;
  font-size: 0.9rem;
  color: #9ca3af;
}

.auth-footnote a {
  color: #38bdf8;
  text-decoration: underline;
}

.auth-footnote a:hover {
  color: #0ea5e9;
}

/* Screen-reader-only */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ===========================
   Responsive tweaks
   =========================== */

@media (max-width: 900px) {
  .nav-container {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }
}

@media (max-width: 768px) {
  .auth-card {
    padding: 1.75rem 1.5rem 2.25rem;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}

/* =========================================
   Card Hover Effects (global)
========================================= */

.feature,
.card {
  transition:
    box-shadow 0.2s ease,
    transform 0.15s ease,
    border-color 0.2s ease;
}

.feature:hover,
.card:hover {
  transform: translateY(-4px);
  border-color: #334155; /* brighter slate border */
  box-shadow: 0 12px 32px rgba(0,0,0,0.55);
}

/* =========================================
   Profile Page
========================================= */

.profile-header-card {
  display: block;
}

.profile-layout {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;
  align-items: center;
}

/* Avatar container */
.profile-avatar-wrapper-lg {
  flex: 0 0 auto;
}

/* Large avatar image */
.profile-avatar-lg {
  width: 260px;
  max-width: 100%;
  height: auto;
  border-radius: 1.25rem;
  object-fit: cover;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.85);
  border: 2px solid rgba(56, 189, 248, 0.8);
}

/* Initials fallback styled similarly */
.profile-avatar-lg.fallback-lg {
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 30% 20%, #38bdf8, #0f172a);
  color: #e0f2fe;
  font-weight: 700;
  font-size: 2.2rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Text block */
.profile-info {
  flex: 1 1 240px;
}

.profile-name {
  font-size: 1.6rem;
  margin: 0 0 0.5rem;
  color: #f9fafb;
}

.profile-email,
.profile-username {
  margin: 0.1rem 0;
  color: #9ca3af;
  font-size: 0.95rem;
}

.profile-username {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

/* Buttons row */
.profile-actions {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* Achievements section tweaks */
.profile-achievements h3 {
  margin-top: 0;
}

.profile-achievements .placeholder-text {
  color: #9ca3af;
  margin-bottom: 1rem;
}

/* Reuse existing cards but ensure a nice grid on larger screens */
.achievement-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.achievement-card.empty {
  background: #020617;
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
  border: 1px dashed #1f2937;
  color: #9ca3af;
}

/* Mobile stacking */
@media (max-width: 700px) {
  .profile-layout {
    flex-direction: column;
    align-items: flex-start;
  }

  .profile-avatar-wrapper-lg {
    align-self: center;
  }
}
