/* ===================================
   SAFAK.DEV — Creative Bento Portfolio
   Space Grotesk + Noise + Gradient Borders
   =================================== */

/* ---------- TOKENS ---------- */
[data-theme="dark"] {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface-2: #1a1a1a;
  --surface-hover: #1f1f1f;
  --border: rgba(255, 255, 255, 0.06);
  --border-hover: rgba(255, 255, 255, 0.15);
  --fg: #999;
  --fg-bright: #eee;
  --fg-dim: #555;
  --accent: #a78bfa;
  --accent-2: #6d28d9;
  --green: #34d399;
  --green-bg: rgba(52, 211, 153, 0.08);
  --green-border: rgba(52, 211, 153, 0.2);
  --shadow: 0 2px 20px rgba(0, 0, 0, 0.4);
  --img-bg: #1a1a1a;
}

[data-theme="light"] {
  --bg: #f4f2ef;
  --surface: #ffffff;
  --surface-2: #f7f5f2;
  --surface-hover: #f0eeeb;
  --border: rgba(0, 0, 0, 0.08);
  --border-hover: rgba(0, 0, 0, 0.16);
  --fg: #666;
  --fg-bright: #1a1a1a;
  --fg-dim: #aaa;
  --accent: #7c3aed;
  --accent-2: #4c1d95;
  --green: #059669;
  --green-bg: rgba(5, 150, 105, 0.06);
  --green-border: rgba(5, 150, 105, 0.2);
  --shadow: 0 2px 20px rgba(0, 0, 0, 0.06);
  --img-bg: #f0eeeb;
}

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

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--fg);
  font-family:
    "Space Grotesk",
    system-ui,
    -apple-system,
    sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition:
    background 0.4s ease,
    color 0.4s ease;
}

a {
  color: var(--accent);
  text-decoration: none;
}

/* ---------- NOISE OVERLAY ---------- */
.noise {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 256px 256px;
}

[data-theme="light"] .noise {
  opacity: 0.025;
}

/* ---------- THEME TOGGLE ---------- */
.theme-toggle {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 100;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s ease;
  box-shadow: var(--shadow);
}

.theme-toggle:hover {
  border-color: var(--border-hover);
  color: var(--fg-bright);
  transform: rotate(15deg) scale(1.08);
}

[data-theme="dark"] .icon-sun {
  display: block;
}
[data-theme="dark"] .icon-moon {
  display: none;
}
[data-theme="light"] .icon-sun {
  display: none;
}
[data-theme="light"] .icon-moon {
  display: block;
}

/* ---------- PAGE ---------- */
.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 3rem 1.25rem 4rem;
}

/* ---------- BENTO GRID ---------- */
.bento {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 10px;
}

/* ---------- CELL BASE ---------- */
.cell {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1.75rem;
  position: relative;
  overflow: hidden;
  transition:
    border-color 0.3s,
    transform 0.35s,
    box-shadow 0.35s;
}

.cell:hover {
  border-color: var(--border-hover);
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

/* ---------- SHARED ---------- */
.eyebrow {
  display: block;
  font-family: "Space Mono", monospace;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--fg-dim);
  margin-bottom: 0.75rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.13em;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
}

.badge-green {
  color: var(--green);
  background: var(--green-bg);
  border: 1px solid var(--green-border);
}

.badge-muted {
  color: var(--fg-dim);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse-glow 2s ease-in-out infinite;
}

@keyframes pulse-glow {
  0%,
  100% {
    opacity: 1;
    box-shadow: 0 0 0 0 var(--green);
  }
  50% {
    opacity: 0.5;
    box-shadow: 0 0 0 6px transparent;
  }
}

/* =============================================
   INTRO (HERO)
   ============================================= */
.c-intro {
  grid-column: span 7;
  padding: 2.5rem;
  background:
    radial-gradient(
      ellipse at 10% 90%,
      rgba(167, 139, 250, 0.08) 0%,
      transparent 50%
    ),
    radial-gradient(
      ellipse at 90% 20%,
      rgba(52, 211, 153, 0.05) 0%,
      transparent 50%
    ),
    var(--surface);
}

[data-theme="light"] .c-intro {
  background:
    radial-gradient(
      ellipse at 10% 90%,
      rgba(124, 58, 237, 0.06) 0%,
      transparent 50%
    ),
    radial-gradient(
      ellipse at 90% 20%,
      rgba(5, 150, 105, 0.04) 0%,
      transparent 50%
    ),
    var(--surface);
}

.intro-top {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.c-intro h1 {
  font-size: clamp(3rem, 7vw, 5rem);
  font-weight: 700;
  line-height: 0.92;
  letter-spacing: -0.05em;
  color: var(--fg-bright);
  margin-bottom: 1rem;
}

.tagline {
  font-size: 1rem;
  color: var(--fg);
  max-width: 440px;
  margin-bottom: 1.75rem;
}

.intro-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.intro-links a {
  font-family: "Space Mono", monospace;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg);
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: all 0.22s ease;
}

.intro-links a:hover {
  color: var(--fg-bright);
  border-color: var(--accent);
  background: rgba(167, 139, 250, 0.06);
  transform: translateY(-1px);
}

[data-theme="light"] .intro-links a:hover {
  background: rgba(124, 58, 237, 0.05);
}

/* =============================================
   NOW — CURRENT JOB
   ============================================= */
.c-now {
  grid-column: span 5;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  border-left: 3px solid var(--green);
  padding-left: 1.75rem;
}

.c-now h2 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--fg-bright);
}

.now-role {
  font-family: "Space Mono", monospace;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
}

.now-desc {
  font-size: 0.875rem;
  color: var(--fg);
  margin-top: 0.25rem;
}

.now-since {
  margin-top: auto;
  font-family: "Space Mono", monospace;
  font-size: 0.7rem;
  color: var(--fg-dim);
}

/* =============================================
   STACK — MARQUEE
   ============================================= */
.c-stack {
  grid-column: span 12;
  padding: 1.25rem 1.75rem;
  overflow: hidden;
}

.marquee-wrap {
  overflow: hidden;
  mask-image: linear-gradient(
    90deg,
    transparent,
    #000 8%,
    #000 92%,
    transparent
  );
  -webkit-mask-image: linear-gradient(
    90deg,
    transparent,
    #000 8%,
    #000 92%,
    transparent
  );
}

.marquee {
  display: flex;
  gap: 0.5rem;
  animation: scroll-left 30s linear infinite;
  width: max-content;
}

.marquee span {
  flex-shrink: 0;
  font-family: "Space Mono", monospace;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--fg);
  white-space: nowrap;
  transition:
    border-color 0.2s,
    color 0.2s;
}

.marquee span:hover {
  border-color: var(--accent);
  color: var(--fg-bright);
}

@keyframes scroll-left {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-50%);
  }
}

/* =============================================
   SECTION LABEL
   ============================================= */
.section-label {
  grid-column: span 12;
  font-family: "Space Mono", monospace;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--fg-dim);
  padding: 0.75rem 0 0;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.section-label::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* =============================================
   PROJECT — FEATURED (FULL WIDTH)
   ============================================= */
.c-featured {
  grid-column: span 12;
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 2.5rem;
  align-items: center;
  padding: 2.5rem;
  position: relative;
}

/* Animated gradient border on hover */
.c-featured::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: 19px;
  padding: 1px;
  background: linear-gradient(
    135deg,
    var(--accent),
    var(--green),
    var(--accent)
  );
  background-size: 300% 300%;
  opacity: 0;
  z-index: -1;
  transition: opacity 0.4s ease;
  animation: gradient-spin 4s ease infinite;
  -webkit-mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  mask:
    linear-gradient(#fff 0 0) content-box,
    linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}

.c-featured:hover::before {
  opacity: 1;
}
.c-featured:hover {
  border-color: transparent;
}

@keyframes gradient-spin {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

.proj-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.proj-badge {
  font-family: "Space Mono", monospace;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  width: max-content;
}

.proj-badge.live {
  color: var(--green);
}
.proj-badge.dim {
  color: var(--fg-dim);
}

.proj-body h2 {
  font-size: clamp(2rem, 3.5vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--fg-bright);
  line-height: 1;
}

.proj-body p {
  font-size: 0.9rem;
  line-height: 1.6;
  max-width: 420px;
}

.proj-tags {
  font-family: "Space Mono", monospace;
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
  margin-top: 0.25rem;
}

.proj-visual {
  background: var(--img-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  aspect-ratio: 3710 / 1834;
  display: flex;
  align-items: center;
  justify-content: center;
}

.proj-visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.c-featured:hover .proj-visual img {
  transform: scale(1.04);
}

/* =============================================
   PROJECT — HALF / THIRD
   ============================================= */
.c-half {
  grid-column: span 7;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.c-third {
  grid-column: span 5;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1.5rem;
  align-items: center;
}

.c-third .proj-body {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.proj-thumb {
  width: 100%;
  background: var(--img-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.25rem;
}

/* Landscape image (sahadefteri) */
.c-half .proj-thumb {
  aspect-ratio: 3684 / 1852;
}

/* Portrait phone screenshot (commercify) */
.c-third .proj-thumb {
  width: 120px;
  flex-shrink: 0;
  border-radius: 10px;
  margin-bottom: 0;
}

.proj-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.45s ease;
}

.cell:hover .proj-thumb img {
  transform: scale(1.04);
}

.c-project h3 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--fg-bright);
  letter-spacing: -0.02em;
}

.c-project p {
  font-size: 0.85rem;
  line-height: 1.55;
}

/* =============================================
   EXPERIENCE
   ============================================= */
.c-exp {
  grid-column: span 8;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.exp-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
  transition: padding-left 0.25s ease;
}

.exp-item:last-child {
  border-bottom: none;
}

.exp-item:hover {
  padding-left: 0.5rem;
}

.exp-left h4 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--fg-bright);
}

.exp-left span {
  font-size: 0.78rem;
  color: var(--fg-dim);
}

.exp-right {
  text-align: right;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.exp-loc {
  font-size: 0.72rem;
  color: var(--fg);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.exp-date {
  font-family: "Space Mono", monospace;
  font-size: 0.68rem;
  color: var(--fg-dim);
}

/* =============================================
   SIDE PROJECTS
   ============================================= */
.c-side {
  grid-column: span 4;
}

.c-side ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.c-side li {
  font-size: 0.82rem;
  line-height: 1.5;
}

.c-side strong {
  color: var(--fg-bright);
  font-weight: 600;
}

/* =============================================
   FOOTER
   ============================================= */
footer {
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  text-align: center;
  font-family: "Space Mono", monospace;
  font-size: 0.68rem;
  color: var(--fg-dim);
  letter-spacing: 0.05em;
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 768px) {
  .bento {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .c-intro,
  .c-now,
  .c-stack,
  .c-featured,
  .c-half,
  .c-third,
  .c-exp,
  .c-side,
  .section-label {
    grid-column: span 1;
  }

  .c-featured {
    grid-template-columns: 1fr;
  }

  .c-third {
    grid-template-columns: 1fr auto;
  }

  .c-third .proj-thumb {
    width: 100px;
  }
    font-size: 2.8rem;
  }

  .intro-links a {
    font-size: 0.65rem;
    padding: 0.4rem 0.65rem;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .bento {
    grid-template-columns: repeat(6, 1fr);
  }

  .c-intro {
    grid-column: span 4;
  }
  .c-now {
    grid-column: span 2;
  }
  .c-stack {
    grid-column: span 6;
  }
  .section-label {
    grid-column: span 6;
  }
  .c-featured {
    grid-column: span 6;
    grid-template-columns: 1fr;
  }
  .c-half {
    grid-column: span 4;
  }
  .c-third {
    grid-column: span 2;
    grid-template-columns: 1fr auto;
  }
  .c-third .proj-thumb {
    width: 100px;
  }
  .c-exp {
    grid-column: span 4;
  }
  .c-side {
    grid-column: span 2;
  }
}
