/* ==========================================================================
   Portfolio stylesheet — Yosef Birhanu
   Sections: 1 Tokens · 2 Base · 3 Layout · 4 Buttons · 5 Header/Nav · 6 Hero
   7 Sections & cards · 8 Projects · 9 Dialogs · 10 Footer · 11 Motion · 12 Breakpoints
   ========================================================================== */

/* 1. DESIGN TOKENS */
:root {
  --navy-900: #060d1c;
  --navy-800: #0a1224;
  --navy-700: #101b33;
  --charcoal: #182238;
  --line: rgba(148, 163, 184, 0.18);
  --white: #ffffff;
  --text: #e8edf6;
  --muted: #a3b0c5;
  --blue: #3b82f6;
  --blue-strong: #2563eb;
  --cyan: #22d3ee;

  --font-sans: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --header-h: 64px;
  --ease: 0.25s ease;
}

/* 2. BASE */
*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 8px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--navy-800);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.65;
  overflow-x: hidden;
}

body.no-scroll { overflow: hidden; }

[hidden] { display: none !important; }

img, video { display: block; max-width: 100%; height: auto; }

h1, h2, h3 { margin: 0 0 0.6rem; line-height: 1.2; color: var(--white); }
h1 { font-size: clamp(2.1rem, 7vw, 3.8rem); letter-spacing: -0.02em; }
h2 { font-size: clamp(1.6rem, 4.5vw, 2.4rem); letter-spacing: -0.01em; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1rem; }
ul, ol { margin: 0; padding: 0; list-style: none; }

a { color: var(--cyan); text-decoration: none; transition: color var(--ease); }
a:hover { color: var(--white); }

:focus-visible { outline: 3px solid var(--cyan); outline-offset: 3px; border-radius: 4px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: fixed; top: 0.5rem; left: 0.5rem; z-index: 200;
  padding: 0.6rem 1rem; border-radius: var(--radius-sm);
  background: var(--cyan); color: var(--navy-900); font-weight: 600;
  transform: translateY(-200%);
}
.skip-link:focus { transform: translateY(0); color: var(--navy-900); }

/* 3. LAYOUT */
.container { width: min(1120px, 100% - 2rem); margin-inline: auto; }

.section { padding: 4rem 0; }
.section-alt { background: var(--navy-700); }

.section-head { margin-bottom: 2rem; }
.section-intro { color: var(--muted); max-width: 62ch; }

.eyebrow {
  margin-bottom: 0.7rem;
  color: var(--cyan);
  font-size: 0.8rem; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase;
}

.subhead { margin-top: 1.5rem; font-size: 1.05rem; color: var(--white); }
.note { color: var(--muted); font-size: 0.9rem; }

.card-grid { display: grid; gap: 1.25rem; grid-template-columns: 1fr; }

.card {
  background: var(--charcoal);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.4rem;
  transition: transform var(--ease), border-color var(--ease);
}
.card:hover { border-color: rgba(34, 211, 238, 0.45); }

.center-row { display: flex; justify-content: center; margin-top: 2rem; }

/* Tags and check lists */
.tag-list { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 1rem 0; }
.tag-list li {
  padding: 0.3rem 0.8rem;
  border: 1px solid rgba(59, 130, 246, 0.45);
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.12);
  color: var(--text); font-size: 0.85rem;
}
.tag-list-small li { padding: 0.15rem 0.65rem; font-size: 0.78rem; }

.check-list li { position: relative; padding: 0.3rem 0 0.3rem 1.5rem; color: var(--muted); }
.check-list li::before {
  content: ""; position: absolute; left: 0; top: 0.85rem;
  width: 0.65rem; height: 0.65rem; border-radius: 2px;
  background: linear-gradient(135deg, var(--blue), var(--cyan));
}

/* 4. BUTTONS */
.button-row { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.button-row-center { justify-content: center; margin: 1.5rem 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0.7rem 1.4rem;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  font: inherit; font-weight: 600; line-height: 1.2; text-align: center;
  cursor: pointer;
  transition: transform var(--ease), background var(--ease), border-color var(--ease), color var(--ease);
}
.btn:hover { transform: translateY(-2px); }

.btn-primary { background: var(--blue); color: var(--white); }
.btn-primary:hover { background: var(--blue-strong); color: var(--white); }

.btn-secondary { background: transparent; border-color: var(--cyan); color: var(--cyan); }
.btn-secondary:hover { background: rgba(34, 211, 238, 0.12); color: var(--white); }

.btn-ghost { background: rgba(255, 255, 255, 0.08); border-color: var(--line); color: var(--text); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.16); color: var(--white); }

.btn-small { padding: 0.55rem 1.1rem; font-size: 0.92rem; }

.btn-link { background: none; border: 0; padding-inline: 0.5rem; color: var(--cyan); text-decoration: underline; text-underline-offset: 3px; }
.btn-link:hover { color: var(--white); transform: none; }

/* 5. HEADER AND NAVIGATION */
.site-header {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  background: rgba(10, 18, 36, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color var(--ease), background var(--ease);
}
.site-header.is-scrolled { background: rgba(6, 13, 28, 0.95); border-bottom-color: var(--line); }

.header-inner {
  position: relative;               /* anchor for the mobile dropdown */
  display: flex; align-items: center; justify-content: space-between;
  height: 100%;
}

.brand { color: var(--white); font-size: 1.15rem; font-weight: 700; letter-spacing: 0.01em; }
.brand:hover { color: var(--cyan); }

.nav-toggle {
  display: inline-flex; flex-direction: column; justify-content: center; align-items: center; gap: 5px;
  width: 44px; height: 44px; padding: 0;
  background: transparent; border: 1px solid var(--line); border-radius: var(--radius-sm);
  cursor: pointer;
}
.nav-toggle-bar { width: 22px; height: 2px; background: var(--white); border-radius: 2px; transition: transform var(--ease), opacity var(--ease); }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* Mobile dropdown: directly beneath the toggle, right edges aligned */
.primary-nav {
  position: absolute; top: calc(100% + 0.25rem); right: 0;
  width: min(260px, calc(100vw - 2rem));
  background: var(--navy-700);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
  opacity: 0; visibility: hidden; transform: translateY(-8px);
  transition: opacity var(--ease), transform var(--ease), visibility var(--ease);
}
.primary-nav.is-open { opacity: 1; visibility: visible; transform: translateY(0); }

.nav-list { padding: 0.5rem; }
.nav-link {
  display: block; padding: 0.75rem 1rem; border-radius: var(--radius-sm);
  color: var(--text); font-weight: 500;
}
.nav-link:hover, .nav-link.is-active { background: rgba(59, 130, 246, 0.18); color: var(--white); }

/* 6. HERO */
.hero {
  position: relative; display: flex; align-items: center;
  min-height: calc(100svh - var(--header-h)); min-height: calc(100vh - var(--header-h));
  padding: 4rem 0;
  overflow: hidden; isolation: isolate;
  background: radial-gradient(circle at 80% 20%, rgba(34, 211, 238, 0.14), transparent 45%),
              linear-gradient(160deg, var(--navy-900), var(--navy-700));
}
@supports (min-height: 100svh) { .hero { min-height: calc(100svh - var(--header-h)); } }

/* Phones and tablets: start the hero text higher instead of vertically centering it */
@media (max-width: 767px) {
  .hero { align-items: flex-start; min-height: 0; padding-top: clamp(3rem, 10vh, 5rem); padding-bottom: 1rem; }
}

.hero-media { position: absolute; inset: 0; z-index: -1; }
.hero-video { width: 100%; height: 100%; object-fit: cover; }
.hero.video-failed .hero-video { display: none; }
.hero-overlay { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(6, 13, 28, 0.72), rgba(10, 18, 36, 0.88)); }

.hero-content { max-width: 820px; margin-inline: auto; text-align: center; }
.hero-content .button-row { justify-content: center; }
.hero-name { margin-bottom: 0.4rem; color: var(--white); font-size: clamp(1.1rem, 3.5vw, 1.5rem); font-weight: 600; letter-spacing: 0.04em; text-shadow: 0 0 18px rgba(34, 211, 238, 0.45); }
.hero-text { max-width: 56ch; margin: 1rem auto 2rem; color: var(--text); font-size: 1.1rem; }
.hero h1 span { color: var(--cyan); }

/* 6b. HERO DATA-VISUALIZATION LAYER (decorative; sits above the overlay, below the text) */
.hero-visuals {
  position: absolute; top: 0; left: 0; right: 0;
  height: var(--hero-cut, 17rem);   /* set by script.js: the line just above the buttons */
  overflow: hidden; pointer-events: none;
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 1.5rem), transparent);
          mask-image: linear-gradient(to bottom, #000 calc(100% - 1.5rem), transparent);
}

/* Frozen background: nothing in the hero visuals moves */
.hero-visuals, .hero-visuals * { animation: none !important; }
.hv-sweep { display: none; }

.hv-grid {
  position: absolute; inset: 0; opacity: 0.5;
  background-image:
    linear-gradient(rgba(59, 130, 246, 0.09) 1px, transparent 1px),
    linear-gradient(90deg, rgba(59, 130, 246, 0.09) 1px, transparent 1px);
  background-size: 56px 56px;
  -webkit-mask-image: radial-gradient(ellipse at 70% 60%, #000 20%, transparent 75%);
          mask-image: radial-gradient(ellipse at 70% 60%, #000 20%, transparent 75%);
}

.hv-orb { position: absolute; border-radius: 50%; filter: blur(70px); opacity: 0.35; }
.hv-orb-a { width: 380px; height: 380px; top: -80px; right: 8%; background: var(--cyan); animation: hv-drift 18s ease-in-out infinite alternate; }
.hv-orb-b { width: 320px; height: 320px; bottom: -100px; left: 10%; background: var(--blue); animation: hv-drift 22s ease-in-out infinite alternate-reverse; }

.hv-sweep {
  position: absolute; top: 0; bottom: 0; left: 0; width: 30%;
  background: linear-gradient(90deg, transparent, rgba(34, 211, 238, 0.07), transparent);
  animation: hv-sweep 9s linear infinite;
}

.hv-chart { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0.8; }

.hv-line { fill: none; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 0; }
.hv-line-core { stroke: var(--cyan); stroke-width: 2; }
.hv-line-glow { stroke: var(--cyan); stroke-width: 10; opacity: 0.18; }
.hv-line.hv-blue { stroke: var(--blue); }
.hv-line-core, .hv-line-glow { animation: hv-draw 12s ease-in-out infinite; }
.hv-blue { animation-delay: 2.5s !important; }

.hv-area { animation: hv-fade 12s ease-in-out infinite; }

.hv-bars rect { fill: rgba(34, 211, 238, 0.28); transform-box: fill-box; transform-origin: bottom; animation: hv-bar 5s ease-in-out infinite alternate; }
.hv-bars rect:nth-child(2n) { fill: rgba(59, 130, 246, 0.3); animation-delay: 0.6s; }
.hv-bars rect:nth-child(3n) { animation-delay: 1.2s; }
.hv-bars rect:nth-child(4n) { animation-delay: 1.8s; }

.hv-network line { stroke: rgba(34, 211, 238, 0.3); stroke-width: 1; }
.hv-network circle { fill: var(--cyan); transform-box: fill-box; transform-origin: center; animation: hv-pulse 3.5s ease-in-out infinite; }
.hv-network circle:nth-of-type(2n) { animation-delay: 1.2s; }

.hv-tick {
  position: absolute; left: var(--x); top: var(--y);
  color: var(--cyan); font-family: Consolas, "Courier New", monospace; font-size: 0.85rem;
  text-shadow: 0 0 10px rgba(34, 211, 238, 0.7);
  opacity: 0.3; white-space: nowrap;
  animation: hv-rise var(--t) linear var(--d) infinite;
}

@keyframes hv-draw {
  0%   { stroke-dashoffset: 1; opacity: 0; }
  10%  { opacity: 1; }
  55%  { stroke-dashoffset: 0; }
  90%  { stroke-dashoffset: 0; opacity: 1; }
  100% { stroke-dashoffset: 0; opacity: 0; }
}
@keyframes hv-fade { 0%, 15% { opacity: 0; } 55%, 90% { opacity: 1; } 100% { opacity: 0; } }
@keyframes hv-bar { from { transform: scaleY(0.55); } to { transform: scaleY(1); } }
@keyframes hv-pulse { 0%, 100% { transform: scale(1); opacity: 0.6; } 50% { transform: scale(1.6); opacity: 1; } }
@keyframes hv-drift { from { transform: translate(0, 0); } to { transform: translate(-60px, 40px); } }
@keyframes hv-sweep { from { transform: translateX(-100%); } to { transform: translateX(400%); } }
@keyframes hv-rise {
  0%   { transform: translateY(0); opacity: 0; }
  15%  { opacity: 0.55; }
  80%  { opacity: 0.35; }
  100% { transform: translateY(-260px); opacity: 0; }
}

/* Lighter version on small screens for performance and readability */
@media (max-width: 599px) {
  .hv-bars, .hv-orb-b, .hv-tick:nth-of-type(n+9) { display: none; }
  .hv-chart { opacity: 0.55; }
}

/* 7. ABOUT, SKILLS, SERVICES, PROCESS, LEARNING, CONTACT */
.about-grid { display: grid; gap: 1.5rem; grid-template-columns: 1fr; }
.about-body .btn { margin-top: 0.5rem; }

.skill-card h3, .service-card h3 { color: var(--cyan); }
.service-card p { margin-bottom: 0.6rem; color: var(--muted); font-size: 0.95rem; }
.service-card strong { color: var(--text); }

.process-list { display: grid; gap: 1rem; grid-template-columns: 1fr; counter-reset: none; }
.process-step { display: flex; align-items: center; gap: 1rem; padding: 1.1rem 1.25rem; }
.process-step p { margin: 0; }
.step-number {
  flex: 0 0 auto; display: grid; place-items: center;
  width: 2.5rem; height: 2.5rem; border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--cyan));
  color: var(--navy-900); font-weight: 700;
}

.contact-box {
  max-width: 760px; text-align: center;
  padding: 3rem 1.5rem;
  background: var(--charcoal);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.contact-box .section-intro { margin-inline: auto; }

/* 8. PROJECTS */
.filter-bar { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem; }
.filter-btn {
  min-height: 40px; padding: 0.45rem 1rem;
  background: transparent; border: 1px solid var(--line); border-radius: 999px;
  color: var(--muted); font: inherit; font-size: 0.9rem; cursor: pointer;
  transition: background var(--ease), color var(--ease), border-color var(--ease);
}
.filter-btn:hover { color: var(--white); border-color: var(--cyan); }
.filter-btn.is-active { background: var(--blue); border-color: var(--blue); color: var(--white); }

.filter-status { min-height: 1.5rem; margin-bottom: 1rem; color: var(--muted); font-size: 0.9rem; }

.project-card { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.project-card:hover { transform: translateY(-4px); }

.project-thumb { aspect-ratio: 16 / 9; background: var(--navy-900); overflow: hidden; }
.project-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s ease; }
.project-card:hover .project-thumb img { transform: scale(1.03); }

.project-body { display: flex; flex-direction: column; flex: 1; padding: 1.25rem; }
.project-body .button-row { margin-top: auto; }

.project-category { margin-bottom: 0.4rem; color: var(--cyan); font-size: 0.78rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }

.empty-state { padding: 2rem 1rem; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }

/* 9. PROJECT DIALOGS AND CASE STUDY */
.project-dialog {
  width: min(960px, calc(100% - 1.5rem)); max-height: 90vh;
  padding: 0; overflow: auto; overscroll-behavior: contain;
  background: var(--navy-700); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6);
}
.project-dialog::backdrop { background: rgba(3, 7, 16, 0.78); backdrop-filter: blur(3px); }

.dialog-header {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
  padding: 1.1rem 1.25rem;
  background: var(--navy-700); border-bottom: 1px solid var(--line);
}
.dialog-header h2 { margin: 0; font-size: clamp(1.2rem, 4vw, 1.6rem); }

.dialog-close {
  flex: 0 0 auto; width: 44px; height: 44px;
  background: transparent; border: 1px solid var(--line); border-radius: var(--radius-sm);
  color: var(--white); font-size: 1.6rem; line-height: 1; cursor: pointer;
  transition: background var(--ease);
}
.dialog-close:hover { background: rgba(255, 255, 255, 0.1); }

.dialog-body { padding: 1.25rem; }

.gallery { display: grid; gap: 1rem; grid-template-columns: 1fr; }
.gallery figure { margin: 0; }
.gallery img {
  width: 100%; aspect-ratio: 16 / 9; object-fit: contain;
  background: var(--navy-900); border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.gallery figcaption { margin-top: 0.4rem; color: var(--muted); font-size: 0.88rem; }

.case-study { margin-top: 1.5rem; padding-top: 0.5rem; border-top: 1px solid var(--line); }
.case-section { margin-bottom: 0.5rem; background: var(--charcoal); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.case-section summary { padding: 0.8rem 1rem; font-weight: 600; cursor: pointer; list-style: none; position: relative; padding-right: 2.5rem; }
.case-section summary::-webkit-details-marker { display: none; }
.case-section summary::after { content: "+"; position: absolute; right: 1rem; color: var(--cyan); font-size: 1.2rem; }
.case-section[open] summary::after { content: "\2212"; }
.case-section p { margin: 0; padding: 0 1rem 1rem; color: var(--muted); }

/* 10. FOOTER */
.site-footer { padding: 2.5rem 0 1.5rem; background: var(--navy-900); border-top: 1px solid var(--line); }
.footer-inner { display: grid; gap: 1.5rem; grid-template-columns: 1fr; }
.footer-brand p { margin: 0; color: var(--muted); }
.footer-name { color: var(--white) !important; font-weight: 700; font-size: 1.1rem; }
.footer-links { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; }
.footer-links a { color: var(--muted); }
.footer-links a:hover { color: var(--cyan); }
.copyright { width: min(1120px, 100% - 2rem); margin: 2rem auto 0; padding-top: 1.25rem; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.85rem; text-align: center; }

/* 11. MOTION */
.hero-content > * { animation: fade-up 0.7s ease both; }
.hero-content > :nth-child(2) { animation-delay: 0.1s; }
.hero-content > :nth-child(3) { animation-delay: 0.2s; }
.hero-content > :nth-child(4) { animation-delay: 0.3s; }
.hero-content > :nth-child(5) { animation-delay: 0.4s; }

@keyframes fade-up { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

/* Reveal-on-scroll only applies when script.js adds .js-ready, so content is never hidden without JS */
.js-ready .reveal { opacity: 0; transform: translateY(20px); transition: opacity 0.6s ease, transform 0.6s ease; }
.js-ready .reveal.is-visible { opacity: 1; transform: none; }

.project-card.is-filtering { animation: fade-up 0.4s ease both; }
.project-dialog[open] { animation: fade-up 0.3s ease both; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .js-ready .reveal { opacity: 1; transform: none; }
  .hero-video { display: none; }
}

/* 12. BREAKPOINTS (mobile first) */
@media (min-width: 600px) {
  .gallery { grid-template-columns: repeat(2, 1fr); }
  .process-list { grid-template-columns: repeat(2, 1fr); }
  .dialog-body, .dialog-header { padding-inline: 1.75rem; }
}

@media (min-width: 768px) {
  :root { --header-h: 72px; }
  .section { padding: 5rem 0; }

  /* Desktop nav: horizontal, toggle hidden */
  .nav-toggle { display: none; }
  .primary-nav {
    position: static; width: auto;
    opacity: 1; visibility: visible; transform: none;
    background: none; border: 0; box-shadow: none;
  }
  .nav-list { display: flex; gap: 0.25rem; padding: 0; }
  .nav-link { padding: 0.5rem 0.8rem; font-size: 0.95rem; }

  .card-grid { grid-template-columns: repeat(2, 1fr); }
  .about-grid { grid-template-columns: 1fr 1.6fr; gap: 3rem; }
  .footer-inner { grid-template-columns: 1.2fr 1.5fr 1fr; align-items: start; }
  .footer-social { justify-content: flex-end; }
}

@media (min-width: 1024px) {
  .project-grid, .skills-grid { grid-template-columns: repeat(3, 1fr); }
  .skills-grid { grid-template-columns: repeat(4, 1fr); }
  .services-grid { grid-template-columns: repeat(4, 1fr); }
  .process-list { grid-template-columns: repeat(3, 1fr); }
  .gallery { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 380px) {
  .btn { width: 100%; }
  .button-row { flex-direction: column; align-items: stretch; }
  .card { padding: 1.1rem; }
  .project-body .button-row { align-items: stretch; }
}
