/* ============================================================
   aitiko.ch — design system
   ------------------------------------------------------------
   FONTS: this build uses Google Fonts via <link> in HTML head
   for fastest preview. To switch to fully-embedded (offline,
   no third-party request, ~250KB total):

     1. Download woff2 subsets (Latin + JP for Noto Sans JP):
        - IBM Plex Sans 400/500
        - IBM Plex Mono 400/500
        - Noto Sans JP 400 (or just the single glyph 守)
     2. Convert each woff2 to base64 (e.g. `base64 file.woff2`)
     3. Replace the <link> in HTML with:
        @font-face { font-family:'IBM Plex Sans'; font-weight:400;
          src: url(data:font/woff2;base64,XXX...) format('woff2'); }
     ...etc. Cached forever, no FOIT, no external request.
   ============================================================ */

:root {
  /* Type */
  --font-mono: "IBM Plex Mono", ui-monospace, "JetBrains Mono", Menlo, monospace;
  --font-sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-jp: "Noto Sans JP", "IBM Plex Sans", sans-serif;

  /* Dark theme (default) */
  --bg:        #0a0e12;
  --bg-2:      #0d1216;
  --surface:   #11171d;
  --surface-2: #161d24;
  --border:    #1f2932;
  --border-2:  #2a3742;
  --fg:        #e8eef2;
  --fg-muted:  #94a4b0;
  --fg-dim:    #6a7782;
  --accent:    #48aec8;
  --accent-hi: #7fd4e8;
  --accent-dim: #2d6a7c;
  --red:       #e23e3e;
  --green:     #4ec97a;
  --amber:     #d9a441;

  /* Geometry */
  --rad: 4px;
  --rad-lg: 8px;
  --gutter: clamp(16px, 4vw, 40px);
  --col: min(1180px, 100% - 2 * var(--gutter));

  /* Effects */
  --grid-line: rgba(72, 174, 200, 0.06);
  --shadow-sm: 0 1px 0 rgba(255,255,255,0.02) inset;
}

[data-theme="light"] {
  --bg:        #f6f5f0;
  --bg-2:      #efeee8;
  --surface:   #ffffff;
  --surface-2: #fafaf6;
  --border:    #d9d6cc;
  --border-2:  #c4c0b3;
  --fg:        #0d1216;
  --fg-muted:  #4a5560;
  --fg-dim:    #7a8590;
  --accent:    #2d8aa3;
  --accent-hi: #1f6d83;
  --accent-dim: #b8e0eb;
  --red:       #c52828;
  --green:     #2f8550;
  --amber:     #a37820;
  --grid-line: rgba(45, 138, 163, 0.05);
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  transition: background-color .25s ease, color .25s ease;
}

/* Subtle background grid */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  z-index: 0;
  mask-image: radial-gradient(ellipse at 50% 30%, black 30%, transparent 75%);
}

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

::selection { background: var(--accent); color: var(--bg); }

/* Layout helpers */
.wrap { width: var(--col); margin-inline: auto; position: relative; z-index: 1; }
section { padding: clamp(56px, 9vw, 120px) 0; position: relative; }

/* ============================================================
   Top bar
   ============================================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  background: color-mix(in oklab, var(--bg) 78%, transparent);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 56px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--fg);
  font-family: var(--font-mono);
  font-weight: 500;
  letter-spacing: 0.02em;
}
.brand-mark {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  font-family: var(--font-jp);
  font-weight: 500;
  font-size: 20px;
  line-height: 1;
  color: var(--accent);
  border: 1px solid var(--border-2);
  background: var(--surface);
  border-radius: var(--rad);
  position: relative;
  transition: border-color .2s, color .2s, transform .2s;
}
.brand-mark > * { line-height: 1; }
/* Noto Sans JP katakana sits low in the em-box; nudge up to optical centre */
.brand-mark { padding-bottom: 2px; }
.brand-mark::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: var(--rad);
  pointer-events: none;
  box-shadow: 0 0 0 0 var(--accent);
  transition: box-shadow .25s ease;
}
.brand:hover .brand-mark { color: var(--accent-hi); border-color: var(--accent-dim); }
.brand:hover .brand-mark::before { box-shadow: 0 0 24px -4px color-mix(in oklab, var(--accent) 50%, transparent); }
.brand-name { font-size: 15px; }
.brand-name .dot { color: var(--accent); }

.topbar-nav {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 13px;
}
.topbar-nav a {
  color: var(--fg-muted);
  padding: 8px 12px;
  border-radius: var(--rad);
  letter-spacing: 0.02em;
  transition: color .15s, background-color .15s;
}
.topbar-nav a:hover { color: var(--fg); background: var(--surface); }

.topbar-tools { display: flex; align-items: center; gap: 8px; }

@media (max-width: 720px) {
  .topbar-inner { gap: 8px; height: 52px; }
  .topbar-nav { display: none; }
  .topbar-tools { margin-left: auto; }
  .brand-name { font-size: 14px; }
}

.icon-btn {
  width: 34px; height: 34px;
  display: inline-grid; place-items: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--rad);
  color: var(--fg-muted);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 12px;
  transition: color .15s, border-color .15s, background-color .15s;
}
.icon-btn:hover { color: var(--accent); border-color: var(--accent-dim); background: var(--surface); }
.icon-btn.is-active { color: var(--accent); border-color: var(--accent); }

.lang-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--rad);
  overflow: hidden;
  font-family: var(--font-mono);
  font-size: 12px;
}
.lang-toggle button {
  background: transparent;
  border: 0;
  color: var(--fg-dim);
  padding: 8px 10px;
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: color .15s, background-color .15s;
}
.lang-toggle button:hover { color: var(--fg); }
.lang-toggle button.is-active { color: var(--accent); background: var(--surface); }

/* ============================================================
   Hero
   ============================================================ */
.hero {
  padding-top: clamp(48px, 8vw, 88px);
  padding-bottom: clamp(56px, 9vw, 100px);
}
.hero-meta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}
.hero-meta .pulse {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 var(--green);
  animation: pulse 2.4s ease-out infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in oklab, var(--green) 60%, transparent); }
  70%  { box-shadow: 0 0 0 10px color-mix(in oklab, var(--green) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--green) 0%, transparent); }
}

.hero-headline {
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: clamp(34px, 5.6vw, 68px);
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0 0 24px;
  text-wrap: balance;
}
.hero-headline .accent { color: var(--accent); }

/* Brand-mark kanji is small, neutral, supportive — not a foreign-company signal.
   Reveals romaji on hover so the meaning is legible to a Swiss audience. */
.brand-mark {
  position: relative;
}
.brand-mark[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--fg-dim);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--rad);
  padding: 4px 8px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
  z-index: 5;
}
.brand:hover .brand-mark[data-tip]::after { opacity: 1; }

.hero-sub {
  max-width: 64ch;
  font-size: clamp(16px, 1.4vw, 19px);
  color: var(--fg-muted);
  line-height: 1.6;
  margin: 0 0 36px;
  text-wrap: pretty;
}

.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }

.btn {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.04em;
  padding: 12px 18px;
  border-radius: var(--rad);
  border: 1px solid var(--border-2);
  background: var(--surface);
  color: var(--fg);
  cursor: pointer;
  transition: border-color .15s, color .15s, background-color .15s, transform .1s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #061117;
}
.btn-primary:hover {
  background: var(--accent-hi);
  border-color: var(--accent-hi);
  color: #061117;
}
.btn .arrow { transition: transform .15s; }
.btn:hover .arrow { transform: translateX(3px); }

/* Hero terminal */
.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: clamp(24px, 5vw, 64px);
  align-items: end;
}
@media (max-width: 880px) { .hero-grid { grid-template-columns: 1fr; } }

.terminal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--rad-lg);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.terminal-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  color: var(--fg-dim);
  font-size: 11px;
  letter-spacing: 0.08em;
}
.terminal-bar .dots { display: flex; gap: 6px; }
.terminal-bar .dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--border-2); display: inline-block; }
.terminal-bar .title { margin-left: 8px; }
.terminal-body { padding: 16px 18px; min-height: 200px; }
.terminal-body .prompt { color: var(--accent); }
.terminal-body .cmd { color: var(--fg); }
.terminal-body .out { color: var(--fg-muted); }
.terminal-body .ok { color: var(--green); }
.terminal-body .key { color: var(--accent-hi); }
.cursor { display: inline-block; width: 8px; height: 1.05em; vertical-align: -2px;
  background: var(--accent); margin-left: 2px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ============================================================
   Section heading + ASCII divider
   ============================================================ */
.section-head {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: clamp(28px, 4vw, 48px);
}
.section-head .num {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--accent);
  letter-spacing: 0.1em;
}
.section-head h2 {
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: clamp(24px, 3vw, 36px);
  letter-spacing: -0.015em;
  margin: 0;
}
.section-head .rule {
  flex: 1;
  height: 1px;
  background: var(--border);
}
.section-head .tag {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ascii-divider {
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.2;
  color: var(--accent-dim);
  text-align: center;
  padding: 32px 0;
  white-space: pre;
  overflow: hidden;
  user-select: none;
  letter-spacing: 0.1em;
  opacity: 0.7;
}

/* ============================================================
   Services grid
   ============================================================ */
.services {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--service-min, 340px), 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--rad-lg);
  overflow: hidden;
}
.service {
  background: var(--surface);
  padding: 30px 28px;
  position: relative;
  transition: background-color .2s;
}
.service:hover { background: var(--surface-2); }
.service:hover .service-id { color: var(--accent); }

.service-id {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-dim);
  letter-spacing: 0.1em;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: color .2s;
}
.service-id::before {
  content: "▸";
  color: var(--accent);
}
.service h3 {
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 18px;
  margin: 0 0 12px;
  letter-spacing: -0.005em;
}
.service ul {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 14px;
  color: var(--fg-muted);
}
.service li {
  padding: 4px 0;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  letter-spacing: 0.005em;
  display: flex;
  gap: 8px;
}
.service li::before {
  content: "·";
  color: var(--accent);
  flex-shrink: 0;
  width: 8px;
  text-align: center;
}

/* ============================================================
   Engagement model — visually distinct from the service grid
   ============================================================ */
.engagement {
  margin-top: 28px;
  padding: 22px 24px;
  border: 1px dashed var(--border-2);
  border-radius: var(--rad-lg);
  background: linear-gradient(
    180deg,
    color-mix(in oklab, var(--accent) 4%, var(--bg)) 0%,
    transparent 100%
  );
}
.engagement-head {
  display: flex; align-items: center; gap: 16px;
  margin-bottom: 16px;
}
.engagement-head .tag {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.engagement-head .rule { flex: 1; height: 1px; background: var(--border); }
.engagement-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px 32px;
}
.eng-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-family: var(--font-mono);
}
.eng-item .lbl {
  font-size: 10px;
  color: var(--fg-dim);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.eng-item .val {
  font-size: 13px;
  color: var(--fg);
  line-height: 1.5;
}

/* ============================================================
   Selected work
   ============================================================ */
.work {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
}
.work-row {
  display: grid;
  grid-template-columns: 110px minmax(0, 2.2fr) minmax(0, 1.4fr) auto;
  gap: 24px;
  align-items: baseline;
  padding: 22px 4px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 14px;
  transition: background-color .15s;
}
.work-row:hover { background: color-mix(in oklab, var(--surface) 50%, transparent); }
.work-row .yr { color: var(--fg-dim); font-size: 12px; letter-spacing: 0.05em; }
.work-row .title {
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.005em;
}
.work-row .desc { color: var(--fg-muted); font-size: 13px; line-height: 1.55; }
.work-row .meta { color: var(--accent); font-size: 12px; text-align: right; letter-spacing: 0.05em; }
@media (max-width: 760px) {
  .work-row { grid-template-columns: 1fr; gap: 6px; padding: 18px 4px; }
  .work-row .meta { text-align: left; }
}

/* ============================================================
   Certifications
   ============================================================ */
.certs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.cert {
  border: 1px solid var(--border);
  border-radius: var(--rad);
  padding: 20px;
  background: var(--surface);
  transition: border-color .2s, transform .2s;
}
.cert:hover { border-color: var(--accent-dim); }
.cert .issuer {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-dim);
  letter-spacing: 0.1em;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
}
.cert .name {
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.35;
  letter-spacing: -0.005em;
}
.cert .yr { color: var(--accent); }

/* ============================================================
   Stats / signals
   ============================================================ */
.signals {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--rad-lg);
  overflow: hidden;
  margin-bottom: 40px;
}
.signal {
  background: var(--surface);
  padding: 24px 22px;
}
.signal .num {
  font-family: var(--font-mono);
  font-size: clamp(28px, 3vw, 40px);
  color: var(--accent);
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1;
}
.signal .label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 10px;
  line-height: 1.4;
}

/* ============================================================
   Availability + contact
   ============================================================ */
.contact-block {
  border: 1px solid var(--border);
  border-radius: var(--rad-lg);
  padding: 0;
  background: var(--surface);
  overflow: hidden;
}
.contact-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
}
@media (max-width: 760px) { .contact-grid { grid-template-columns: 1fr; } }
.contact-info {
  padding: 32px;
  border-right: 1px solid var(--border);
}
@media (max-width: 760px) {
  .contact-info { border-right: 0; border-bottom: 1px solid var(--border); }
}
.contact-info dl { margin: 0; display: grid; grid-template-columns: 130px 1fr; gap: 14px 16px; font-family: var(--font-mono); font-size: 13px; }
.contact-info dt { color: var(--fg-dim); letter-spacing: 0.05em; text-transform: uppercase; font-size: 11px; padding-top: 2px; }
.contact-info dd { margin: 0; color: var(--fg); }
.contact-info dd .accent { color: var(--accent); }

.contact-cta {
  padding: 32px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.contact-cta h3 {
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: 22px;
  margin: 0 0 10px;
  letter-spacing: -0.01em;
}
.contact-cta p { color: var(--fg-muted); margin: 0 0 20px; font-size: 14px; }
.contact-cta a.email {
  font-family: var(--font-mono);
  font-size: 16px;
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  padding: 12px 16px;
  border-radius: var(--rad);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  transition: background-color .15s, color .15s, border-color .15s;
  align-self: flex-start;
}
.contact-cta a.email:hover {
  background: var(--accent);
  color: #061117;
  border-color: var(--accent);
}

/* ============================================================
   Footer
   ============================================================ */
.foot {
  border-top: 1px solid var(--border);
  padding: 28px 0 60px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--fg-dim);
  display: flex;
  flex-wrap: wrap;
  gap: 16px 32px;
  justify-content: space-between;
  align-items: center;
}
.foot .flag { color: var(--red); }
.foot .right { display: flex; gap: 18px; }

/* ============================================================
   Scanline overlay (toggleable, time-limited)
   ============================================================ */
.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  opacity: 0;
  transition: opacity .4s ease;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(72, 174, 200, 0.05) 0,
      rgba(72, 174, 200, 0.05) 1px,
      transparent 1px,
      transparent 3px
    );
  mix-blend-mode: screen;
}
.scanlines::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(72, 174, 200, 0.06) 50%,
    transparent 100%
  );
  background-size: 100% 8px;
  animation: scan 2.4s linear infinite;
}
@keyframes scan {
  0%   { transform: translateY(-100%); }
  100% { transform: translateY(100%); }
}
body.scanlines-on .scanlines { opacity: 1; }

/* ============================================================
   Glitch utility (used on hover for headings)
   ============================================================ */
.glitch { position: relative; display: inline-block; }
.glitch[data-text]::before,
.glitch[data-text]::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity .15s;
}
.glitch[data-text]::before { color: var(--red); transform: translate(-1.5px, 0); mix-blend-mode: screen; }
.glitch[data-text]::after  { color: var(--accent); transform: translate(1.5px, 0); mix-blend-mode: screen; }
.glitch:hover::before { opacity: 0.7; animation: glitch-x 0.4s steps(2) infinite; }
.glitch:hover::after  { opacity: 0.7; animation: glitch-x 0.55s steps(2) infinite reverse; }
@keyframes glitch-x {
  0%   { transform: translate(-2px, 0); }
  25%  { transform: translate(2px, -1px); }
  50%  { transform: translate(-1px, 1px); }
  75%  { transform: translate(2px, 0); }
  100% { transform: translate(-2px, 0); }
}

/* ============================================================
   Reveal on enter
   ============================================================ */
.reveal { opacity: 0; transform: translateY(8px); transition: opacity .6s ease, transform .6s ease; }
.reveal.in { opacity: 1; transform: none; }

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  .cursor, .pulse, .scanlines::after { animation: none; }
}
