/*-------------------------------*/
/* start: document level styles  */
/*-------------------------------*/

/* 
 * The html and body settings are important to make the footer 
 * stick to the bottom when the body content is less than the 
 * viewport height. See 
 * https://developer.mozilla.org/en-US/docs/Web/CSS/Layout_cookbook/Sticky_footers
 */

* {
    box-sizing: border-box;
}

html {
    height: 100%;
}

body {
    --body-padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    margin: 0 auto;
    padding: var(--body-padding);
    background-color: #f8f9fa;
    min-height: 100vh;
    display: grid;
    grid-template-rows: auto 1fr auto;
    --max-body-width: 960px;
    max-width: var(--max-body-width);
}

.warning {
    color: orange !important;
    font-size: 0.8rem;
}

pre {
    font-size: 0.5rem;
    display: inline-block;
    padding: 0.5rem;
}

/*-------------------------------*/
/* end: document level styles    */
/*-------------------------------*/

/*-------------------------------*/
/* header styles                 */
/*-------------------------------*/
header {
    text-align: center;
}
header img {
    cursor: pointer;
    width: 40px;
}
header nav {
    text-align: center;
    visibility: hidden;
    margin-top: -1.25rem;
}
header nav ul {
    /* left padding ensures that "about" is aligned with the logo above */
    padding-left: 17px;
}
header nav ul li {
    display: inline;
    list-style: none;
    font-family: sans-serif;
    margin-right: 1rem;
}

/* 
 * https://gradienty.codes/animations
 * animation fade-in-normal
 */
 @keyframes fade-in-normal {0% { opacity: 0; } 100% { opacity: 1;} }

 .fade-in-normal { 
     visibility: visible;
     animation: fade-in-normal 1s ease-in 0s 1 normal none; 
 }

/*-------------------------------*/
/* end: header styles            */
/*-------------------------------*/

/*-------------------------------*/
/* start: footer styles          */
/*-------------------------------*/
footer {
    text-align: center;
    font-family: sans-serif;
    font-size: .75rem;
    margin-bottom: -1rem;
}

/*-------------------------------*/
/* end: footer styles            */
/*-------------------------------*/

/*-------------------------------*/
/* start: form styles            */
/*-------------------------------*/
form {
    /* 
     * forms don't have a default width or height, and 
     * instead, they take the dimensions of their content.
     * The var --form-width here is used to set the width 
     * of the content input field and div.
     */
    --form-width: 100%;
    --reset-button-width: 30px;
    --go-button-width: 50px;
    --buttons-width: calc(var(--reset-button-width) + var(--go-button-width));
    --button-height: 36px;
    --border-radius: 5px;
    margin-bottom: 20px;
    position: relative;
}

.input-container {
    position: relative;
    display: inline-block;
    width: calc(100% - var(--buttons-width) - 11px);
    vertical-align: top;
}

.editable-input {
    width: 100%;
    padding: 1px 10px;
    min-height: calc(var(--button-height) + 4px);
    border: 2px solid #e1e8ed;
    border-radius: 8px;
    font-size: 1rem;
    line-height: 2;
    background-color: #fff;
    transition: border-color 0.2s ease;
    outline: none;
    /* overflow-y: auto; */
}

.editable-input:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.editable-input:empty::before {
    content: attr(data-placeholder);
    color: #95a5a6;
    font-style: italic;
}

.placeholder-clickable {
    cursor: pointer;
    text-decoration: underline;
    color: #3498db;
}

.placeholder-clickable:hover {
    color: #2980b9;
}

.placeholder-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 12px;
    color: #95a5a6;
    pointer-events: none;
    align-items: center;
    z-index: 1;
}

.placeholder-overlay .placeholder-clickable {
    pointer-events: all;
}

.placeholder-overlay.hidden {
    display: none;
}

.suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e1e8ed;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.suggestion-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f8f9fa;
    transition: background-color 0.2s ease;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover,
.suggestion-item.highlighted {
    background-color: #3498db;
    color: white;
}

.species-name {
    font-weight: 400;
    font-size: 12px;
    display: block;
}

.species-type {
    font-size: 12px;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.hint {
    margin-top: 12px;
    padding: 12px;
    background-color: #e8f6f3;
    border-left: 4px solid #1abc9c;
    border-radius: 4px;
    font-size: 14px;
    color: #16a085;
}

#q span:not(.hl) {
    color: lightgrey;
}
span.stopword {
    color: lightgrey;
}
span.hl,
span.res {
    color: green;
}

/*-------------------------------*/
/* start: button styles          */
/*-------------------------------*/

#buttons {
    border: 1px solid lightgrey;
    border-radius: var(--border-radius);
    display: inline-block;
    vertical-align: top;
    margin-top: 0;
    cursor: pointer;
    position: relative;
}
#reset,
#go {
    border: 1px solid lightslategrey;
    background-color: lightgrey;
}
#reset {
    width: var(--reset-button-width);
    height: var(--button-height);
    border-radius: var(--border-radius) 0 0 var(--border-radius);
}
#reset:hover {
    background-color: red;
    color: white;
}
#go {
    border-radius: 0 var(--border-radius) var(--border-radius) 0;
    width: var(--go-button-width);
    height: var(--button-height);
}
#go:hover {
    background-color: lightgreen;
}

/* https://dev.to/dcodeyt/create-a-button-with-a-loading-spinner-in-html-css-1c0h */
@keyframes button-loading-spinner {
    from { transform: rotate(0turn); }
    to { transform: rotate(1turn); }
}
.button--loading::after {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    top: 0;
    left: 33px;
    right: 0;
    bottom: 0;
    margin: auto;
    background-color: lightgreen;
    border: 4px solid transparent;
    border-top-color: darkgreen;
    border-radius: 50%;
    animation: button-loading-spinner 1s ease infinite;
    opacity: 0.75;
}

/*-------------------------------*/
/* end: button styles            */
/*-------------------------------*/

/*-------------------------------*/
/* start: examples styles        */
/*-------------------------------*/
#example-queries {
    font-family: sans-serif;
    font-size: 10pt;
    /* width: 288px; */
    padding: 1rem;
}

.is-hidden {
    transition: 0.6s;
    opacity: 0;
    visibility: hidden;
    display: none;
}
.is-visible {
    transition: 0.6s;
    opacity: 1;
    visibility: visible;
    display: block;
}

#example-queries .speciesName {
    text-decoration: underline wavy green;
}

#dropdown {
    padding: 0;
}
#dropdown li {
    padding: 5px;
    margin: 0;
    cursor: pointer;
    list-style: none;
    transition: opacity 0.5s ease-in-out 0.1s;
    border-bottom: 1px dotted black;
}
#dropdown li:hover {
    color: blue;
    text-decoration: underline;
}
/*-------------------------------*/
/* end: examples styles          */
/*-------------------------------*/

/*-------------------------------*/
/* start: responses styles       */
/*-------------------------------*/
#response,
#answer {
    margin: 1rem 0;
    font-family: Georgia, 'Times New Roman', Times, serif;
    line-height: 1.6;
}

@keyframes typing { from { width: 0; } to { width: 8ch; } }
@keyframes blink { 50% { opacity: 0; } }
.typewriter {
    overflow: hidden;
    white-space: nowrap;
    animation: typing 800ms steps(8, end);
  
    &::after {
      content: "";
      border-left: 2px solid #000;
      animation: blink 1s step-end infinite;
    }
}
/*-------------------------------*/
/* end: responses styles         */
/*-------------------------------*/

/*-------------------------------*/
/* start: columns styles         */
/*-------------------------------*/

/*
◀─────────────────────a = 928─────────────────────▶
┌─────────────┐   ┌─────────────┐   ┌─────────────┐
│col          │   │col          │   │col          │
│┌───────────┐│   │             │   │             │
││fig         ││   │             │   │             │
││┌─────────┐││   │a - ((cc - 1)│   │             │
│││img      │││   │    * b)     │   │             │
│││         │││   │◀───────────▶│   │             │
│││         │││   │             │   │             │
│││         │││   │             │   │             │
│││         │││   │             │   │             │
│││         │││   │             │   │             │
│││         │││   │             │   │             │
││└─────────┘││◀─▶│             │◀─▶│             │
│└───────────┘│ │ │             │ │ │             │
└─────────────┘ │ └─────────────┘ │ └─────────────┘
                │                 │                
                └───▶ b = 30  ◀───┘                
                                                   
                 cc = column count                 
*/

.columns {
    --container-width: 280px;
    --column-count: 1;
    --column-gap: 30px;
    --column-width: calc( 
        var(--container-width) - (
            (var(--column-count) - 1) * var(--column-gap)
        )
    );
    width: var(--column-width);
    max-width: var(--column-width);
    margin: 0 auto;

    column-count: var(--column-count);
    column-gap: var(--column-gap);

    page-break-inside: avoid;
    break-inside: avoid;
}

figure {
    position: relative;
    height: auto;
    margin: 0 0 10px 0;
    padding: 1rem;
    opacity: 1;
    text-align: center;
    font-family: sans-serif;
    font-size: 12px;
    border: 1px solid #ccc;
    box-shadow: 1px 1px 10px 1px #dbd9d5;
    
    /* avoid figures splitting across columns */
    /* see https://stackoverflow.com/a/17415553/183692 */
    overflow: hidden; /* fix for Firefox */
    break-inside: avoid;
}
figure img.lazyloaded {
    width: 100%;
}
figcaption {
    font-family: helvetica,sans-serif;
    font-size: 10pt;
    text-align: left;
    cursor: pointer;
    line-height: 1.1rem;
}
figcaption div.closed {
    height: 0;
}
figcaption div.figTitle {
    font-weight: 800;
}
figcaption div.open {
    height: 100%;
}
figcaption h3 {
    line-height: 1.25rem;
}
figcaption details {
    border-radius: 4px;
    padding: 0.5em 0.5em 0;
}
figcaption details summary {
    font-weight: bold;
    margin: -0.5em -0.5em 0;
    padding: 0.5em;

    /******************************/
    /* limit length of summary    */
    /* https://btxx.org/posts/te/ */
    /******************************/
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
figcaption details[open] {
    padding: 0.5em;
    overflow: auto;
}
figcaption details[open] summary {
    border-bottom: 1px solid #aaa;
    margin-bottom: 0.5em;
    overflow: unset;
    white-space: unset;
}
#source {
    padding: 1rem;
    font-size: 0.8rem;
}
#source ol {
    padding: 0 1rem;
}
#source a {
    /* Break huge URLs so they don't overflow */
    /* https://stackoverflow.com/a/52371146/183692 */
    word-break: break-all;
}

/* Larger than phablet */
@media (min-width: 550px) {
    pre {
        font-size: 8pt;
    }
    header {
        height: 7rem;
        padding-top: 1rem;
    }
    header img {
        width: 50px;
    }
    .warning {
        font-size: 1rem;
    }
    #q,
    #buttons {
        display: inline-block;
    }
    #buttons {
        margin-top: 0;
    }
    .columns {
        --column-count: 2 !important;
    }
    figure.figure-250 { 
        margin: 0 auto 20px auto;
    }
}

/* Larger than tablet */
@media (min-width: 768px) {
    .columns {
        --column-count: 3 !important;
        --image-size: 238px;
    }
}