/* ==========================================================================
   Afiq N — Minimalist Gallery Stylesheet
   Zero gradients, zero fake grain, zero neon, zero AI slop.
   ========================================================================== */

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

:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

  --bg: #FFFFFF;
  --ink: #111111;
  --ink-secondary: #5E5E5E;
  --ink-muted: #9A9A9A;
  --rule: #EAEAEA;
  --rule-hover: #CCCCCC;
  --shelf: #161616;

  --ease-out: cubic-bezier(0.19, 1, 0.22, 1);
  --ease-spring: cubic-bezier(0.22, 1, 0.36, 1);
}

html {
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100dvh;
  background-color: var(--bg);
  color: var(--ink);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

body.is-wire-hover {
  cursor: grab;
}

body.is-wire-dragging,
body.is-wire-dragging * {
  user-select: none !important;
  -webkit-user-select: none !important;
  -webkit-touch-callout: none !important;
  overscroll-behavior: none;
  cursor: grabbing !important;
}

body.is-wire-dragging .row-link,
body.is-wire-dragging .text-nav-link,
body.is-wire-dragging .underline-tab {
  pointer-events: none;
}

/* Fullscreen non-blocking layer for the elastic shelf wire & resident cat */
#cat-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 30;
  pointer-events: none;
}

/* ==========================================================================
   Views & Line-Born Clip-Path Spatial Page Reveal
   ========================================================================== */
.view {
  display: none;
  min-height: 100dvh;
  width: 100%;
  padding-left: clamp(20px, 6vw, 40px);
  padding-right: clamp(20px, 6vw, 40px);
  padding-bottom: max(56px, env(safe-area-inset-bottom) + 36px);
}

.view.is-active {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.view.is-revealing {
  animation: shelfReveal 360ms var(--ease-out) both;
}

@keyframes shelfReveal {
  0% {
    clip-path: inset(var(--reveal-y, 34%) 0 calc(100% - var(--reveal-y, 34%)) 0);
  }
  100% {
    clip-path: inset(0 0 0 0);
  }
}

.view-home.is-active {
  justify-content: center;
  padding-top: max(40px, env(safe-area-inset-top) + 24px);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.view-sub.is-active {
  justify-content: flex-start;
  padding-top: max(28px, env(safe-area-inset-top) + 18px);
}

.col-narrow {
  width: 100%;
  max-width: 420px;
}

.col-wide {
  width: 100%;
  max-width: 620px;
}

/* Open headroom above the shelf so the resident has space to leap and stretch */
.home-stage {
  padding-top: clamp(72px, 14vh, 130px);
}

.sub-stage {
  padding-top: clamp(64px, 10vh, 96px);
}

/* ==========================================================================
   Elastic Physical Shelf Anchor
   Rendered dynamically by #cat-canvas as a taut vibrating wire; solid fallback
   when reduced motion is active or JS is disabled.
   ========================================================================== */
.cat-shelf {
  width: 100%;
  height: 1.5px;
  background-color: transparent;
  position: relative;
}

/* Native touch-action strip around the 1.5px shelf wire so mobile / Instagram
   in-app browser plucks the wire cleanly without triggering scroll or pull-to-refresh */
.cat-shelf::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: -16px;
  bottom: -16px;
  touch-action: none;
}

/* ==========================================================================
   Sub-Page Top Navigation
   ========================================================================== */
.sub-nav {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  user-select: none;
  -webkit-user-select: none;
}

.text-nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  background: none;
  border: none;
  padding: 4px 0;
  color: var(--ink-secondary);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 400;
  letter-spacing: -0.01em;
  text-decoration: underline;
  text-decoration-color: transparent;
  text-underline-offset: 4px;
  cursor: pointer;
  transition: color 180ms ease, text-decoration-color 180ms ease;
}

.text-nav-link:hover,
.text-nav-link:focus-visible {
  color: var(--ink);
  text-decoration-color: var(--rule-hover);
  outline: none;
}

/* ==========================================================================
   Spring-Sliding Underline Tabs (Dial/All & Anonymous/With name)
   ========================================================================== */
.underline-tabs {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 20px;
  border-bottom: 1px solid var(--rule);
  user-select: none;
  -webkit-user-select: none;
}

.msg-identity-tabs {
  margin-bottom: 24px;
}

.underline-tab {
  position: relative;
  padding: 6px 0 9px;
  border: none;
  background: none;
  color: var(--ink-muted);
  font-family: var(--font-sans);
  font-size: 0.84rem;
  font-weight: 450;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: color 180ms ease;
}

.underline-tab:hover {
  color: var(--ink);
}

.underline-tab.is-selected {
  color: var(--ink);
}

.tab-indicator {
  position: absolute;
  left: 0;
  bottom: -1px;
  height: 1.5px;
  width: 0;
  background-color: var(--ink);
  transform-origin: left center;
  transition:
    transform 300ms var(--ease-spring),
    width 300ms var(--ease-spring);
  pointer-events: none;
}

/* ==========================================================================
   Home View — Identity & Clean Link Rows
   ========================================================================== */
.identity-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 0 28px;
}

.identity-name {
  font-size: 1.32rem;
  font-weight: 500;
  letter-spacing: -0.028em;
  line-height: 1.1;
  color: var(--ink);
}

.link-list-wrap {
  position: relative;
}

.link-highlight {
  position: absolute;
  top: 0;
  left: -12px;
  right: -12px;
  height: 44px;
  border-radius: 8px;
  background-color: #F4F4F4;
  opacity: 0;
  pointer-events: none;
  z-index: 0;
  transform: translate3d(0, 0, 0) scale(0.985);
  transform-origin: center center;
  will-change: transform, height, opacity;
  transition:
    transform 240ms var(--ease-spring),
    height 240ms var(--ease-spring),
    opacity 160ms ease,
    background-color 140ms ease;
}

.link-highlight.no-glide {
  transition:
    opacity 160ms ease,
    background-color 140ms ease;
}

.link-highlight.is-visible {
  opacity: 1;
}

.link-highlight.is-pressed {
  background-color: #EBEBEB;
}

.link-list {
  position: relative;
  z-index: 1;
  list-style: none;
  border-top: 1px solid var(--rule);
}

.link-list-item {
  border-bottom: 1px solid var(--rule);
}

.row-link {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 50px;
  padding: 13px 2px;
  background: none;
  border: none;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 0.94rem;
  font-weight: 400;
  letter-spacing: -0.012em;
  text-decoration: none;
  text-align: left;
  cursor: pointer;
  transition: opacity 200ms ease, color 180ms ease;
}

.row-link:focus-visible {
  outline: none;
}

/* Sibling quiet-dim: focused row stays razor-sharp, others recede gently */
.link-list.has-active .row-link {
  opacity: 0.36;
}

.link-list.has-active .row-link.is-active {
  opacity: 1;
}

.row-meta {
  font-size: 0.82rem;
  font-weight: 400;
  letter-spacing: -0.008em;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
  transition: color 180ms ease;
}

.row-link.is-active .row-meta,
.row-link:hover .row-meta,
.row-link:focus-visible .row-meta {
  color: var(--ink);
}

/* ==========================================================================
   Publications View — Scannable Academic Index
   ========================================================================== */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 0 28px;
}

.section-title {
  font-size: 1.32rem;
  font-weight: 500;
  letter-spacing: -0.028em;
  line-height: 1.1;
  color: var(--ink);
}

.pub-groups {
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.pub-year-heading {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 6px;
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.pub-year-rule {
  flex: 1;
  height: 1px;
  background-color: var(--rule);
}

.pub-list {
  list-style: none;
}

.pub-entry {
  padding: 18px 0;
  border-bottom: 1px solid var(--rule);
  transform-origin: center center;
  will-change: transform;
}

.pub-entry:last-child {
  border-bottom: none;
}

.pub-title-link {
  display: inline;
  color: var(--ink);
  font-size: 0.96rem;
  font-weight: 500;
  line-height: 1.46;
  letter-spacing: -0.014em;
  text-decoration: none;
  transition: opacity 180ms ease;
}

.pub-title-link:hover,
.pub-title-link:focus-visible {
  opacity: 0.65;
  outline: none;
}

.pub-authors {
  margin-top: 6px;
  font-size: 0.82rem;
  line-height: 1.55;
  color: var(--ink-secondary);
}

.pub-authors strong {
  font-weight: 500;
  color: var(--ink);
}

.pub-footer {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
}

.pub-venue {
  font-size: 0.78rem;
  letter-spacing: -0.006em;
  color: var(--ink-muted);
}

.pub-actions {
  display: inline-flex;
  align-items: center;
  gap: 16px;
}

.pub-btn {
  display: inline-flex;
  align-items: center;
  background: none;
  border: none;
  padding: 2px 0;
  color: var(--ink-muted);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: -0.006em;
  text-decoration: none;
  cursor: pointer;
  transition: color 160ms ease, filter 160ms ease, opacity 160ms ease;
}

.pub-btn:hover,
.pub-btn:focus-visible {
  color: var(--ink);
  outline: none;
}

.pub-btn.is-copied {
  color: var(--ink);
}

/* Micro-blur text swap helper (BibTeX -> Copied & Sending as ...) */
.blur-text {
  transition: filter 150ms ease, opacity 150ms ease, transform 160ms var(--ease-out);
}

.blur-swapping {
  filter: blur(2.5px);
  opacity: 0.2;
  transform: translateY(-2px);
}

/* ==========================================================================
   Send a Message View — Minimal, Anonymous or Named
   ========================================================================== */
.msg-lead {
  margin-top: -16px;
  margin-bottom: 24px;
  font-size: 0.87rem;
  line-height: 1.55;
  color: var(--ink-secondary);
}

.msg-form {
  display: flex;
  flex-direction: column;
}

.name-collapse {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows 280ms var(--ease-out), opacity 220ms ease, margin-bottom 280ms var(--ease-out);
  margin-bottom: 0;
}

.name-collapse.is-open {
  grid-template-rows: 1fr;
  opacity: 1;
  margin-bottom: 22px;
}

.name-collapse-inner {
  overflow: hidden;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.field-hint {
  font-weight: 400;
  font-size: 0.75rem;
  color: var(--ink-muted);
}

.field-input,
.field-textarea {
  width: 100%;
  background-color: transparent;
  border: none;
  border-bottom: 1px solid var(--rule);
  border-radius: 0;
  padding: 10px 0 11px;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.55;
  letter-spacing: -0.01em;
  transition: border-color 180ms ease;
  user-select: text;
  -webkit-user-select: text;
}

.field-textarea {
  resize: vertical;
  min-height: 104px;
  max-height: 300px;
}

.field-input::placeholder,
.field-textarea::placeholder {
  color: var(--ink-muted);
}

.field-input:focus,
.field-textarea:focus {
  outline: none;
  border-bottom-color: var(--ink);
}

.field-input:read-only,
.field-textarea:read-only {
  opacity: 0.55;
}

.msg-actions {
  margin-top: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.msg-sender-note {
  font-size: 0.78rem;
  letter-spacing: -0.006em;
  color: var(--ink-muted);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 96px;
  height: 38px;
  padding: 0 18px;
  border: none;
  border-radius: 8px;
  background-color: var(--ink);
  color: var(--bg);
  font-family: var(--font-sans);
  font-size: 0.84rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  cursor: pointer;
  transition: opacity 180ms ease, transform 160ms var(--ease-spring);
}

.btn-primary:hover:not(:disabled) {
  opacity: 0.86;
}

.btn-primary:active:not(:disabled) {
  transform: scale(0.97);
}

.btn-primary:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.msg-status {
  margin-top: 14px;
  min-height: 1.3em;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--ink-secondary);
}

.msg-receipt {
  padding: 6px 0 12px;
}

.msg-receipt[hidden] {
  display: none;
}

.receipt-title {
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: -0.018em;
  color: var(--ink);
}

.receipt-meta {
  margin-top: 8px;
  font-size: 0.84rem;
  line-height: 1.55;
  color: var(--ink-secondary);
}

.receipt-actions {
  margin-top: 24px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.receipt-btn {
  background: none;
  border: none;
  padding: 6px 0;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: var(--rule-hover);
  text-underline-offset: 4px;
  cursor: pointer;
  transition: text-decoration-color 180ms ease;
}

.receipt-btn:hover {
  text-decoration-color: var(--ink);
}

/* ==========================================================================
   Focus & Accessibility
   ========================================================================== */
:focus-visible {
  outline: 1.5px solid var(--ink);
  outline-offset: 3px;
  border-radius: 3px;
}

.field-input:focus-visible,
.field-textarea:focus-visible {
  outline: none;
}

@media (prefers-reduced-motion: reduce) {
  .cat-shelf {
    background-color: var(--shelf);
  }
  .view.is-revealing {
    animation: none;
  }
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
  }
}
