/* ==============================================
   Diwas Shrestha — Portfolio
   Design studio. Dense grid. Type & craft.
   ============================================== */

/* ===== Custom Properties ===== */
:root {
  --bg:          #F9F6F0;
  --text:        #1A1817;
  --text-sub:    #5C5854;
  --text-faint:  #635E59;
  --accent:      #A84424;   /* rust */
  --accent-sub:  #E8C4B8;
  --surface:     #F2EDE4;
  --border:      #E4DDD4;

  --font-display: 'Fraunces', 'Georgia', serif;
  --font-body:    'DM Sans', 'Segoe UI', system-ui, sans-serif;
  --font-mono:    'JetBrains Mono', 'Consolas', monospace;

  --fs-hero:  clamp(2.75rem, 6vw, 5.5rem);
  --fs-h2:    clamp(1rem, 1.5vw, 1.15rem);
  --fs-h3:    1.0625rem;
  --fs-body:  0.9375rem;
  --fs-sm:    0.8125rem;

  --lh-body:  1.6;
  --lh-tight: 1.2;

  --pad:    clamp(1.5rem, 4vw, 2.5rem);
  --wide:   64rem;
  --gap:    3.5rem;

  /* Decorative */
  --deco-color: var(--accent);

  /* Hero */
  --hero-name-ls: 0.15em;
  --hero-rule-width: 4rem;
  --hero-role-ls: 0.25em;
  --hero-role-tt: uppercase;
  --hero-role-fw: 500;

  /* Hover */
  --hover-bg: rgba(168, 68, 36, 0.03);
  --card-hover-bg: #FDFBF8;

  /* Scroll reveal */
  --reveal-distance: 20px;
  --reveal-duration: 0.6s;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  font-size: var(--fs-body);
  font-weight: 400;
  line-height: var(--lh-body);
  color: var(--text-sub);
  background: var(--bg);
}

/* ===== Container ===== */
.container {
  max-width: var(--wide);
  margin: 0 auto;
  padding: var(--pad);
}

/* ===== Base Typography ===== */
h1, .hero__name {
  font-family: var(--font-display);
  font-size: var(--fs-hero);
  font-weight: 300;
  line-height: 1.05;
  letter-spacing: 0.01em;
  color: var(--text);
}

h2 {
  font-family: var(--font-display);
  font-size: var(--fs-h3);
  font-weight: 500;
  color: var(--text);
  line-height: var(--lh-tight);
  margin-bottom: 0.3rem;
}

h2 span {
  font-weight: 400;
  font-style: italic;
  color: var(--text-faint);
  font-size: var(--fs-sm);
}

h3 {
  font-family: var(--font-display);
  font-weight: 500;
  color: var(--text);
}

p {
  margin-bottom: 0.75rem;
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 200ms;
}
a:hover { color: var(--text); }

/* ===== Rule ===== */
.rule {
  border: none;
  height: 1px;
  background: var(--border);
  margin: var(--gap) 0;
}

/* Double rule */
.rule--double {
  height: 3px;
  background: transparent;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

/* Decorative mark rule */
.rule--mark {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin: var(--gap) 0;
  height: auto;
  background: transparent;
}

.rule--mark::before,
.rule--mark::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.rule--mark .deco {
  flex: 0;
  font-family: var(--font-display);
  color: var(--deco-color);
  font-size: var(--fs-sm);
}

/* ===== Section Head ===== */
.section__head {
  font-family: var(--font-display);
  font-size: var(--fs-h2);
  font-weight: 400;
  font-style: italic;
  color: var(--accent);
  margin-bottom: 2rem;
}

/* ===== Hero ===== */
.hero {
  padding-top: clamp(2.5rem, 8vw, 6rem);
  padding-bottom: 0;
  position: relative;
  overflow-x: hidden;
}

.hero::before {
  content: '';
  position: absolute;
  top: -15%;
  right: -10%;
  width: 60%;
  height: 90%;
  background: radial-gradient(
    ellipse at 50% 30%,
    rgba(168, 68, 36, 0.04) 0%,
    transparent 65%
  );
  pointer-events: none;
  z-index: -1;
}

.hero__name {
  letter-spacing: var(--hero-name-ls);
  margin-inline: calc(-1 * var(--pad));
  padding-inline: var(--pad);
  max-width: 100vw;
}

.hero__rule {
  border: none;
  height: 1px;
  width: var(--hero-rule-width);
  background: var(--accent);
  margin: 1.25rem 0 1.5rem 0;
}

.hero__role {
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: var(--hero-role-fw);
  text-transform: var(--hero-role-tt);
  letter-spacing: var(--hero-role-ls);
  color: var(--text-faint);
  margin-top: 0;
}

.hero__role .deco {
  margin-right: 0.5em;
}

.hero__links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.75rem;
  margin-top: 1.5rem;
  font-size: var(--fs-sm);
  color: var(--text-faint);
  justify-content: flex-end;
}

.hero__links a {
  color: var(--text-sub);
  border-bottom: 1px solid transparent;
}

.hero__links a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ===== Theme Switch ===== */
.theme-switch {
  position: fixed;
  bottom: 1.5rem;
  right: var(--pad);
  z-index: 10;
  display: flex;
  gap: 1rem;
}

.theme-btn {
  background: none;
  border: none;
  padding: 0;
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  color: var(--text-faint);
  cursor: pointer;
  letter-spacing: 0.08em;
  transition: color 200ms;
}

.theme-btn:hover {
  color: var(--accent);
}

.theme-btn.is-active {
  color: var(--accent);
  cursor: default;
  pointer-events: none;
}

/* ===== Decorative utility ===== */
.deco {
  font-family: var(--font-display);
  color: var(--deco-color);
  user-select: none;
}

/* ===== Intro / About ===== */
.intro p {
  font-family: var(--font-body);
  font-size: var(--fs-body);
  color: var(--text-sub);
  line-height: var(--lh-body);
  margin-bottom: 0.85rem;
}

.intro p strong {
  font-weight: 500;
  color: var(--text);
}

.intro__stats {
  margin-top: 1.25rem;
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-style: italic;
  color: var(--text-faint);
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.5rem;
}

.intro__stats em {
  font-style: normal;
  font-weight: 500;
  color: var(--text);
}

/* ===== Work Items ===== */
.work-list {
  display: flex;
  flex-direction: column;
}

.work-item {
  display: grid;
  grid-template-columns: 10rem 1fr;
  gap: 1.5rem;
  padding: 1.25rem 0;
  border-bottom: 1px solid var(--border);
  transition: background 200ms;
}

.work-item:first-child {
  padding-top: 0;
}

.work-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.work-item:hover {
  background: var(--hover-bg);
  margin-inline: -0.5rem;
  padding-inline: 0.5rem;
  border-radius: 4px;
}

.work-item__meta {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding-top: 0.15rem;
}

.work-item__date {
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  color: var(--text-faint);
}

.work-item__tag {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.accent-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

.work-item__body h3 {
  font-size: var(--fs-h3);
  margin-bottom: 0.35rem;
}

.work-item__body h3 span {
  font-weight: 400;
  font-style: italic;
  color: var(--text-faint);
  font-size: var(--fs-sm);
}

.work-item__body p {
  margin-bottom: 0.35rem;
}

.work-item__tech {
  font-family: var(--font-mono) !important;
  font-size: 0.6875rem !important;
  color: var(--text-faint) !important;
  margin-top: 0.4rem !important;
  margin-bottom: 0 !important;
}

/* ===== Projects ===== */
.proj-featured {
  border-left: 3px solid var(--accent);
  padding: 1.25rem 1.5rem;
  margin-bottom: 2rem;
  background: var(--surface);
  border-radius: 0 6px 6px 0;
  transition: border-color 200ms, background 200ms;
}

.proj-featured:hover {
  border-left-color: var(--text);
}

.proj-featured__label {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: block;
  margin-bottom: 0.4rem;
}

.proj-featured h3 {
  font-size: var(--fs-h3);
  margin-bottom: 0.4rem;
}

/* Project Grid */
.proj-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

.proj-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  transition: border-color 200ms, background 200ms, transform 200ms;
}

.proj-card:hover {
  border-color: var(--accent);
  background: var(--card-hover-bg);
}

.proj-card h3 {
  font-size: var(--fs-h3);
  margin-bottom: 0.25rem;
}

.proj-card__meta {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--text-faint);
  margin-bottom: 0.6rem;
}

.proj-card p {
  font-size: var(--fs-sm);
  flex: 1;
  margin-bottom: 0.6rem;
}

.proj-card__award {
  font-family: var(--font-mono);
  font-size: 0.625rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.proj-link {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent);
  align-self: flex-start;
  margin-top: auto;
  border-bottom: 1px solid transparent;
  transition: border-color 200ms, color 200ms;
}

.proj-link:hover {
  color: var(--text);
  border-bottom-color: var(--text);
}

/* ===== Capabilities ===== */
.caps-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem 2.5rem;
}

.cap-group h3 {
  font-family: var(--font-body);
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 0.35rem;
}

.cap-group p {
  font-size: var(--fs-sm);
  line-height: 1.65;
}

/* ===== Split Grid (Education + Certs) ===== */
.split-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
}

.split-grid h3 {
  font-size: var(--fs-h3);
  margin-bottom: 0.5rem;
}

.split-grid h3 span {
  font-weight: 400;
  font-style: italic;
  color: var(--text-faint);
  font-size: var(--fs-sm);
}

/* Certifications */
.cert-list {
  display: flex;
  flex-direction: column;
}

.cert-list a,
.cert-misc {
  display: block;
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  color: var(--text-sub);
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--border);
  transition: color 200ms, border-color 200ms;
}

.cert-list a span {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--text-faint);
  margin-top: 0.1rem;
}

.cert-list a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ===== Footer ===== */
.footer {
  padding-bottom: 1.5rem;
}

.footer p {
  font-size: var(--fs-sm);
  color: var(--text-faint);
  margin-bottom: 0;
}

/* ===== Scroll Reveal ===== */
@keyframes reveal-fade-up {
  from {
    opacity: 0;
    transform: translateY(var(--reveal-distance));
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@supports (animation-timeline: view()) {
  .section__head {
    animation: reveal-fade-up 0.4s ease-out;
    animation-timeline: view();
    animation-range: entry 0% entry 35%;
  }

  .section__body {
    animation: reveal-fade-up 0.6s ease-out;
    animation-timeline: view();
    animation-range: entry 5% entry 65%;
  }
}

/* ===== Dark Mode ===== */

/* Auto: system preference (respects manual light override) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:             #1C1814;
    --text:           #EDE6DD;
    --text-sub:       #C5BDB4;
    --text-faint:     #9E968E;
    --accent:         #D48363;
    --accent-sub:     #3D2820;
    --surface:        #241F1A;
    --border:         #352F2A;
    --hover-bg:       rgba(200, 122, 90, 0.06);
    --card-hover-bg:  #2A241F;
  }
}

/* Manual: dark mode forced */
[data-theme="dark"] {
  --bg:             #1C1814;
  --text:           #EDE6DD;
  --text-sub:       #C5BDB4;
  --text-faint:     #9E968E;
  --accent:         #D48363;
  --accent-sub:     #3D2820;
  --surface:        #241F1A;
  --border:         #352F2A;
  --hover-bg:       rgba(200, 122, 90, 0.06);
  --card-hover-bg:  #2A241F;
}

/* Manual: light mode forced */
[data-theme="light"] {
  --bg:             #F9F6F0;
  --text:           #1A1817;
  --text-sub:       #5C5854;
  --text-faint:     #635E59;
  --accent:         #A84424;
  --accent-sub:     #E8C4B8;
  --surface:        #F2EDE4;
  --border:         #E4DDD4;
  --hover-bg:       rgba(168, 68, 36, 0.03);
  --card-hover-bg:  #FDFBF8;
}

/* ===== Dark Mode Atmosphere ===== */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --hero-rule-width: 6rem;
  }

  /* Warm glow behind hero */
  :root:not([data-theme="light"]) .hero::before {
    background: radial-gradient(
      ellipse at 50% 30%,
      rgba(200, 122, 90, 0.08) 0%,
      transparent 65%
    );
  }

  /* Glowing § marks in dividers */
  :root:not([data-theme="light"]) .rule--mark .deco {
    text-shadow: 0 0 8px rgba(200, 122, 90, 0.3);
  }

  /* Hero § mark glow */
  :root:not([data-theme="light"]) .hero__role .deco {
    text-shadow: 0 0 6px rgba(200, 122, 90, 0.25);
  }

  /* Hero rule glow */
  :root:not([data-theme="light"]) .hero__rule {
    box-shadow: 0 0 6px rgba(200, 122, 90, 0.15);
  }

  /* Section heads — warmer glow */
  :root:not([data-theme="light"]) .section__head {
    text-shadow: 0 0 4px rgba(200, 122, 90, 0.15);
  }
}

/* Same atmosphere for manual dark mode */
[data-theme="dark"] {
  --hero-rule-width: 6rem;
}

[data-theme="dark"] .hero::before {
  background: radial-gradient(
    ellipse at 50% 30%,
    rgba(200, 122, 90, 0.08) 0%,
    transparent 65%
  );
}

[data-theme="dark"] .rule--mark .deco {
  text-shadow: 0 0 8px rgba(200, 122, 90, 0.3);
}

[data-theme="dark"] .hero__role .deco {
  text-shadow: 0 0 6px rgba(200, 122, 90, 0.25);
}

[data-theme="dark"] .hero__rule {
  box-shadow: 0 0 6px rgba(200, 122, 90, 0.15);
}

[data-theme="dark"] .section__head {
  text-shadow: 0 0 4px rgba(200, 122, 90, 0.15);
}

/* ===== Responsive: Tablet ===== */
@media (max-width: 900px) {
  .proj-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .split-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

}

/* ===== Responsive: Mobile ===== */
@media (max-width: 640px) {
  :root {
    --pad: 1.25rem;
    --gap: 2.5rem;
    --fs-hero: clamp(2rem, 9vw, 3.5rem);
  }

  .hero {
    padding-top: clamp(1.5rem, 6vw, 3rem);
  }

  .hero__name {
    margin-inline: 0;
  }

  .hero__links {
    flex-direction: column;
    gap: 0.3rem;
    margin-top: 1rem;
  }

  .hero__links span[aria-hidden] {
    display: none;
  }

  .intro__stats {
    flex-wrap: wrap;
    gap: 0.15rem 0.4rem;
  }

  .work-item {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .work-item:hover {
    margin-inline: 0;
    padding-inline: 0;
    border-radius: 0;
  }

  .work-item__meta {
    flex-direction: row;
    gap: 0.75rem;
  }

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

  .proj-card {
    padding: 1rem;
  }

  .proj-featured {
    padding: 1rem;
    margin-left: -0.5rem;
    padding-left: 0.75rem;
  }

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

  .split-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .section__head {
    margin-bottom: 1.5rem;
  }

  .theme-switch {
    bottom: 1rem;
    right: 1.25rem;
  }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}
