/* ==========================================================================
   STYLE.CSS - every line is commented so you can see what it does.
   Anything between slash-star and star-slash is a comment: the browser
   ignores it, so you can write notes anywhere.

   How CSS reads:   selector { property: value; }
   - selector  = WHICH element to style (h1, .navbar, #id, etc.)
   - property  = WHAT to change (color, margin, font-size...)
   - value     = HOW to change it
   ========================================================================== */


/* ==========================================================================
   1. VARIABLES (change these to recolour / re-font the whole site)
   ========================================================================== */

:root {                                   /* :root = the whole page. Variables made here work everywhere */
  --bg: #0b1020;                          /* page background: very dark navy. #rrggbb is a hex colour code */
  --surface: #131a2e;                     /* slightly lighter navy, used for code boxes and cards */
  --text: #e6edf7;                        /* main text colour: soft off-white (easier on eyes than pure white) */
  --muted: #8b98b3;                       /* dimmer blue-grey, used for paragraphs and less important text */
  --accent: #38bdf8;                      /* main accent: sky blue, used for links and highlights */
  --accent-2: #a78bfa;                    /* second accent: soft violet, used for hover glows and borders */
  --border: rgba(255, 255, 255, 0.08);    /* rgba = red, green, blue, opacity. This is white at 8% opacity (a faint line) */

  --font-heading: "Space Grotesk", sans-serif;  /* heading font. sans-serif is the backup if the font fails to load */
  --font-body: "Inter", system-ui, sans-serif;  /* body font. Backups are tried left to right */
  --font-code: "JetBrains Mono", monospace;     /* code font. monospace = every character the same width */
}                                         /* end of :root. Use any variable later with var(--name) */

/* ==========================================================================
   2. RESET (removes browser defaults so every browser starts the same)
   ========================================================================== */

*,                                        /* * means "every element" */
*::before,                                /* ::before and ::after are extra pieces the browser can add to elements */
*::after {
  box-sizing: border-box;                 /* makes width include padding + border, so boxes don't grow past the size you set */
}

html {                                    /* html = the whole document */
  scroll-behavior: smooth;                /* clicking a #link scrolls smoothly instead of jumping */
}

body {                                    /* body = everything visible on the page */
  margin: 0;                              /* removes the default 8px gap around the page */
  min-height: 100vh;                      /* at least as tall as the screen. vh = 1% of screen height, so 100vh = full height */
  background: var(--bg);                  /* uses the --bg variable from the top (dark navy) */
  color: var(--text);                     /* default text colour for the whole page */
  font-family: var(--font-body);          /* default font for the whole page (Inter) */
  line-height: 1.6;                       /* space between lines of text. 1.6 = 1.6x the font size (higher = more airy) */
}


/* ==========================================================================
   3. TYPOGRAPHY (text styles)
   ========================================================================== */

h1, h2, h3 {                              /* the comma means "all of these", so the rules apply to h1 AND h2 AND h3 */
  font-family: var(--font-heading);       /* headings use Space Grotesk */
  line-height: 1.2;                       /* tighter line spacing than body text, which suits big headings */
  margin: 0 0 0.5em;                      /* margin shorthand: top 0, sides 0, bottom 0.5em (em = relative to this element's font size) */
}

h1 { font-size: clamp(2.2rem, 6vw, 4rem); }  /* clamp(smallest, ideal, biggest): scales with screen width (6vw) but never below 2.2rem or above 4rem. rem = relative to the root font size (16px by default) */
h2 { font-size: clamp(1.5rem, 3vw, 2.2rem); } /* same idea for h2, with smaller sizes */

p {                                       /* paragraphs */
  color: var(--muted);                    /* dimmer text so headings stand out */
  margin: 0 0 1em;                        /* no top/side margin, 1em gap underneath to separate paragraphs */
}

a {                                       /* links */
  color: var(--accent);                   /* links are sky blue instead of the default purple/blue */
}

code, pre {                               /* code = inline code, pre = code blocks */
  font-family: var(--font-code);          /* monospace font */
  background: var(--surface);             /* slightly lighter box behind the code */
  border: 1px solid var(--border);        /* border shorthand: thickness, style, colour */
  border-radius: 6px;                     /* rounds the corners. Bigger number = rounder */
}

code { padding: 0.15em 0.4em; }           /* inline code: 0.15em top/bottom, 0.4em left/right (padding = space INSIDE the box) */
pre  { padding: 1rem; overflow-x: auto; } /* code blocks: padding all around, and a sideways scrollbar appears if a line is too wide */


/* ==========================================================================
   4. NAVBAR (the bar at the top)
   ========================================================================== */

.navbar {                                 /* the dot means "class". This styles <nav class="navbar"> */
  display: grid;                          /* turns the navbar into a grid so we can place things in columns */
  grid-template-columns: 1fr auto 1fr;    /* 3 columns: left (1fr), middle (auto = as wide as the links), right (1fr). The two 1fr columns are equal, so the middle is perfectly centred. fr = a share of the free space */
  align-items: center;                    /* vertically centres everything in the bar */
  padding: 15px 30px;                     /* 15px top/bottom, 30px left/right */
  background: rgba(19, 26, 46, 0.6);     /* navy at 60% opacity. Lower the last number for more see-through */
  -webkit-backdrop-filter: blur(10px);    /* blurs whatever is behind the bar (Safari version) */
  backdrop-filter: blur(10px);            /* same blur for other browsers. Raise 10px for a stronger frosted look */
  border-bottom: 1px solid var(--border); /* a faint line along the bottom edge only */
  position: sticky;                       /* bar scrolls normally until it reaches the top, then sticks there */
  top: 0;                                 /* sticks 0px from the top of the screen (needed for sticky to work) */
  z-index: 1000;                          /* stacking order: higher numbers sit on top, so the bar stays above page content */
}

.logo {
  grid-column: 1;
  justify-content: start;
}

.logo img {
  height: 72px;
  width: auto;
  display: block;
}

.codenavlinks {                           /* the <ul class="codenavlinks"> list that holds the links */
  grid-column: 2;
  justify-content: center;
  list-style: none;                       /* removes the bullet points */
  margin: 0;                              /* removes the default margin around the list */
  padding: 0;                             /* removes the default left indent lists have */
  display: flex;                          /* flexbox puts the list items side by side in a row */
  gap: 12px;                              /* space between the links */
}

.codenavlinks a {                         /* the links inside that list (space = "inside") */
  display: inline-block;                  /* lets the link have padding and be moved/scaled like a box, while staying in the row */
  padding: 10px 30px;                      /* 8px top/bottom, 18px left/right: this makes the pill shape */
  border-radius: 999px;                   /* huge radius = fully rounded ends (a pill) */
  border: 1px solid transparent;          /* invisible border for now, so the hover border doesn't shift the layout */
  color: var(--text);                     /* link text is off-white (overrides the blue from the plain "a" rule) */
  text-decoration: none;                  /* removes the underline */
  font-family: var(--font-heading);       /* links use the heading font */
  font-weight: 500;                       /* medium boldness. 400 = normal, 700 = bold */
  transition:                             /* makes changes animate smoothly instead of snapping. Each line is one property */
    transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), /* movement/scale takes 0.25s. The curve numbers overshoot slightly = the springy bounce. Raise 1.56 for more bounce */
    box-shadow 0.2s ease,                 /* the glow fades in over 0.2 seconds */
    background 0.2s ease,                 /* the background colour fades */
    color 0.2s ease,                      /* the text colour fades */
    border-color 0.2s ease;               /* the border colour fades. ease = starts fast, ends slow */
}

/* Hover: when the mouse is over a link */
.codenavlinks a:hover {                   /* :hover = only while the mouse is on it */
  transform: translateY(-3px) scale(1.08); /* moves up 3px (negative = up) and grows to 108% size */
  color: var(--accent);                   /* text turns sky blue */
  border-color: var(--accent-2);          /* the invisible border becomes violet */
  background: rgba(56, 189, 248, 0.08);   /* a very faint blue fill (8% opacity) */
  box-shadow: 0 6px 18px rgba(167, 139, 250, 0.3); /* glow: 0 sideways, 6px down, 18px blur, then the colour (violet at 30%) */
}

/* Click: while the mouse button is held down */
.codenavlinks a:active {                  /* :active = only while being clicked */
  transform: translateY(1px) scale(0.88); /* pushes down 1px and shrinks to 88% (the squish). Lower 0.88 for a deeper squish */
  box-shadow: 0 0 6px rgba(56, 189, 248, 0.4); /* small tight blue glow while pressed */
  transition-duration: 0.08s;             /* the squish happens fast (0.08s). On release the normal 0.25s spring-back plays = the "bloop" */
}

/* Keyboard users: shows which link is selected when tabbing */
.codenavlinks a:focus-visible {           /* only shows when navigating with the keyboard (Tab key) */
  outline: 2px solid var(--accent);       /* a 2px blue ring around the link */
  outline-offset: 3px;                    /* 3px gap between the link and the ring */
}

/* Accessibility: some people turn off animations in their computer settings */
@media (prefers-reduced-motion: reduce) { /* @media = "only apply this when the condition is true". Here: the user asked for less motion */
  .codenavlinks a {
    transition: none;                     /* no animation for those users */
  }
  .codenavlinks a:hover,                  /* hover and click states... */
  .codenavlinks a:active {
    transform: none;                      /* ...don't move or resize the links */
  }
}


.infolinks {                           /* the <ul class="infolinks"> list that holds the links */
  grid-column: 3;
  justify-content: end;
  list-style: none;                       /* removes the bullet points */
  margin: 0;                              /* removes the default margin around the list */
  padding: 0;                             /* removes the default left indent lists have */
  display: flex;                          /* flexbox puts the list items side by side in a row */
  gap: 12px;                              /* space between the links */
}

.infolinks a {                         /* the links inside that list (space = "inside") */
  display: inline-block;                  /* lets the link have padding and be moved/scaled like a box, while staying in the row */
  padding: 8px 18px;                      /* 8px top/bottom, 18px left/right: this makes the pill shape */
  border-radius: 999px;                   /* huge radius = fully rounded ends (a pill) */
  border: 1px solid transparent;          /* invisible border for now, so the hover border doesn't shift the layout */
  color: var(--text);                     /* link text is off-white (overrides the blue from the plain "a" rule) */
  text-decoration: none;                  /* removes the underline */
  font-family: var(--font-heading);       /* links use the heading font */
  font-weight: 500;                       /* medium boldness. 400 = normal, 700 = bold */
  transition:                             /* makes changes animate smoothly instead of snapping. Each line is one property */
    transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), /* movement/scale takes 0.25s. The curve numbers overshoot slightly = the springy bounce. Raise 1.56 for more bounce */
    box-shadow 0.2s ease,                 /* the glow fades in over 0.2 seconds */
    background 0.2s ease,                 /* the background colour fades */
    color 0.2s ease,                      /* the text colour fades */
    border-color 0.2s ease;               /* the border colour fades. ease = starts fast, ends slow */
}

/* Hover: when the mouse is over a link */
.infolinks a:hover {                   /* :hover = only while the mouse is on it */
  transform: translateY(-3px) scale(1.08); /* moves up 3px (negative = up) and grows to 108% size */
  color: var(--accent);                   /* text turns sky blue */
  border-color: var(--accent-2);          /* the invisible border becomes violet */
  background: rgba(56, 189, 248, 0.08);   /* a very faint blue fill (8% opacity) */
  box-shadow: 0 6px 18px rgba(167, 139, 250, 0.3); /* glow: 0 sideways, 6px down, 18px blur, then the colour (violet at 30%) */
}

/* Click: while the mouse button is held down */
.infolinks a:active {                  /* :active = only while being clicked */
  transform: translateY(1px) scale(0.88); /* pushes down 1px and shrinks to 88% (the squish). Lower 0.88 for a deeper squish */
  box-shadow: 0 0 6px rgba(56, 189, 248, 0.4); /* small tight blue glow while pressed */
  transition-duration: 0.08s;             /* the squish happens fast (0.08s). On release the normal 0.25s spring-back plays = the "bloop" */
}

/* Keyboard users: shows which link is selected when tabbing */
.infolinks a:focus-visible {           /* only shows when navigating with the keyboard (Tab key) */
  outline: 2px solid var(--accent);       /* a 2px blue ring around the link */
  outline-offset: 3px;                    /* 3px gap between the link and the ring */
}

/* Accessibility: some people turn off animations in their computer settings */
@media (prefers-reduced-motion: reduce) { /* @media = "only apply this when the condition is true". Here: the user asked for less motion */
  .infolinks a {
    transition: none;                     /* no animation for those users */
  }
  .infolinks a:hover,                  /* hover and click states... */
  .infolinks a:active {
    transform: none;                      /* ...don't move or resize the links */
  }
}

/* ==========================================================================
   5. PAGE CONTENT WRAPPER
   ========================================================================== */

.content {                                /* put your page content inside <main class="content"> */
  max-width: 900px;                       /* never wider than 900px, which keeps text readable on big screens */
  margin: 0 auto;                         /* 0 top/bottom, auto left/right. auto splits the leftover space evenly = centres the block */
  padding: 10vh 30px 0;                   /* 3 values: top 10vh (10% of screen height), left/right 30px, bottom 0 */
}
