/* =========================================================
   DOT GRID BACKGROUND
   ========================================================= */

.dots {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;

  background-image: radial-gradient(
    circle at calc(var(--dot-size) / 2) calc(var(--dot-size) / 2),
    var(--color-dot) calc(var(--dot-size) / 2),
    transparent calc(var(--dot-size) / 2 + 0.5px)
  );

  background-size: var(--dot-gap) var(--dot-gap);
}


/* =========================================================
   GRID LINES
   Same pitch as the dots, and the lines run through the dot
   centres, so the dots appear to stretch into a grid.
   Hidden until js/door/main.js fades it in (opacity).
   ========================================================= */

.grid-lines {
  --half-dot: calc(var(--dot-size) / 2);
  --half-line: calc(var(--grid-line-width) / 2);

  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0;

  background-image:
    linear-gradient(
      to right,
      transparent calc(var(--half-dot) - var(--half-line)),
      var(--color-grid-line) calc(var(--half-dot) - var(--half-line)),
      var(--color-grid-line) calc(var(--half-dot) + var(--half-line)),
      transparent calc(var(--half-dot) + var(--half-line))
    ),
    linear-gradient(
      to bottom,
      transparent calc(var(--half-dot) - var(--half-line)),
      var(--color-grid-line) calc(var(--half-dot) - var(--half-line)),
      var(--color-grid-line) calc(var(--half-dot) + var(--half-line)),
      transparent calc(var(--half-dot) + var(--half-line))
    );

  background-size: var(--dot-gap) var(--dot-gap);
}


/* =========================================================
   HEADER
   ========================================================= */

.site-header {
  position: sticky;
  top: 0;

  z-index: 10;

  width: 100%;

  display: flex;
  justify-content: flex-end;
  align-items: center;

  padding: 40px 120px;
  gap: 40px;                    /* space between Resume / Blogs / LinkedIn */

  box-sizing: border-box;
}


/* =========================================================
   RESUME
   ========================================================= */

.resume-link {
  display: inline-block;

  font-family: "Work Sans", sans-serif;
  font-size: 20px;
  font-weight: 500;
  line-height: 1;

  color: var(--color-header-text);

  text-decoration: none;

  cursor: pointer;

  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

.resume-link:hover {
  opacity: 0.65;
}

.resume-link:active {
  transform: translateY(1px);
}


/* =========================================================
   MAIN CONTENT
   ========================================================= */

main {
  position: relative;
  z-index: 1;

  min-height: calc(100vh - 120px);

  display: flex;
  flex-direction: column;
  align-items: center;

  box-sizing: border-box;

  padding:
    0
    clamp(16px, 4vw, 60px)
    clamp(40px, 6vw, 80px);
}


/* =========================================================
   INTRO TEXT
   ========================================================= */

.intro {
  width: 100%;
  padding-top:132px;
  padding-bottom:132px;
  display: flex;
  justify-content: center;
  align-items: center;

  text-align: center;

  margin: 0;
}

.intro p {
  margin: 0;

  font-family: "Work Sans", sans-serif;
  font-weight: 600;

  font-size: clamp(24px, 5.4vw, 72px);
  line-height: 1.15;
  letter-spacing: -0.02em;
  text-wrap: balance;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;

  color: #323232;
}


/* =========================================================
   FOLDER
   ========================================================= */

.folder {
  --w: min(90vw, 1100px);

  position: relative;

  width: var(--w);

  aspect-ratio: 1042 / 721;

  cursor: pointer;

  perspective: calc(var(--w) * 1.447);
}


/* =========================================================
   FOLDER LAYERS
   ========================================================= */

.layer {
  position: absolute;

  inset: 0;

  transform-origin: 50% 100%;

  transition:
    transform 0.55s cubic-bezier(.2, .8, .2, 1),
    filter 0.55s;

  /* Each inside page is a ~3 MB SVG with a big picture embedded. Without this the browser
     re-draws it on every frame of the open / close animation (and decodes it on the first
     hover), which is what made the folder hang. This keeps each page as one ready-made
     layer on the GPU that is simply moved, so the animation stays smooth. */
  will-change: transform, filter;
  backface-visibility: hidden;

  filter:
    drop-shadow(0 1px 1px rgba(40, 30, 20, .16))
    drop-shadow(0 6px 8px rgba(40, 30, 20, .12))
    drop-shadow(0 18px 24px rgba(40, 30, 20, .10));
}


/* =========================================================
   SVG IMAGES
   ========================================================= */

.layer img {
  display: block;

  width: 100%;
  height: 100%;
}


/* =========================================================
   DEFAULT FOLDER POSITIONS
   ========================================================= */

.lb {
  --up: -43%;
  --s: .675;
}

.l3 {
  --up: -39%;
  --s: .68;
}

.l2 {
  --up: -26%;
  --s: .71;
}

.l1 {
  --up: -13%;
  --s: .74;
}

.lc {
  --up: 0%;
  --s: .78;
}


/* =========================================================
   FOLDER OPEN STATE
   ========================================================= */

.folder:hover .layer,
.folder.open .layer {
  transform:
    scale(var(--s))
    translateY(var(--up))
    rotateX(-42deg);
}


/* =========================================================
   ACTIVE LAYER
   ========================================================= */

.folder.has-active .layer:not(.active) {
  transform:
    scale(var(--as, var(--s)))
    translateY(calc(var(--up) + var(--sh, 0%)))
    rotateX(var(--at, -42deg));
}


/* =========================================================
   SELECTED / ACTIVE LAYER
   ========================================================= */

.folder .layer.active {
  transform:
    scale(var(--as, var(--s)))
    translateY(var(--aup, var(--up)))
    rotateX(0deg);
}


/* =========================================================
   CLICKABLE INSIDE LAYERS
   ========================================================= */

.layer:not(.lc) {
  cursor: pointer;
}


/* =========================================================
   REDUCED MOTION
   ========================================================= */

@media (prefers-reduced-motion: reduce) {

  .layer {
    transition: none;
  }

}


/* =========================================================
   CLOSED FOLDER SHADOW
   ========================================================= */

.folder:not(:hover):not(.open) .layer:not(.lc) {
  filter: none;
}


/* =========================================================
   TABLET
   ========================================================= */

@media (max-width: 900px) {

  .site-header {
    padding: 32px 60px;
  }

  main {
    min-height: calc(100vh - 100px);
  }

  .folder {
    --w: 88vw;
  }

}


/* =========================================================
   MOBILE
   ========================================================= */

@media (max-width: 700px) {

  .site-header {
    padding: 24px;
    gap: 24px;
  }

  main {
    min-height: calc(100vh - 80px);

    padding:
      0
      14px
      30px;
  }

  .folder {
    --w: 94vw;
  }

}


/* =========================================================
   SMALL MOBILE
   ========================================================= */

@media (max-width: 420px) {

  .site-header {
    padding: 20px 18px;
    gap: 18px;
  }

  main {
    min-height: calc(100vh - 70px);

    padding:
      0
      10px
      24px;
  }

  .folder {
    --w: 96vw;
  }

}


/* =========================================================
   PREVENT FOLDER ANIMATION FROM CREATING
   HORIZONTAL PAGE OVERFLOW
   ========================================================= */

html {
  overflow-x: clip;
}

body {
  overflow-x: clip;
}

/* =========================================================
   RADAR CHART COMPONENT
   Responsive wrapper for the original radar artwork.
   ========================================================= */

.radar-section {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: clamp(48px, 8vw, 120px) 0 clamp(48px, 8vw, 100px);
  box-sizing: border-box;
}

.radar-chart {
  position: relative;
  width: min(100%, 1280px);
  aspect-ratio: 1280 / 1000;
  margin: 0 auto;
  overflow: hidden;
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.radar-layer {
  position: absolute;
  left: 8.974296875%;
  top: 21.7406%;
  width: 75.34421875%;
  height: 64.3398%;
  display: block;
  -webkit-user-drag: none;
  user-select: none;
}

.radar-base,
.radar-pins {
  object-fit: fill;
  pointer-events: none;
}

.thread-canvas {
  touch-action: pan-y;
  pointer-events: auto;
}

@media (max-width: 700px) {
  .radar-section {
    padding-top: 36px;
    padding-bottom: 48px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .radar-chart {
    scroll-behavior: auto;
  }
}


/* =========================================================
   TABLET AND SMALLER (1024px and below): header links centred
   ========================================================= */
@media (max-width: 1024px) {
  .site-header {
    justify-content: center;
  }
}


/* =========================================================
   TAB BOOM
   A soft green pulse that grows out of the "Abdul Kalam"
   tab (Inside 1) so people can see it is clickable.
   It sits exactly over the tab: 288 x 88 of the 1042 x 721 page.
   It stops for good once any tab has been clicked open.
   ========================================================= */

.tab-boom {
  position: absolute;
  left: 0;
  top: 0;
  width: 27.6392%;   /* 288 / 1042 */
  height: 12.2053%;  /* 88 / 721 */

  overflow: visible;
  pointer-events: none;
}

.tab-boom g path {
  fill: #289E4B;
  stroke: none;

  transform-box: fill-box;
  transform-origin: center;

  animation: tab-boom 2s ease-out infinite;
}

@keyframes tab-boom {
  0%   { transform: scale(1, 1);        opacity: .6; }
  70%  { transform: scale(1.10, 1.30);  opacity: 0;  }
  100% { transform: scale(1.10, 1.30);  opacity: 0;  }
}

/* stop pulsing for good once any tab has been clicked open */
.folder.boom-done .tab-boom g path {
  animation: none;
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  .tab-boom g path {
    animation: none;
    opacity: 0;
  }
}


/* =========================================================
   TYPING EFFECT (second line of the intro heading)
   js/typing/main.js types / deletes the text inside .typed.
   The caret is a thin blinking bar after it.
   ========================================================= */

/* One line on tablets and desktops; may wrap on phones so nothing is cut off. */
@media (min-width: 600px) { .intro .intro-line { white-space: nowrap; } }

.typed-caret {
  display: inline-block;
  width: 0.06em;
  height: 0.95em;
  margin-left: 0.06em;
  vertical-align: -0.08em;
  background: currentColor;
  animation: typed-caret-blink 1s steps(1) infinite;
}

@keyframes typed-caret-blink {
  0%, 49%   { opacity: 1; }
  50%, 100% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .typed-caret { animation: none; }
}
