:root {
  --navy: #0f1b2d;
  --navy-light: #16273f;
  --orange: #ff9900;
  --orange-text: #a35f00; /* accessible orange for text on light backgrounds (~5:1 contrast) */
  --text: #1c2530;
  --text-muted: #5a6472;
  --bg-main: #f6f8fa;
  --bg-alt: #eef1f4;
  --border: #d5dbe2;
  --max-width: 860px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  line-height: 1.6;
  background: var(--bg-main);
  border-top: 4px solid var(--orange);
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

h1, h2, h3 {
  font-weight: 600;
  line-height: 1.25;
}

h2 {
  font-size: 1.6rem;
  margin-bottom: 24px;
  color: var(--navy);
}

h3 {
  font-size: 1.05rem;
  margin: 0 0 8px 0;
  color: var(--navy);
}

p {
  margin: 0 0 12px 0;
  color: var(--text-muted);
}

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

a:hover {
  text-decoration: underline;
}

/* Hero */

.hero {
  background: linear-gradient(rgba(15, 27, 45, 0.9), rgba(15, 27, 45, 0.9)), url('../images/hero-bg.jpg');
  background-size: cover;
  background-position: center 55%;
  background-repeat: no-repeat;
  color: #fff;
  padding: 84px 0 42px;
}

.hero-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 40px;
  padding-bottom: 42px;
}

.avatar {
  width: 195px;
  height: 195px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--orange);
  display: block;
  flex-shrink: 0;
}

.hero-text {
  text-align: left;
}

.hero h1 {
  margin: 0;
  font-size: 3.125rem;
  color: #fff;
  font-variant: all-small-caps;
  letter-spacing: 0.03em;
}

.hero .tagline {
  color: #d7dee7;
  font-size: 1.35rem;
  margin: 10px 0 5px;
}

.hero .location {
  color: #93a1b3;
  font-size: 1.1rem;
  margin: 0;
}

.hero-nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 24px;
  padding-top: 26px;
  border-top: 1px solid rgba(255,255,255,0.12);
}

.hero-nav a {
  color: #d7dee7;
  font-size: 0.9rem;
}

.hero-nav a:hover {
  color: var(--orange);
  text-decoration: none;
}

/* Sections */

.section {
  padding: 56px 0;
  background-image: radial-gradient(rgba(15, 27, 45, 0.07) 1px, transparent 1px);
  background-size: 24px 24px;
  background-attachment: fixed;
}

.section.alt {
  background-color: var(--bg-alt);
  border-top: 1px solid rgba(15, 27, 45, 0.05);
  border-bottom: 1px solid rgba(15, 27, 45, 0.05);
}

/* Expertise grid */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}

.card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.card:hover {
  box-shadow: 0 8px 20px rgba(15, 27, 45, 0.08);
  transform: translateY(-2px);
}

.card p {
  font-size: 0.92rem;
  margin: 0;
}

.card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.card-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--orange);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Expandable cards (Outside Work) */

#interests .grid {
  grid-auto-rows: 236px;
  align-items: stretch;
}

.card-expandable {
  overflow: hidden;
  cursor: pointer;
}

.card-expandable p {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-expandable::after {
  content: "Read more…";
  display: block;
  margin-top: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--orange-text);
}

.card-expandable.no-clamp::after {
  display: none;
}

.card-expandable:focus,
.card-expandable:focus-within,
.card-expandable.is-tapped {
  position: relative;
  align-self: start;
  z-index: 5;
  height: auto;
  outline: none;
  box-shadow: 0 14px 30px rgba(15, 27, 45, 0.18);
}

.card-expandable:focus p,
.card-expandable:focus-within p,
.card-expandable.is-tapped p {
  -webkit-line-clamp: unset;
  overflow: visible;
}

.card-expandable:focus::after,
.card-expandable:focus-within::after,
.card-expandable.is-tapped::after {
  display: none;
}

/* Real hover only applies on devices with an actual pointer, so touch
   devices rely solely on the tap-to-toggle JS above (avoids the
   iOS "first tap triggers hover" quirk on elements with hover styles). */
@media (hover: hover) and (pointer: fine) {
  .card-expandable:hover {
    position: relative;
    align-self: start;
    z-index: 5;
    height: auto;
    outline: none;
    box-shadow: 0 14px 30px rgba(15, 27, 45, 0.18);
  }

  .card-expandable:hover p {
    -webkit-line-clamp: unset;
    overflow: visible;
  }

  .card-expandable:hover::after {
    display: none;
  }
}

/* Timeline */

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
}

.timeline::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--border);
}

.timeline li {
  position: relative;
  padding-left: 36px;
  margin-bottom: 18px;
}

.timeline li:last-child {
  margin-bottom: 0;
}

.timeline-marker {
  position: absolute;
  left: 0;
  top: 24px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--orange);
  z-index: 1;
}

.timeline-current .timeline-marker {
  background: var(--orange);
  box-shadow: 0 0 0 4px rgba(255, 153, 0, 0.18);
}

.timeline-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.timeline-card:hover {
  box-shadow: 0 8px 20px rgba(15, 27, 45, 0.08);
  transform: translateY(-2px);
}

.timeline-current .timeline-card {
  border-color: rgba(255, 153, 0, 0.35);
}

.timeline-card h3 {
  margin: 0 0 6px;
}

.timeline-date {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  color: #7a4a00;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: rgba(255, 153, 0, 0.22);
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 10px;
}

.timeline p {
  margin: 0;
  font-size: 0.92rem;
}

/* Certifications */

.cert-group {
  margin-bottom: 32px;
}

.cert-group:last-of-type {
  margin-bottom: 20px;
}

.cert-group-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0 0 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.cert-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  grid-auto-rows: 148px;
  gap: 22px 12px;
}

.cert-tile {
  display: block;
  position: relative;
  text-align: center;
  color: inherit;
  padding: 12px 8px;
  border-radius: 12px;
  z-index: 1;
  cursor: pointer;
  transition: background 0.2s ease, box-shadow 0.2s ease, width 0.2s ease, margin 0.2s ease, padding 0.2s ease;
}

.cert-tile:focus,
.cert-tile:focus-within,
.cert-tile.is-tapped {
  text-decoration: none;
  background: #fff;
  box-shadow: 0 10px 24px rgba(15, 27, 45, 0.12);
  outline: none;
}

.cert-tile:not(.cert-tile-static):focus,
.cert-tile:not(.cert-tile-static):focus-within,
.cert-tile.is-tapped:not(.cert-tile-static) {
  align-self: start;
  height: auto;
  z-index: 30;
  width: 220px;
  margin-left: -35px;
  margin-right: -35px;
  padding: 16px 14px 18px;
  box-shadow: 0 16px 34px rgba(15, 27, 45, 0.2);
}

.cert-icon {
  display: block;
  position: relative;
  width: 74px;
  height: 74px;
  margin: 0 auto 8px;
  transition: transform 0.25s ease;
}

.cert-icon img {
  position: absolute;
  top: 0;
  left: 0;
  width: 74px;
  height: 74px;
  object-fit: contain;
  transition: opacity 0.3s ease;
}

.cert-icon .icon-color {
  opacity: 0;
}

.cert-tile:focus .cert-icon,
.cert-tile:focus-within .cert-icon,
.cert-tile.is-tapped .cert-icon {
  transform: scale(1.08);
}

.cert-tile:focus .icon-mono,
.cert-tile:focus-within .icon-mono,
.cert-tile.is-tapped .icon-mono {
  opacity: 0;
}

.cert-tile:focus .icon-color,
.cert-tile:focus-within .icon-color,
.cert-tile.is-tapped .icon-color {
  opacity: 1;
}

.cert-tile-expired .icon-mono {
  opacity: 0.55;
}

.cert-issuer {
  display: block;
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.cert-name {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--navy);
  line-height: 1.3;
}

.cert-tile-expired .cert-name {
  color: var(--text-muted);
}

.cert-detail {
  display: block;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: 0;
  transition: max-height 0.25s ease, opacity 0.2s ease, margin-top 0.25s ease;
}

.cert-tile:focus .cert-detail,
.cert-tile:focus-within .cert-detail,
.cert-tile.is-tapped .cert-detail {
  max-height: 50px;
  opacity: 1;
  margin-top: 4px;
}

.cert-desc {
  display: block;
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  text-align: left;
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: 0;
  transition: max-height 0.3s ease, opacity 0.25s ease, margin-top 0.3s ease;
}

.cert-tile:focus .cert-desc,
.cert-tile:focus-within .cert-desc,
.cert-tile.is-tapped .cert-desc {
  max-height: 220px;
  opacity: 1;
  margin-top: 10px;
}

/* Real hover only applies on devices with an actual pointer, so touch
   devices rely solely on the tap-to-toggle JS above (avoids the
   iOS "first tap triggers hover" quirk on elements with hover styles). */
@media (hover: hover) and (pointer: fine) {
  .cert-tile:hover {
    text-decoration: none;
    background: #fff;
    box-shadow: 0 10px 24px rgba(15, 27, 45, 0.12);
    outline: none;
  }

  .cert-tile:not(.cert-tile-static):hover {
    align-self: start;
    height: auto;
    z-index: 30;
    width: 220px;
    margin-left: -35px;
    margin-right: -35px;
    padding: 16px 14px 18px;
    box-shadow: 0 16px 34px rgba(15, 27, 45, 0.2);
  }

  .cert-tile:hover .cert-icon {
    transform: scale(1.08);
  }

  .cert-tile:hover .icon-mono {
    opacity: 0;
  }

  .cert-tile:hover .icon-color {
    opacity: 1;
  }

  .cert-tile:hover .cert-detail {
    max-height: 50px;
    opacity: 1;
    margin-top: 4px;
  }

  .cert-tile:hover .cert-desc {
    max-height: 220px;
    opacity: 1;
    margin-top: 10px;
  }
}

.cert-tile-static {
  cursor: default;
}

.badges-link {
  margin: 0;
}

/* Contact */

.contact-section {
  background: linear-gradient(160deg, rgba(22, 39, 63, 0.9), rgba(15, 27, 45, 0.9) 65%), url('../images/contact-bg.jpg');
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  color: #fff;
  text-align: center;
}

.contact-section h2 {
  color: #fff;
  font-size: 2rem;
  margin-bottom: 10px;
}

.contact-section p {
  color: #d7dee7;
  font-size: 1.05rem;
  max-width: 480px;
  margin: 0 auto 8px;
}

.contact-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  margin-top: 24px;
}

.contact-btn {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  border-radius: 999px;
  padding: 10px 30px 10px 10px;
  font-weight: 700;
  font-size: 1rem;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.contact-btn:hover {
  text-decoration: none;
  transform: translateY(-2px);
}

.contact-btn-primary {
  background: linear-gradient(135deg, #ffad33, var(--orange));
  color: var(--navy);
}

.contact-btn-primary:hover {
  box-shadow: 0 10px 24px rgba(255, 153, 0, 0.35);
}

.contact-btn-primary .contact-btn-icon {
  background: var(--navy);
}

.contact-btn-secondary {
  background: transparent;
  color: #fff;
  border: 2px solid rgba(255, 255, 255, 0.4);
  padding: 8px 28px 8px 8px;
}

.contact-btn-secondary:hover {
  border-color: var(--orange);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
}

.contact-btn-secondary .contact-btn-icon {
  background: rgba(255, 255, 255, 0.15);
}

.contact-btn-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.contact-btn-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--orange);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Footer */

.footer {
  background: var(--navy);
  padding: 24px 0;
  text-align: center;
  font-size: 0.8rem;
  color: #93a1b3;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.footer p {
  margin: 0;
}

@media (max-width: 600px) {
  .hero-inner {
    flex-direction: column;
    text-align: center;
  }
  .hero-text {
    text-align: center;
  }
  .avatar {
    margin: 0 auto;
  }
  .hero-nav {
    justify-content: center;
  }

  /* On narrow screens the tile grid only has 2 columns, so the usual
     220px pop-out (with -35px side margins) overshoots the edge of the
     viewport for the right-hand column and causes horizontal scroll.
     Keep the expanded tile within its own column instead. */
  .cert-tile:not(.cert-tile-static):focus,
  .cert-tile:not(.cert-tile-static):focus-within,
  .cert-tile.is-tapped:not(.cert-tile-static) {
    width: auto;
    margin-left: 0;
    margin-right: 0;
  }
}

@media (max-width: 480px) {
  .hero { padding: 50px 0 30px; }
  .hero h1 { font-size: 2.1rem; }
  .avatar { width: 145px; height: 145px; }
  .section { padding: 40px 0; }
}
