/* http://meyerweb.com/eric/tools/css/reset/ 
   v2.0 | 20110126
   License: none (public domain)
*/

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed, 
figure, figcaption, footer, header, hgroup, 
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 100%;
  vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure, 
footer, header, hgroup, menu, nav, section {
  display: block;
}
body {
  /*line-height: 1;*/
}
ol, ul {
  list-style: none;
}
blockquote, q {
  quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
  content: '';
  content: none;
}
table {
  border-collapse: collapse;
  border-spacing: 0;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Make sure everything includes padding in width calculation */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  font-family: "IBM Plex Sans", sans-serif;
  font-weight: 300;
  font-style: normal;

  margin: 0;
  padding: 2rem;
  background: #ffffff;
  color: #000000;
  display: flex;
  flex-direction: column;
  align-items: center;

  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto 1.5rem auto;
  /*padding: 0 2rem;*/
  box-sizing: border-box;
  /*border: 1px solid red;*/
}

.header-left {
  display: flex;
}

input[type="search"] {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  outline: none;
  border: none;
  background: none;
  box-shadow: none;
  border-radius: 0;
  padding: 0;
  margin: 0;
  font-family: "IBM Plex Sans", sans-serif;
  font-weight: bold; /* ← MAKE TEXT BOLD HERE */
}

input[type="search"]::-webkit-search-decoration,
input[type="search"]::-webkit-search-cancel-button,
input[type="search"]::-webkit-search-results-button,
input[type="search"]::-webkit-search-results-decoration {
  display: none;
}

#search {

  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background: none;
  box-shadow: none;
  border-radius: 0;

  height: 2rem;
  padding: 15px;
  border: none;

  font-family: "IBM Plex Sans", sans-serif;
  font-size: 1.25rem;
  font-style: normal;
  font-weight: 300;
  line-height: normal;
}

#search:focus {
  outline: none;
  background: #ffffff;
  font-weight: 300;
}

.results {
  display: grid;
  grid-template-columns: repeat(4, 1fr); /* 4 equal columns */
  /*gap: 1rem;*/
  width: 100%;
  /*max-width: 1200px;*/
  margin: 0 auto;
/*  padding: 0 1rem;*/
  box-sizing: border-box;
  /*overflow-x: hidden; */
}

.card {
  width: 100%; /* full width of grid cell */
  height: 10rem;
  box-sizing: border-box;
  overflow: hidden;
  padding-top: 1rem;
  transition: background-color 0.1s ease;
  color: #F0DFFF;
}

.card-link .card:hover {
  background-color: #1A0B3B !important;
  color: #fff !important;
}

.card a {
  text-decoration: none;
  /*color: #fff;*/
  word-break: break-word;
}

.card p {
  font-size: 0.5rem;
}

.card-content {
  margin: 0.5rem 1rem 0.5rem 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 80%;  
  min-width: 0;
  gap: 0.2rem;
}

.card-url {
  font-size: 0.5rem;
  opacity: 1;
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: normal;  
  font-family: "IBM Plex Mono";
  font-weight: 300;
}

.card-title {
  font-size: 1rem;
  line-height: 1rem;
  /*color: #fff;*/
  word-wrap: break-word;
  overflow-wrap: break-word;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: normal;
}

.card-description {
  font-size: 0.5rem;
  max-height: 2rem;
  overflow: hidden;
}

.card-category {
  text-transform: uppercase;
  font-size: 0.5rem;
  opacity: 0.75;
}

.toggle-container {
  /*margin-bottom: 2rem;*/
  display: flex;
  align-items: center;
}

body.dark-mode {
  background-color: #121212;
  color: #e0e0e0;
}

body.dark-mode #search {
  background-color: #121212;
  color: #ffffff;
}

body.dark-mode .card a {
  color: #90caf9;
}

body.dark-mode .card {
/*  border: 1px solid #333;*/
}

#theme-toggle {
  margin-right: 0.5rem;
  transform: scale(1);
  cursor: pointer;
}

label[for="theme-toggle"] {
  cursor: pointer;
  font-size: 0.8rem;
  user-select: none;
}

.order {
  /*font-family: "IBM Plex Mono";*/
  font-weight: 200;
}

.card-link {
  display: block;
  width: 100%;
  text-decoration: none;
}

footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 1200px;
  margin: 3rem auto 0 auto;
  /*padding: 1rem 2rem;*/
  box-sizing: border-box;
  font-size: 0.5em;
  flex-shrink: 0; /* do not shrink? */
}

.results-count {
  font-size: 0.8rem;
  color: #666;
  margin-bottom: 0.75rem;
  width: 100%;
  padding: 0 1rem;
  box-sizing: border-box;
}

body.dark-mode .results-count {
  color: #aaa;
}

footer a {
  color: #000;
}

body.dark-mode footer a {
  color: #fff;
}

.card,
.card-title,
.card-url {
  word-break: break-word;       /* Breaks long words */
  overflow-wrap: anywhere;      /* Ensures wrapping in any context */
  min-width: 0;                 /* Prevents stretching */
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  width: 100%;
}

/* Tablets (portrait, < 1024px) — 3 columns */
@media (max-width: 1024px) {
  .results {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Phones (landscape, < 768px) — 2 columns */
@media (max-width: 768px) {
  .results {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Small screens (< 480px) — 1 column */
@media (max-width: 480px) {
  .results {
    grid-template-columns: 1fr;
  }
  #search {
    width: 90%;
  }
  .toggle-container {
    margin-right: 0.5rem;
  }
  .dark-mode-label {
    display: none;
  }
}

