/* ==========================================================================
   THE INTERNET TOOLBOX — style.css
   Design tokens: pegboard workshop aesthetic
   ========================================================================== */

/* ---------- Design tokens ---------- */
:root{
  --bg: #12151C;
  --surface: #1B1F29;
  --surface-2: #21273380;
  --text: #ECEAE3;
  --muted: #9098AC;
  --border: rgba(255,255,255,0.09);
  --accent: #FFB100;
  --accent-ink: #12151C;
  --teal: #3ED7C4;
  --pink: #FF6B8A;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --shadow-soft: 0 10px 30px -12px rgba(0,0,0,0.5);
  --shadow-lift: 0 18px 40px -14px rgba(0,0,0,0.6);
  --font-display: "Space Grotesk", "Segoe UI", sans-serif;
  --font-body: "Inter", "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
  --container-w: 1240px;
  --header-h: 68px;
  color-scheme: dark;
}

[data-theme="light"]{
  --bg: #F7F5F0;
  --surface: #FFFFFF;
  --surface-2: #FFFFFFcc;
  --text: #171A21;
  --muted: #666E7E;
  --border: rgba(18,21,28,0.09);
  --accent-ink: #12151C;
  --shadow-soft: 0 10px 30px -14px rgba(23,26,33,0.18);
  --shadow-lift: 0 18px 40px -16px rgba(23,26,33,0.22);
  color-scheme: light;
}

/* ---------- Reset ---------- */
*, *::before, *::after{ box-sizing: border-box; }
html{
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}
body{
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  overflow-x: hidden;
  transition: background .35s ease, color .35s ease;
}
img{ max-width: 100%; height: auto; display: block; }
a{ color: inherit; text-decoration: none; }
button{ font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
ul{ list-style: none; margin: 0; padding: 0; }
h1,h2,h3,h4,p{ margin: 0; }
input{ font: inherit; color: inherit; }
svg{ display: block; flex-shrink: 0; }

@media (prefers-reduced-motion: reduce){
  *{ animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

:focus-visible{
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.container{
  width: 100%;
  max-width: var(--container-w);
  margin-inline: auto;
  padding-inline: 20px;
}

.skip-link{
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 10px 16px;
  z-index: 999;
  border-radius: 0 0 8px 0;
  font-weight: 600;
}
.skip-link:focus{ left: 0; }

/* ---------- Typography scale ---------- */
h1, h2, h3, .brand-text, .stat-number{ font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; }
.eyebrow{
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}
h2{ font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.2rem); }

/* ---------- Header ---------- */
.site-header{
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  display: flex;
  align-items: center;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--border);
}
.header-inner{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: 100%;
}
.brand{
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.brand-mark{ flex-shrink: 0; display: flex; }
.brand-text{
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-text strong{ color: var(--accent); font-weight: 700; }

.main-nav{
  display: none;
  align-items: center;
  gap: 28px;
  font-size: 0.92rem;
  font-weight: 500;
}
.main-nav a{
  color: var(--muted);
  transition: color .2s ease;
  position: relative;
  padding: 4px 0;
}
.main-nav a:hover{ color: var(--text); }
.main-nav a::after{
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -2px;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transition: transform .25s ease;
}
.main-nav a:hover::after{ transform: scaleX(1); }

.header-actions{ display: flex; align-items: center; gap: 8px; }

.icon-btn{
  width: 40px; height: 40px;
  min-height: 44px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--border);
  transition: background .2s ease, transform .2s ease;
}
.icon-btn:hover{ background: var(--surface); transform: rotate(-8deg); }

.hamburger{
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 44px; height: 44px;
  border-radius: 10px;
}
.hamburger span{
  width: 20px; height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform .3s ease, opacity .3s ease;
}
.hamburger[aria-expanded="true"] span:nth-child(1){ transform: translateY(7px) rotate(45deg); }
.hamburger[aria-expanded="true"] span:nth-child(2){ opacity: 0; }
.hamburger[aria-expanded="true"] span:nth-child(3){ transform: translateY(-7px) rotate(-45deg); }

/* Mobile nav drawer */
@media (max-width: 768px){
  .main-nav{
    position: fixed;
    inset: var(--header-h) 0 0 0;
    background: var(--bg);
    flex-direction: column;
    align-items: flex-start;
    padding: 28px 24px;
    gap: 4px;
    transform: translateX(100%);
    transition: transform .32s ease;
    overflow-y: auto;
  }
  .main-nav.is-open{ display: flex; transform: translateX(0); }
  .main-nav a{
    width: 100%;
    padding: 14px 4px;
    font-size: 1.05rem;
    border-bottom: 1px solid var(--border);
    min-height: 44px;
    display: flex;
    align-items: center;
  }
}
@media (min-width: 769px){
  .main-nav{ display: flex; }
  .hamburger{ display: none; }
}

/* ---------- Buttons ---------- */
.btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 22px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.94rem;
  white-space: nowrap;
  transition: transform .2s ease, box-shadow .2s ease, background .2s ease;
}
.btn-primary{
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 10px 24px -10px rgba(255,177,0,0.55);
}
.btn-primary:hover{ transform: translateY(-2px); box-shadow: 0 16px 30px -12px rgba(255,177,0,0.6); }
.btn-primary svg{ transition: transform .2s ease; }
.btn-primary:hover svg{ transform: translateX(3px); }

.btn-ghost{
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-ghost:hover{ background: var(--surface); }

.btn-visit{
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  width: 100%;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.9rem;
  gap: 6px;
  text-decoration: none;
}
.btn-visit:hover{ background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* ---------- Hero ---------- */
.hero{
  position: relative;
  padding: 56px 0 44px;
  overflow: hidden;
}
.pegboard{
  position: absolute;
  inset: -40px 0 auto 0;
  height: 480px;
  background-image: radial-gradient(circle, color-mix(in srgb, var(--accent) 35%, transparent) 1.6px, transparent 1.6px);
  background-size: 26px 26px;
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 0%, black 40%, transparent 85%);
  mask-image: radial-gradient(ellipse 70% 60% at 50% 0%, black 40%, transparent 85%);
  opacity: 0.5;
  pointer-events: none;
}
.hero-inner{ position: relative; z-index: 1; max-width: 760px; }
.hero-title{
  font-size: clamp(2rem, 1.35rem + 3.2vw, 3.4rem);
  line-height: 1.08;
  letter-spacing: -0.02em;
}
.hero-title .highlight{ color: var(--accent); }
.hero-sub{
  margin-top: 20px;
  max-width: 52ch;
  color: var(--muted);
  font-size: clamp(0.98rem, 0.9rem + 0.3vw, 1.1rem);
}
.hero-cta{
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 30px;
}
.hero-stats{
  display: flex;
  flex-wrap: wrap;
  gap: 28px;
  margin-top: 44px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.hero-stats div{ display: flex; flex-direction: column; gap: 2px; }
.hero-stats strong{ font-family: var(--font-display); font-size: 1.4rem; }
.hero-stats span{ font-size: 0.82rem; color: var(--muted); }

/* ---------- Search ---------- */
.search-section{ padding: 0 0 40px; }
.search-drawer{
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 4px 16px;
  min-height: 56px;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.15), var(--shadow-soft);
}
.search-icon{ color: var(--muted); }
.search-drawer input{
  flex: 1;
  min-width: 0;
  background: none;
  border: none;
  height: 44px;
  color: var(--text);
  font-size: 1rem;
}
.search-drawer input::placeholder{ color: var(--muted); }
.search-drawer input:focus{ outline: none; }
.search-kbd{
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 8px;
  display: none;
}
@media (min-width: 481px){ .search-kbd{ display: inline-block; } }

.quick-filters{
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
.chip{
  min-height: 38px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--muted);
  transition: all .2s ease;
}
.chip:hover{ color: var(--text); border-color: var(--accent); }
.chip.is-active{ background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* ---------- Sections ---------- */
.section{ padding: 56px 0; }
.section-alt{ background: color-mix(in srgb, var(--surface) 45%, transparent); }
.section-head{
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 30px;
}
.section-desc{ color: var(--muted); max-width: 60ch; font-size: 0.96rem; }

/* ---------- Card grid ---------- */
.grid{ display: grid; gap: 18px; }
.card-grid{ grid-template-columns: 1fr; }

@media (min-width: 481px){
  .card-grid{ grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 769px){
  .card-grid{ grid-template-columns: repeat(3, 1fr); gap: 20px; }
}
@media (min-width: 1441px){
  .card-grid{ grid-template-columns: repeat(4, 1fr); }
}

/* ---------- Tool card ---------- */
.tool-card{
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-soft);
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
  min-width: 0;
}
.tool-card:hover{
  transform: translateY(-5px);
  box-shadow: var(--shadow-lift);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}
.card-top{ display: flex; align-items: flex-start; gap: 12px; }
.card-logo{
  width: 46px; height: 46px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  color: #12151C;
  position: relative;
  overflow: hidden;
}
.card-logo-fallback{ position: relative; z-index: 1; }
.card-logo-img{
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  padding: 9px;
  box-sizing: border-box;
  background: #ffffff;
  z-index: 2;
}
.card-heading{ min-width: 0; flex: 1; }
.card-heading h3{
  font-size: 1.02rem;
  font-weight: 600;
  overflow-wrap: break-word;
}
.card-category{
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.fav-btn{
  margin-left: auto;
  width: 36px; height: 36px;
  min-height: 36px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  transition: color .2s ease, transform .15s ease;
  flex-shrink: 0;
}
.fav-btn:hover{ transform: scale(1.12); }
.fav-btn svg{ transition: fill .2s ease, stroke .2s ease; }
.fav-btn.is-fav{ color: var(--pink); }
.fav-btn.is-fav svg{ fill: var(--pink); stroke: var(--pink); }

.card-desc{
  color: var(--muted);
  font-size: 0.89rem;
  line-height: 1.55;
  overflow-wrap: break-word;
  flex: 1;
}
.card-meta{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.badge{
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
  letter-spacing: 0.03em;
}
.badge-Free{ background: color-mix(in srgb, var(--teal) 22%, transparent); color: var(--teal); }
.badge-Freemium{ background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent); }
.badge-Paid{ background: color-mix(in srgb, var(--pink) 22%, transparent); color: var(--pink); }

.rating{
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--muted);
}
.rating svg{ color: var(--accent); }

.card-new-flag, .card-featured-flag{
  position: absolute;
  top: -9px;
  left: 18px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  box-shadow: 0 4px 10px -4px rgba(0,0,0,0.4);
}
.card-featured-flag{ background: var(--teal); }

.empty-state{
  color: var(--muted);
  text-align: center;
  padding: 30px 0;
  font-size: 0.95rem;
}

/* ---------- Categories (hanging tag signature) ---------- */
.tag-grid{
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 22px 16px;
}
@media (min-width: 481px){ .tag-grid{ grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 769px){ .tag-grid{ grid-template-columns: repeat(5, 1fr); gap: 26px 18px; } }

.cat-tag{
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 26px 10px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  min-height: 110px;
  text-align: center;
  transition: transform .28s cubic-bezier(.2,.9,.3,1.3), border-color .2s ease, box-shadow .2s ease;
  transform-origin: top center;
}
.cat-tag::before{
  content: "";
  position: absolute;
  top: -7px;
  left: 50%;
  transform: translateX(-50%);
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--muted);
}
.cat-tag:hover{
  transform: rotate(-3deg) translateY(-4px);
  border-color: var(--accent);
  box-shadow: var(--shadow-lift);
}
.cat-tag:nth-child(even):hover{ transform: rotate(3deg) translateY(-4px); }
.cat-icon{ font-size: 1.5rem; }
.cat-name{ font-size: 0.86rem; font-weight: 600; }
.cat-count{ font-family: var(--font-mono); font-size: 0.7rem; color: var(--muted); }
.cat-tag.is-active{ border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }

/* ---------- CTA band ---------- */
.cta-band{
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 16%, var(--surface)), var(--surface));
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.cta-inner{
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: 640px;
}
.cta-inner p{ color: var(--muted); }

/* ---------- Footer ---------- */
.site-footer{
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 50px 0 20px;
}
.footer-grid{
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
}
@media (min-width: 481px){ .footer-grid{ grid-template-columns: 1fr 1fr; } }
@media (min-width: 769px){ .footer-grid{ grid-template-columns: 1.6fr 1fr 1fr 1fr; } }

.footer-brand p{ margin-top: 12px; color: var(--muted); font-size: 0.9rem; max-width: 34ch; }
.footer-col h3{ font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 14px; }
.footer-col ul{ display: flex; flex-direction: column; gap: 10px; }
.footer-col a{ font-size: 0.9rem; transition: color .2s ease; }
.footer-col a:hover{ color: var(--accent); }

.footer-bottom{
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

/* ---------- Back to top ---------- */
.back-to-top{
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 46px; height: 46px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-lift);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  z-index: 90;
}
.back-to-top.is-visible{ opacity: 1; transform: translateY(0); pointer-events: auto; }

/* ---------- Larger screens polish ---------- */
@media (min-width: 1025px){
  .container{ padding-inline: 32px; }
  .hero{ padding: 90px 0 60px; }
}
@media (min-width: 1441px){
  .container{ max-width: 1360px; }
}

/* Landscape phone tweak */
@media (max-width: 900px) and (orientation: landscape){
  .hero{ padding: 32px 0 28px; }
  .pegboard{ height: 260px; }
  .main-nav{ inset: var(--header-h) 0 0 0; }
}