/* If you need to borrow something from below, that's fine */
.extra a {
  background: #ccc linear-gradient(45deg, rgba(255,220,220,1) 0%, rgba(219,255,196,1) 50%, rgba(212,216,255,1) 100%);
  color: #000;
  padding: 0.5ch;
  border-radius: 0.5ch;
  text-decoration: none;
  border: 3px outset #000;
  word-break: none;
  white-space: nowrap;
  float: right;
}

.extra a:active {
  border: 3px inset #000;
}

body {
  margin: 0px;
  font-size: 12pt;
  font-family: sans-serif;
  background-color: #f8f8ee;
}

.rightbox {
  float: right;
  display: block;
  max-width: 40ch;
  clear: both;
}

.sticker {
  ruby-position: under;
}
.sticker rt {
  background-color: #ff08;
  font-size: 8pt;
}
header {
  background-color: #acae89;
  color: #fff;
  border-bottom: 1px solid #888;
}

h1, h2 {
  font-weight: normal;
}

header nav a {
  text-decoration: none;
  color: #000;

  margin-right: 1ch;
  padding: .5ch;
  display: inline-block;
}

header nav a:hover, header nav a:focus {
  background: #2f4858;
  color: #fff !important;
}

.form {
  max-width: 60ch;
  padding: 1ch;
  margin: auto;
}

.form {
  background-color: #fff;
}

.form h1 {
  color: #fff;
  background-color: #2f4858;
  font-size: medium;
  font-family: serif;
  padding: .5ch .5ch .5ch .5ch;
  margin-top: unset;
  margin-left: unset;

  font-family: 'Trebuchet', 'Noto Sans', sans-serif;

  text-decoration: none;
}

.form input[type="submit"] {
  float: right;
}

.form input[type="text"], .form select, .form textarea {
  width: 80%;
}

table > * {
  vertical-align: baseline;
  text-align: left;
}

thead th {
  font-weight: normal;
  font-size: 14pt;
}

footer td, footer th {
  padding-bottom: 8px;
  padding-right: 8px;
}

article {
  max-width: 160ch;
  margin-left: auto;
  margin-right: auto;
}

ul.semantic-results:empty {
  display: none;
}
ul.semantic-results {
  list-style: none;
  padding: 0px;
}
ul.semantic-results li {
  padding-left: 0px;
}
ul.semantic-results a {
  color: #c00;
}

.cards {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: flex-start;
  padding-left: 1ch;
  gap: 1ch;
}

.cards.big .card { flex-grow: 1 }
.cards.big { padding-right: 1ch; }

.w3m-helper {
    display: none;
}

.ms-rank-1 > .url, .ms-rank-1 > h2 { filter: grayscale(0%); }
.ms-rank-2 > .url, .ms-rank-2 > h2 { filter: grayscale(5%); }
.ms-rank-3 > .url, .ms-rank-3 > h2  { filter: grayscale(15%); }
.ms-rank-4 > .url, .ms-rank-4 > h2  { filter: grayscale(20%); }
.ms-rank-5 > .url, .ms-rank-5 > h2  { filter: grayscale(30%); }
.ms-rank-10 > .url, .ms-rank-10 > h2 { filter: grayscale(60%); }

.positions {
  box-shadow: 0px 0px 2px #888;
  background-color: #e4e4e4;
  padding: 2px;
  margin-right: -1ch;
  margin-left: 1ch;
}
.big .card {
  min-width: 40ch;
}

.card .info {
  flex-grow: 1;
  padding-left: 1ch;
  padding-right: 1ch;
  line-height: 1.6;
}
.card {
  flex-basis: 20ch;
  border: 2px #ccc;
  background-color: #fff;
  min-width: 30ch;
  display: flex;
  flex-direction: column;
  margin-left: 2px;
  margin-right: 2px;
  margin-bottom: 8px;
  border-left: 1px solid #ecb;
  border-top: 1px solid #ecb;
  box-shadow: #0008 0 0 5px;
}

.card h2 a {
  display: block !important;
}

.card img {
  width: 30ch;
  height: 22.5ch; /* 4:3 aspect ratio, card width = 30, height = 30*3/4 */
}
.card a:focus img  {
  filter: sepia(100%);
  box-shadow: #444 0px 0px 20px;
}


.card a:focus:not(.nofocus) {
  background-color: black;
  color: white;
}

.problems ul {
  flex-grow: 1;
  margin-left: -1em;
}

.card .description {
  padding-left: 1ch;
  padding-right: 1ch;
  flex-grow: 1;
  overflow: auto;
  -webkit-hyphens: auto;
  -moz-hyphens: auto;
  -ms-hyphens: auto;
  hyphens: auto;
}

.card h2 {
  color: #fff;
  background-color: #2f4858;
  font-size: medium;
  font-family: serif;
  padding: .5ch .5ch .5ch .5ch;
  margin: 0px 0px 0px 0px;

  font-family: 'Trebuchet', 'Noto Sans', sans-serif;

  text-decoration: none;
  border-bottom-right-radius: 2ch;
}

.card h2 a {
  color: #fff;
  text-decoration: none;
}

.problems h2, .info h2 {
  background-color: #482f58;
}

.browse-result {
  background-color: #eee;
}
.semantic h2, .browse-result .h2, .definition h2 {
  background-color: #48582f;
}

.search-result .url a {
  font-family: monospace;
  margin: 1ch;
  font-size: 8pt;
  background-color: #3F5F6F;
  display: block;
  margin: 0px;
  padding: 1ch;
  word-break: break-all;

  color: #fff;
}
.search-result .url a:visited {
  color: #FCC;
}
.card .utils {
  display: flex;
  font-size: 10pt;

  padding: 1ch;
  background-color: #eee;
}

.card .utils > * {
  margin-right: 1ch;
  margin-left: 1ch;
}

.card .utils a {
  color: #000;
}

.card.definition {
    min-height: 10ch;
}

.card.definition .description {
  padding: 2ch;
  font-size: 12pt;
}

.search-result .meta {
  flex-grow: 2;
  text-align: right;
}
.search-result .meta > * {
  padding-left: 4px;
}

.search-box {
    display: flex;
    flex-direction: row;
    background-color: #fff;
    margin-bottom: 4ch;
    box-shadow: #ccc 4px 4px 5px;
}

.search-box h1 {
  color: #fff;
  background-color: #2f4858;
  font-size: medium;
  font-family: serif;
  padding: .5ch .5ch .5ch .5ch;
  margin: 0px 0px 0px 0px;
  border: 2px groove;
  max-width: 100%;
  font-size: 16pt;
}

.search-box .input {
  flex-grow: 2;
  padding: .5ch;
}


select {
  color: #444;
  background-color: #fff;
  border: 1px solid #444;
  border-radius: 5px;
}

.search-box .settings {
  padding: .5ch;
}

.search-box .extra {
  padding: 1ch;
}

.search-box .input {
  display: flex;
  gap: .5ch;
}

.search-box input[name="query"] {
  flex-grow: 2;
  padding: .5ch;
  font-size: 12pt;
  font-family:  'fixedsys', monospace, serif;

  border: 2px inset #000;
  background: #fff;
  color: #444;
}

.search-box input[name="query"]:focus {
  color: #000;
}

.search-box input[type="submit"] {
  padding: .5ch;
  min-width: 5ch;
  font-size: 12pt;
  font-family:  'fixedsys', monospace, serif;
  border: 2px groove #ccc;
  background-color: #eee;
}

.search-box .settings > * {
  margin-top: .5ch;
}

footer {
  clear: both;
  padding: 2ch;
  margin: 16ch 0px 0px 0px;
  background: #e2e2c2;
  border-top: 1px solid #acae89;
  box-shadow: 5px 0px 5px #acae89;

  font-size: 12pt;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: flex-start;
}

footer h2 {
  font-size: 14pt;
  border-bottom: 1px solid #888;
  width: 80%;
}

footer > section {
  line-height: 1.5;
  background-color: #f8f8ee;
  flex-basis: 40ch;

  flex-grow: 1.1;

  border-left: 1px solid #000;
  padding-left: 1ch;
  padding-right: 1ch;
  box-shadow: -1px -1px 5px #000;
  margin-left: 1ch;
  padding-bottom: 1ch;
}

footer > section {
  margin-bottom: 1ch;
}

a.underline {
    text-decoration: underline !important;
}


.suggestions {
  background-color: #fff;
  padding: .5ch;
  margin-top: 3.2ch;
  position: absolute;
  display: inline-block;
  width: 300px;
  border-left: 1px solid #ccc;
  border-top: 1px solid #ccc;
  box-shadow: 5px 5px 5px #888;
  z-index: 10;
}

.suggestions a {
  display: block;
  color: #000;
  font-size: 12pt;
  font-family: 'fixedsys', monospace, serif;
  text-decoration: none;
  outline: none;
}

.suggestions a:focus {
  display: block;
  background-color: #000;
  color: #eee;
}
.query-samples dd {
  margin-top: .5ch;
  margin-bottom: .5ch;
}
.query-samples sample {
  font-family: monospace;
  color: #444;
}
.query-samples dt {
  font-family: monospace;

  display: inline-block;
  box-shadow: -2px -2px 5px #444;
  margin-bottom: .5ch;
  margin-top: .5ch;
  background-color: #eee;
  padding: .25ch;
}

@media only screen and (max-device-width: 1024px)  {
  .rightbox { width: 30ch !important; }
  .card {
    margin-right: 2ch;
  }
  .card .utils a {
    padding: 1ch;
  }

  .cards {
    justify-content: center;
  }

  .suggestions {
    display: none;
  }
}

@media only screen and (max-device-width: 800px) {
  .rightbox { display: none; }
  .search-box {
    flex-direction: column;
  }
  header nav a {
    padding: 1ch !important;
  }

  .card {
    flex-basis: 40ch !important;
    max-width: unset;
    margin-bottom: 2ch;
    margin-right: unset;
  }

  .card img {
    width: 100%;
    height: 100%;
  }

  .cards {
    padding-left: unset;
    padding-right: 5px;
  }


}

/* https://www.youtube.com/watch?v=v0nmHymgM7Y */
@media (prefers-color-scheme: dark) {
  .extra a {
    background: #000 linear-gradient(45deg, rgba(135,93,93,1) 0%, rgba(106,135,87,1) 50%, rgba(76,83,118,1) 100%);
    font-weight: bold;
    color: #fff;
    border: 3px outset #000;
  }
  .positions {
    box-shadow: 0px 0px 2px #222;
    background-color: #222;
    padding: 2px;
    color: #fff;

  }

  a {
    color: #acf;
  }
  .card {
    background-color: #222;
    color: #aaa;
    box-shadow: #0008 0 0 5px;
    border: none;
  }
  .card .utils {
    background-color: #000;
    color: #fff;
  }
  .card .utils a {
    color: #acf;
  }
  header {
    background-color: #000;
  }
  footer {
    background-color: #000;
    color: #fff;
    box-shadow: 5px 0px 5px #000;
    border-top: 1px solid #888;
  }
  body {
    background-color: #444;
  }
  header nav a {
    color: #eee;
  }
  .search-box {
    background-color: #222;
    box-shadow: #0008 0 0 5px;
  }
  .search-box h1 {
    background-color: unset;
    border: none;
  }

  .search-box input[name="query"] {
    background-color: #000 !important;
    color: #aaa;
    border: 1px solid #888;
  }
  .search-box input[name="query"]:focus {
    color: #eee;
  }
  .search-box input[type="submit"] {
    background-color: #000 !important;
    color: #fff;
    border: 1px solid #888;
  }
  .card img {
    /* White images turn into an unpleasant death laser if you put them in an otherwise dark page */
    filter: brightness(80%) saturate(140%);
  }
  input {
    color: #fff;
  }
  .card a:focus img  {
    filter: brightness(100%);
    box-shadow: #ccca 0px 0px 50px;
  }

  .card a:focus:not(.nofocus) {
    background-color: white;
    color: black;
  }

  select {
    color: #fff;
    background-color: #000;
    border: 1px solid #ccc;
    border-radius: 5px;
  }

  .suggestions {
    background-color: #000;
    border: 1px solid #444;
    box-shadow: 2px 2px 5px #000;
  }
  .suggestions a {
    color: #fff;
  }
  .suggestions a:focus {
    background-color: #2f4858;
  }

  footer {
    background: #000;
    border-top: 1px solid #444;
    box-shadow: 5px 0px 5px #000;
  }

  footer h2 {
    border-bottom: 1px solid #888;
  }

  footer > section {
    background-color: #222;
    border-left: 1px solid #444;
    box-shadow: -1px -1px 5px #444;
  }

  .form {
    background-color: #000;
    color: #eee;
  }

  .form h1 {
    color: #fff;
    background-color: #2f4858;
  }

  .form input[type="submit"] {
    background-color: #222;
    color: #fff;
  }

  .form input[type="text"], .form select, .form textarea {
    background-color: #222;
    color: #fff;
  }
  .query-samples dt {
    color :#000;
  }
  .query-samples dd sample {
    color: #ee8 !important;
  }

}

@media only print {
  article {
    margin-left: 4ch !important;
    margin-right: 4ch !important;
  }
  .rightbox { display: none !important; }
  .cards {
    display: block !important;
  }
  .card h2 {
    font-size: 16pt;
    font-family: serif !important;
  }
  .card .description {
    font-family: serif;
    text-align: justify;
    word-break: all;
  }
  .card {
    border-left: none !important;
    border-right: none !important;
    border-top: none !important;
    border-bottom: 3px double #000 !important;
    box-shadow: none !important;
  }
  .card > .utils {
    display: none !important;
  }
  footer {
    display: none;
  }
  nav {
    display: none !important;
    box-shadow: none !important;
  }
  .search-box {
    display: none !important;
    box-shadow: none !important;
  }
}