/*
Author: COS10026 student team — replace with member names.
Purpose: RimbaKita Assignment 1 stylesheet, based on Lecture 4.
Enhancement references are listed beside their rules and on enhancement1.html.
*/

/* General */
* {
    box-sizing: border-box;
}
body {
    margin: 0;
    background-color: #f5f1e8;
    color: #222222;
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.5;
}
h1 {
    font: normal bold 2em/1.2 Arial, Helvetica, sans-serif;
}
h1, h2, h3, legend {
    color: #24513b;
}
a {
    color: #24513b;
}
a:hover {
    color: #111111;
}
a:focus, button:focus, input:focus, select:focus, textarea:focus,
summary:focus, .table-scroll:focus {
    outline: 2px solid #24513b;
    outline-offset: 3px;
}
main {
    padding: 2%;
}
section {
    margin-bottom: 28px;
}
p {
    max-width: 75em;
}
#introduction {
    border-bottom: 1px solid #777777;
}
img {
    max-width: 100%;
    height: auto;
}
figure {
    margin: 16px 0;
}
figure img {
    width: 360px;
}
figcaption {
    font-size: 0.9em;
}
dt {
    font-weight: bold;
}
dd {
    margin-bottom: 8px;
}
pre {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    padding: 12px;
    border: 1px solid #777777;
}

/* Header */
header {
    padding: 12px 2%;
    background-color: #ffffff;
}
/* Required homepage background graphic, beside rather than behind the text. */
.home-page header {
    background-image: url("../images/borneo-rainforest.jpg");
    background-repeat: no-repeat;
    background-position: right 16px top 16px;
    background-size: 180px auto;
}
.logo {
    width: 300px;
    max-width: 100%;
    height: auto;
}

/* Navigation: details provides a native, keyboard-operable required dropdown. */
.main-nav {
    padding: 8px 2%;
    background-color: #24513b;
}
.main-nav a, .main-nav summary {
    display: inline-block;
    padding: 8px;
    color: #ffffff;
}
.main-nav a:hover, .main-nav a:focus, .main-nav summary:focus {
    background-color: #dfe9df;
    color: #24513b;
}
a.current {
    font-weight: bold;
    text-decoration: underline;
}
.main-nav a.current {
    background-color: #dfe9df;
    color: #24513b;
}
.explore-menu {
    display: inline-block;
    position: relative;
}
.explore-menu summary {
    cursor: pointer;
    border: 1px solid #dfe9df;
}
.submenu {
    position: absolute;
    width: 180px;
    padding: 8px;
    background-color: #24513b;
    border: 1px solid #dfe9df;
    z-index: 1;
}
.submenu a {
    display: block;
}
.taxonomy-nav {
    padding: 8px 0;
    border-bottom: 1px solid #777777;
}

/* Explorer: the assessed aside floats right and occupies 30% of its parent. */
aside {
    width: 30%;
    float: right;
    margin: 0 0 16px 24px;
    padding: 16px;
    border: 2px solid #24513b;
}
.clear-section, footer {
    clear: both;
}
.plant-entry, .species-record, .observation {
    padding-bottom: 20px;
    margin-bottom: 24px;
    border-bottom: 1px solid #777777;
}

/* Forms: no backend is provided; method=dialog validates without sending data. */
dialog {
    position: static;
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    background-color: #f5f1e8;
    color: #222222;
}
form {
    width: 100%;
    max-width: 760px;
}
fieldset {
    min-width: 0;
    padding: 16px;
    margin: 16px 0;
    border: 1px solid #24513b;
}
label, small {
    display: block;
    margin: 6px 0;
}
.form-field {
    margin-bottom: 16px;
}
input, select, textarea {
    width: 100%;
    max-width: 440px;
    padding: 8px;
    border: 1px solid #777777;
    font: inherit;
}
.choice {
    width: auto;
}
button {
    padding: 8px 16px;
    margin: 6px 0;
    border: 1px solid #24513b;
    background-color: #24513b;
    color: #ffffff;
    font: inherit;
    cursor: pointer;
}
button:hover {
    background-color: #111111;
}

/* Tables */
.table-scroll {
    overflow-x: auto;
}
table {
    width: 100%;
    border-collapse: collapse;
}
caption {
    padding: 8px;
    font-weight: bold;
    text-align: left;
}
th, td {
    padding: 10px;
    border: 1px solid #777777;
    text-align: left;
}
th {
    background-color: #dfe9df;
}

/* Individual profile rules explicitly required by the specification. */
.profile-name {
    text-align: center;
    font-weight: bold;
    font-size: 200%;
}
.student-number {
    font-family: Arial, sans-serif;
}
.profile-course {
    color: rgb(36, 81, 59);
}
.profile-photo {
    float: right;
    width: 180px;
    padding: 20px;
    margin: 0 0 16px 16px;
    border: 4px groove #24513b;
}
.profile-table {
    clear: both;
}
.profile-table th {
    width: 40%;
    text-align: center;
    font-weight: bold;
}
.profile-table td {
    background-color: #ffffff;
}
.profile-email td {
    text-align: center;
}

/* Footer */
footer {
    width: 100%;
    padding: 16px 2%;
    background-color: #24513b;
    color: #ffffff;
    text-align: center;
    font-style: italic;
}
footer p {
    max-width: none;
}
footer a {
    color: #ffffff;
}
footer a:hover, footer a:focus {
    color: #dfe9df;
}

/* Enhancements */
/* E1: narrow-screen adaptations, beyond baseline percentage widths.
   Reference: https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Media_queries/Using */
@media (max-width: 700px) {
    .home-page header { background-image: none; }
    .filter-control { float: left; clear: left; margin-top: 12px; }
    .species-filter .filter-label { display: block; margin-left: 24px; }
    main {
        padding: 16px;
    }
    aside {
        float: none;
        width: 100%;
        margin: 16px 0;
    }
    .profile-photo {
        float: none;
        margin: 0 0 16px;
    }
    .main-nav a, .main-nav summary {
        padding: 10px 8px;
    }
    .submenu {
        position: static;
        width: 100%;
    }
    th, td {
        padding: 6px;
        overflow-wrap: anywhere;
    }
    input, select, textarea {
        max-width: 100%;
    }
}

/* E2: explicit radio state + sibling selectors, no script.
   Reference: https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors/:checked */
.filter-control {
    width: auto;
}
.filter-label {
    display: inline-block;
    margin-right: 12px;
    padding: 4px;
}
.filter-control:checked + .filter-label {
    background-color: #dfe9df;
    font-weight: bold;
}
#filter-dipterocarpaceae:checked ~ .species-list .species-record,
#filter-lauraceae:checked ~ .species-list .species-record,
#filter-burseraceae:checked ~ .species-list .species-record,
#filter-myristicaceae:checked ~ .species-list .species-record {
    display: none;
}
#filter-dipterocarpaceae:checked ~ .species-list .dipterocarpaceae,
#filter-lauraceae:checked ~ .species-list .lauraceae,
#filter-burseraceae:checked ~ .species-list .burseraceae,
#filter-myristicaceae:checked ~ .species-list .myristicaceae {
    display: block;
}
/* A deep-linked record must remain reachable despite a restored filter selection. */
.species-list .species-record:target {
    display: block !important;
    border: 2px solid #24513b;
    padding: 12px;
}

/* E3: fragment-addressed photo viewer in normal page flow, with no overlay.
   Reference: https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors/:target */
.gallery-thumbnails img {
    width: 120px;
    margin: 6px;
}
.gallery-view {
    display: none;
}
.gallery-view:target {
    display: block;
    padding: 12px;
    border: 1px solid #24513b;
}
.gallery-view img {
    width: 700px;
}

/* E4: print a complete field guide even when the screen is filtered.
   Reference: https://developer.mozilla.org/en-US/docs/Web/CSS/Guides/Media_queries/Printing */
@media print {
    body, dialog, footer {
        background-color: #ffffff;
        color: #000000;
    }
    header, .main-nav, footer, .taxonomy-nav, .filter-control,
    .filter-label, .filter-help, .print-help, .gallery-thumbnails {
        display: none;
    }
    main {
        padding: 0;
    }
    aside {
        float: none;
        width: 100%;
        margin: 12px 0;
    }
    .species-list .species-record {
        display: block !important;
    }
    .gallery-view, .gallery-view:target {
        display: none;
    }
    figure {
        break-inside: avoid;
    }
    figure img {
        width: 180px;
    }
    h2, h3 {
        break-after: avoid;
    }
    .table-scroll {
        overflow: visible;
    }
    thead {
        display: table-header-group;
    }
    a {
        color: #000000;
        overflow-wrap: anywhere;
    }
    main a[href^="https"]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
    }
}
