/* ==========================================================================
   chlrxe portfolio — stylesheet
   Organized per WSC CSS guidelines: design tokens, base/reset, layout,
   components, utilities, accessibility, then responsive overrides last.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design tokens
   -------------------------------------------------------------------------- */
:root {
  /* Color palette */
  --bg: #40826d;
  --text: #fcfcfc;
  --hi: #e3e7af;
  --card: #02111b;
  --card2: #30292f;
  --acc: #40826d;
  --err: #ffb4b4;

  /* Layout */
  --side-w: 280px;
  --content-max: 900px;

  /* Motion */
  --transition-fast: 0.15s ease;


  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Dark mode follows the visitor's system setting, or an explicit override. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #02111b;
    --card: #30292f;
    --card2: #02111b;
  }
}
:root[data-theme="dark"] {
  --bg: #02111b;
  --card: #30292f;
  --card2: #02111b;
}

/* --------------------------------------------------------------------------
   2. Base / reset
   -------------------------------------------------------------------------- */
* {
  box-sizing: border-box;
}
/* The gradient lives on <html>, not <body>: <html> always spans the full
   viewport even when page content is shorter, and background-attachment:
   fixed + background-size: cover keep it as a single sheet that never
   repeats or leaves a gap, no matter how tall the page ends up being. */
html {
  scroll-padding-top: env(safe-area-inset-top, 0px);
  min-height: 100%;
  background: var(--bg); /* fallback for browsers with no gradient support */
  background: linear-gradient(0deg, var(--bg) 0%, var(--hi) 100%);
  background: -moz-linear-gradient(0deg, var(--bg) 0%, var(--hi) 100%);
  background: -webkit-linear-gradient(0deg, var(--bg) 0%, var(--hi) 100%);
  filter: progid: DXImageTransform.Microsoft.gradient( startColorstr="#40826D", endColorstr="#E3E7AF", GradientType=1 );
  background-repeat: no-repeat;
  background-attachment: fixed;
  background-size: cover;
}
body {
  margin: 0;
  min-height: 100vh;
  background: transparent; /* let the gradient on <html> show through everywhere */
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
[hidden] {
  display: none !important;
}
h1 {
  font-size: clamp(34px, 6vw, 56px);
  line-height: 1.1;
  margin: 0 0 8px;
}
h2 {
  color: var(--hi);
  font-size: 14px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin: 0 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
h3 {
  margin: 0 0 6px;
  font-size: 18px;
}
label {
  display: block;
  margin: 0 0 14px;
  font-size: 14px;
}
label input,
label textarea {
  margin-top: 4px;
}

/* --------------------------------------------------------------------------
   3. Layout
   -------------------------------------------------------------------------- */

/* Sidebar is pinned to the real left edge of the viewport at all times,
   independent of how wide the window / main content column is. */
.side {
  position: fixed;
  top: 0;
  left: 0;
  right: auto;
  width: var(--side-w);
 
  height: 100dvh;
  overflow-y: auto;
  padding: calc(48px + env(safe-area-inset-top, 0px)) 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  border-right: 1px solid rgba(252, 252, 252, 0.12);
  z-index: 5;
}
main {
  margin-left: var(--side-w);
  max-width: var(--content-max);
  padding: 48px 40px 80px;
}

/* Fixed top-right bar for auth actions (log in / register / account).
   Explicit left:auto stops it from ever being pulled to the left edge. */
.topbar {
  position: fixed;
  top: calc(16px + env(safe-area-inset-top, 0px));
  left: auto;
  right: 24px;
  z-index: 20;
  display: flex;
  gap: 8px;
  align-items: center;
}

.about {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 24px;
}

/* --------------------------------------------------------------------------
   4. Components
   -------------------------------------------------------------------------- */

/* Navigation (sidebar links) */
nav a {
  display: block;
  padding: 6px 0;
  color: var(--text);
  text-decoration: none;
  opacity: 0.8;
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  background: none;
  border: 0;
  font: inherit;
  text-align: left;
  width: 100%;
  transition: opacity var(--transition-fast), color var(--transition-fast);
}
nav a:hover,
nav a.on {
  opacity: 1;
  color: var(--hi);
}
nav a.on::before {
  content: "— ";
}

/* Search: a round white magnifying-glass button that expands into an
   input when clicked, instead of a permanently-visible search bar. */
.search-wrap {
  display: flex;
  align-items: center;
}
.search-btn {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #fff;
  border: 0;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}
.search-btn svg {
  width: 16px;
  height: 16px;
  stroke: var(--card);
}
.search-input {
  width: 0;
  min-width: 0;
  opacity: 0;
  padding: 0;
  margin-left: 0;
  border: 0;
  overflow: hidden;
  transition: width var(--transition-fast), opacity var(--transition-fast),
    padding var(--transition-fast), margin var(--transition-fast);
}
.search-wrap.open .search-input {
  width: 100%;
  opacity: 1;
  padding: 8px 12px;
  margin-left: 8px;
  border: 1px solid rgba(252, 252, 252, 0.3);
}

/* Sidebar footer (auth link/logout) */
.side-foot {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid rgba(252, 252, 252, 0.12);
  font-size: 13px;
}
.side-foot button {
  background: none;
  border: 0;
  color: var(--hi);
  font: inherit;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

/* Buttons */
.btn {
  display: inline-block;
  background: var(--hi);
  color: #02111b;
  border: 0;
  border-radius: 6px;
  padding: 10px 18px;
  font: 600 14px system-ui, sans-serif;
  cursor: pointer;
  text-decoration: none;
  margin: 8px 8px 0 0;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.btn:hover {
  transform: translateY(-1px);
}
.btn.ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--hi);
}
.btn.small {
  padding: 6px 12px;
  font-size: 12px;
  margin: 0;
}

/* Form fields */
input,
textarea {
  width: 100%;
  background: var(--card2);
  color: var(--text);
  border: 1px solid rgba(252, 252, 252, 0.3);
  border-radius: 6px;
  padding: 10px 12px;
  font: inherit;
}

/* Cards (projects / posts / files) */
.card {
  background: var(--card);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 16px;
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 18px;
  border-left: 3px solid var(--acc);
  cursor: pointer;
}
.card:hover {
  outline: 1px solid var(--hi);
}
.card.one {
  grid-template-columns: 1fr;
}
.card.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  cursor: default;
}
.card p {
  margin: 0 0 8px;
}

/* Bio Image */
.profile-icon {
    width: 120px;
    height: 120px;
    display: block;
    border-radius: 20%; /* optional: circular icon */
    object-fit: cover;   /* prevents distortion */
}

/* Tags / badges */
.tag {
  display: inline-block;
  background: var(--card2);
  color: var(--hi);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  margin: 4px 6px 0 0;
}
.admin-badge {
  display: inline-block;
  background: var(--hi);
  color: #02111b;
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 10px;
}

/* File upload dropzone */
.drop {
  display: block;
  border: 2px dashed var(--hi);
  border-radius: 10px;
  padding: 22px;
  text-align: center;
  cursor: pointer;
  margin-bottom: 16px;
  background: var(--card2);
}
.drop:hover {
  border-color: var(--text);
}

/* Detail pages (single post / single project) */
.back {
  background: none;
  border: 0;
  color: var(--hi);
  font: inherit;
  cursor: pointer;
  padding: 0;
  margin-bottom: 20px;
  display: inline-block;
  text-decoration: underline;
}
.detail-body {
  white-space: pre-wrap;
  line-height: 1.7;
  margin: 16px 0;
}

/* Code tab (auto-pulled from GitHub) */
.code-tab {
  background: var(--card);
  border-radius: 8px;
  padding: 16px;
  overflow-x: auto;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  margin: 12px 0;
}

/* Comments */
.comment {
  background: var(--card);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 10px;
}
.comment .who {
  color: var(--hi);
  font-size: 12px;
  font-weight: 600;
}

/* Status text */
.small {
  font-size: 13px;
  opacity: 0.85;
}
.muted {
  opacity: 0.85;
}
.err {
  color: var(--err);
  font-size: 13px;
}
.ok {
  color: var(--hi);
  font-size: 13px;
}

/* --------------------------------------------------------------------------
   5. Accessibility
   -------------------------------------------------------------------------- */

/* Visible focus ring for keyboard users on every interactive element. */
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--hi);
  outline-offset: 2px;
}

/* Respect reduced-motion preference. */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
  .btn:hover {
    transform: none;
  }
}

/* --------------------------------------------------------------------------
   6. Responsive overrides (mobile / narrow viewports)
   -------------------------------------------------------------------------- */
@media (max-width: 800px) {
  .side {
    position: static;
    width: auto;
    height: auto;
  }
  main {
    margin-left: 0;
  }
  .topbar {
    position: static;
    justify-content: flex-end;
    padding: 12px 24px 0;
  }
  .card,
  .about {
    grid-template-columns: 1fr;
  }
}