/* ==========================================================================
   Teedatec – Amir Namvar portfolio
   ========================================================================== */
:root {
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 14px;
  --radius-sm: 10px;
  --maxw: 1140px;
  --accent: #6366f1;
  --accent-2: #06b6d4;
  --grad: linear-gradient(135deg, var(--accent), var(--accent-2));
  --ease: cubic-bezier(.2, .7, .2, 1);
}
:root,
[data-theme="light"] {
  --bg: #f7f8fc;
  --bg-alt: #eef0f8;
  --surface: #ffffff;
  --text: #141a2e;
  --muted: #4a5470;
  --border: #dde1ee;
  --tag-bg: #eceefe;
  --tag-text: #3730a3;
  --shadow: 0 1px 2px rgba(20, 26, 46, .05), 0 8px 24px rgba(20, 26, 46, .07);
  --header-bg: rgba(247, 248, 252, .82);
  --accent-text: #4f46e5;
  --error: #c62828;
  --success: #1b7f4b;
}
[data-theme="dark"] {
  --bg: #0b1020;
  --bg-alt: #10162b;
  --surface: #151c34;
  --text: #e8ebf7;
  --muted: #a6aec8;
  --border: #263052;
  --tag-bg: #222b4f;
  --tag-text: #c7cbff;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
  --header-bg: rgba(11, 16, 32, .8);
  --accent-text: #a5b4fc;
  --error: #ff8a80;
  --success: #6ee7a8;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 1.0625rem; line-height: 1.65;
  color: var(--text); background: var(--bg);
  transition: background-color .3s ease, color .3s ease;
  -webkit-font-smoothing: antialiased;
}
img, svg { display: block; max-width: 100%; }
img { height: auto; }
a { color: var(--accent-text); text-decoration-thickness: 1px; text-underline-offset: 3px; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
p { margin: 0 0 1em; }
ul { margin: 0; padding: 0; list-style: none; }
:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 3px; border-radius: 6px; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 1rem; top: -100px; z-index: 100;
  background: var(--surface); color: var(--text); padding: .6rem 1rem; border-radius: var(--radius-sm);
  box-shadow: var(--shadow); transition: top .2s;
}
.skip-link:focus { top: 1rem; }

.container { width: min(100% - 2.5rem, var(--maxw)); margin-inline: auto; }
.narrow { max-width: 760px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--header-bg); backdrop-filter: saturate(160%) blur(12px); -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid transparent; transition: border-color .3s, box-shadow .3s;
}
.site-header.scrolled { border-bottom-color: var(--border); box-shadow: 0 4px 20px rgba(0,0,0,.06); }
.nav-wrap { display: flex; align-items: center; gap: 1rem; height: 68px; }
.brand { display: inline-flex; align-items: center; gap: .6rem; font-weight: 800; font-size: 1.2rem; color: var(--text); text-decoration: none; letter-spacing: -.01em; }
.brand-mark { width: 34px; height: 34px; }
.nav { margin-left: auto; }
.nav-menu { display: flex; gap: .25rem; }
.nav-menu a {
  display: block; padding: .5rem .8rem; border-radius: 8px; color: var(--muted);
  text-decoration: none; font-weight: 500; font-size: .98rem; transition: color .2s, background-color .2s;
}
.nav-menu a:hover, .nav-menu a.active { color: var(--text); background: var(--bg-alt); }
.nav-toggle { display: none; }

.theme-toggle {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--surface); border: 1px solid var(--border); color: var(--text); cursor: pointer;
  transition: transform .2s var(--ease), background-color .3s;
}
.theme-toggle:hover { transform: rotate(-15deg); }
.theme-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.theme-toggle .icon-moon { fill: currentColor; stroke: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
[data-theme="light"] .theme-toggle .icon-sun,
:root:not([data-theme]) .theme-toggle .icon-sun { display: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .85rem 1.5rem; border-radius: 999px; font: inherit; font-weight: 600; font-size: 1rem;
  text-decoration: none; cursor: pointer; border: 1px solid transparent;
  transition: transform .2s var(--ease), box-shadow .2s, background-color .2s, color .2s;
}
.btn:hover { transform: translateY(-2px); }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 8px 20px rgba(99, 102, 241, .3); }
.btn-primary:hover { box-shadow: 0 12px 28px rgba(99, 102, 241, .4); }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--accent); }
.btn-small { padding: .5rem 1rem; font-size: .9rem; }
.btn[disabled] { opacity: .65; cursor: progress; transform: none; }

/* ---------- Hero ---------- */
.hero { position: relative; overflow: hidden; padding: clamp(4.5rem, 12vw, 9rem) 0 clamp(4rem, 10vw, 7.5rem); }
.hero-inner { position: relative; z-index: 1; }
.hero-glow {
  position: absolute; top: -220px; right: -220px; width: min(900px, 120vw); aspect-ratio: 1; z-index: 0; pointer-events: none;
  background: radial-gradient(closest-side, rgba(99,102,241,.24), rgba(6,182,212,.12) 45%, transparent 100%);
}
.eyebrow { color: var(--accent-text); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; font-size: .9rem; margin-bottom: .5rem; }
.hero h1 { font-size: clamp(2.6rem, 8vw, 5rem); font-weight: 800; letter-spacing: -.035em; margin-bottom: .15em; }
.hero-title {
  font-size: clamp(1.35rem, 3.5vw, 2rem); font-weight: 700; margin-bottom: 1rem;
  background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent;
  width: fit-content;
}
.hero-tagline { max-width: 640px; color: var(--muted); font-size: clamp(1.05rem, 2vw, 1.2rem); margin-bottom: 2rem; }
.hero-tagline strong { color: var(--text); }
.hero-cta { display: flex; flex-wrap: wrap; gap: .9rem; }

/* ---------- Sections ---------- */
.section { padding: clamp(4rem, 9vw, 6.5rem) 0; }
.section.alt { background: var(--bg-alt); }
.section-title { font-size: clamp(1.8rem, 4vw, 2.5rem); font-weight: 800; letter-spacing: -.02em; margin-bottom: 1.6rem; }
.section-title::after { content: ""; display: block; width: 48px; height: 4px; margin-top: .6rem; border-radius: 4px; background: var(--grad); }
.lead { font-size: 1.15rem; }
#about p:not(.lead) { color: var(--muted); }

.grid { display: grid; gap: 1.4rem; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 290px), 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.6rem; box-shadow: var(--shadow); transition: transform .25s var(--ease), border-color .25s, background-color .3s;
}
.card:hover { transform: translateY(-4px); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.card h3 { font-size: 1.2rem; }

.tags { display: flex; flex-wrap: wrap; gap: .5rem; }
.tags li { background: var(--tag-bg); color: var(--tag-text); padding: .35rem .8rem; border-radius: 999px; font-size: .92rem; font-weight: 500; }
.tags.small li { font-size: .8rem; padding: .25rem .65rem; }

.service-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; background: var(--grad); margin-bottom: 1rem; }
.service-icon svg { width: 24px; height: 24px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.service p { color: var(--muted); margin: 0; font-size: .98rem; }

/* ---------- Projects ---------- */
.project { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.project picture { display: block; aspect-ratio: 16 / 10; overflow: hidden; border-bottom: 1px solid var(--border); background: var(--bg-alt); }
.project img { width: 100%; height: 100%; object-fit: cover; object-position: top; transition: transform .5s var(--ease); }
.project:hover img { transform: scale(1.04); }
.project-body { padding: 1.4rem 1.5rem 1.5rem; display: flex; flex-direction: column; gap: .9rem; flex: 1; }
.project-body h3 { margin: 0; }
.project-body p { color: var(--muted); margin: 0; font-size: .98rem; }
.project-links { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: auto; padding-top: .3rem; }

/* ---------- Contact ---------- */
.contact-grid { display: grid; grid-template-columns: 1fr 1.2fr; gap: 2.5rem; align-items: start; }
.contact-links { display: grid; gap: .8rem; margin-top: 1.5rem; }
.contact-links a {
  display: inline-flex; align-items: center; gap: .75rem; color: var(--text); text-decoration: none; font-weight: 500;
  padding: .7rem 1rem; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface);
  transition: border-color .2s, transform .2s var(--ease); word-break: break-word;
}
.contact-links a:hover { border-color: var(--accent); transform: translateX(3px); }
.contact-links svg { width: 22px; height: 22px; flex: none; fill: none; stroke: var(--accent-text); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.contact-links svg.fill { fill: var(--accent-text); stroke: none; }

.contact-form { display: grid; gap: 1rem; }
.contact-form:hover { transform: none; }
.field { display: grid; gap: .35rem; }
.field label { font-weight: 600; font-size: .95rem; }
.field input, .field textarea {
  width: 100%; font: inherit; font-size: 1rem; color: var(--text); background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .75rem .9rem;
  transition: border-color .2s, box-shadow .2s;
}
.field textarea { resize: vertical; min-height: 130px; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99, 102, 241, .25); }
.field [aria-invalid="true"] { border-color: var(--error); }
.error { color: var(--error); font-size: .85rem; margin: 0; min-height: 0; }
.error:empty { display: none; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.form-status { margin: 0; font-weight: 500; }
.form-status.ok { color: var(--success); }
.form-status.err { color: var(--error); }
.contact-form .btn { justify-self: start; }

/* ---------- Hero photo ---------- */
.hero-inner { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: clamp(2rem, 5vw, 4rem); }
.hero-photo { margin: 0; position: relative; width: clamp(220px, 28vw, 340px); aspect-ratio: 1; }
.hero-photo::before {
  content: ""; position: absolute; inset: -10px; border-radius: 50%; background: var(--grad); opacity: .9; z-index: 0;
}
.hero-photo picture, .hero-photo img { position: relative; z-index: 1; display: block; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.hero-photo img { border: 6px solid var(--bg); box-shadow: var(--shadow); }
.hero-badges { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1.6rem; }
.hero-badges li {
  font-size: .9rem; font-weight: 600; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  padding: .4rem .9rem; border-radius: 999px; display: inline-flex; align-items: center; gap: .45rem;
}
.hero-badges li::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--grad); }

/* ---------- About ---------- */
.about-grid { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: clamp(1.5rem, 4vw, 3rem); align-items: start; }
.about-photo { margin: 0; }
.about-photo img { width: 220px; height: 220px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); }
.about-text p:not(.lead) { color: var(--muted); }
.about-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .8rem; margin-top: 1.4rem; }
.about-facts li { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .8rem 1rem; }
.about-facts strong { display: block; font-size: 1.15rem; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; width: fit-content; }
.about-facts span { color: var(--muted); font-size: .9rem; }
.about-langs { margin-top: 1.6rem; }
.about-langs h3 { font-size: .85rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--accent-text); margin-bottom: .7rem; }
.lang-list { display: flex; flex-wrap: wrap; gap: .6rem; }
.lang-list li { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: .15rem .55rem; max-width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: .45rem 1rem; font-size: .95rem; }
.lang-name { font-weight: 600; color: var(--text); }
.lang-level { color: var(--muted); font-size: .85rem; }
.lang-level::before { content: "·"; margin-right: .55rem; color: var(--accent-2); font-weight: 700; }

/* ---------- Experience timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0 0 0 1.75rem; position: relative; max-width: 880px; }
.timeline::before { content: ""; position: absolute; left: 7px; top: .5rem; bottom: .5rem; width: 2px; background: linear-gradient(var(--accent), var(--accent-2)); border-radius: 2px; }
.timeline-item { position: relative; }
.timeline-dot { position: absolute; left: calc(-1.75rem + 1px); top: 1.7rem; width: 14px; height: 14px; border-radius: 50%; background: var(--surface); border: 3px solid var(--accent); }
.timeline-card:hover { transform: none; }
.timeline-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .3rem 1rem; margin-bottom: .8rem; }
.timeline-head h3 { margin: 0; }
.timeline-period { margin: 0; font-weight: 600; font-size: .95rem; color: var(--accent-text); }
.timeline-list { list-style: none; padding: 0; margin: 0 0 1.1rem; display: grid; gap: .5rem; }
.timeline-list li { position: relative; padding-left: 1.3rem; color: var(--muted); }
.timeline-list li::before { content: ""; position: absolute; left: 0; top: .7em; width: 7px; height: 7px; border-radius: 50%; background: var(--accent-2); }

/* ---------- Learning & How I work ---------- */
.section-lead { max-width: 760px; color: var(--muted); margin-bottom: 2rem; }
.learn p, .step p { color: var(--muted); margin: 0; font-size: .98rem; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 1.2rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); counter-reset: step; }
.step { position: relative; }
.step-num {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; margin-bottom: 1rem;
  background: var(--grad); color: #fff; font-weight: 800; font-size: 1.1rem; box-shadow: 0 6px 16px rgba(99, 102, 241, .3);
}
.step h3 { font-size: 1.1rem; }

/* ---------- Contact link labels ---------- */
.cl-text { display: grid; line-height: 1.3; }
.cl-label { font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); padding: 2rem 0; color: var(--muted); font-size: .95rem; }
.footer-inner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; }
.footer-inner p { margin: 0; }
.footer-links { display: flex; flex-wrap: wrap; gap: 1.2rem; }
.footer-links a { color: var(--muted); text-decoration: none; display: inline-flex; align-items: center; gap: .4rem; }
.footer-links svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.footer-links svg.fill { fill: currentColor; stroke: none; }
.footer-brand p { margin: 0; }
.footer-phone { font-size: .9rem; margin-top: .25rem !important; }
.footer-phone a { color: var(--muted); }
.footer-phone a:hover { color: var(--text); }
.footer-links a:hover { color: var(--text); }

/* ---------- Reveal animation ---------- */
.js .reveal { opacity: 0; transform: translateY(24px); transition: opacity .7s var(--ease), transform .7s var(--ease); }
.js .reveal.visible { opacity: 1; transform: none; }

/* ---------- 404 ---------- */
.page-404 { min-height: calc(100vh - 68px - 90px); display: grid; place-items: center; text-align: center; padding: 3rem 0; }
.page-404 .code { font-size: clamp(5rem, 20vw, 9rem); font-weight: 800; line-height: 1; margin: 0; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- Responsive ---------- */
@media (max-width: 820px) {
  .contact-grid { grid-template-columns: 1fr; }
}
@media (max-width: 980px) {
  .nav { order: 3; margin-left: 0; }
  .theme-toggle { margin-left: auto; }
  .nav-toggle {
    display: grid; gap: 5px; place-content: center; width: 42px; height: 42px; border-radius: 10px;
    background: var(--surface); border: 1px solid var(--border); cursor: pointer; padding: 0;
  }
  .nav-toggle .bar { display: block; width: 20px; height: 2px; background: var(--text); border-radius: 2px; transition: transform .3s var(--ease), opacity .2s; }
  .nav-toggle[aria-expanded="true"] .bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
  .nav-toggle[aria-expanded="true"] .bar:nth-child(2) { opacity: 0; }
  .nav-toggle[aria-expanded="true"] .bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
  .nav-menu {
    position: fixed; top: 68px; left: 0; right: 0; flex-direction: column; gap: .25rem;
    padding: 1rem 1.25rem 1.5rem; background: var(--bg); border-bottom: 1px solid var(--border);
    box-shadow: 0 16px 30px rgba(0,0,0,.12);
    transform: translateY(-8px); opacity: 0; visibility: hidden;
    transition: transform .25s var(--ease), opacity .25s, visibility .25s;
  }
  .nav-menu.open { transform: none; opacity: 1; visibility: visible; }
  .nav-menu a { padding: .8rem 1rem; font-size: 1.05rem; }
}
@media (max-width: 760px) {
  .hero-inner { grid-template-columns: 1fr; }
  .hero-photo { order: -1; width: 180px; margin-bottom: .5rem; }
  .hero-photo::before { inset: -7px; }
  .hero-photo img { border-width: 4px; }
  .about-grid { grid-template-columns: 1fr; }
  .about-photo img { width: 160px; height: 160px; }
}
@media (max-width: 480px) {
  .hero-cta .btn { flex: 1 1 100%; }
  .card { padding: 1.3rem; }
  .project { padding: 0; }
  .contact-form .btn { justify-self: stretch; }
}

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