@charset "utf-8";

/* =============================================
   STYLES THAT APPLY REGARDLESS OF SCREEN SIZE
   ============================================= */

body {
   font-family: Verdana, Geneva, sans-serif;
   color: rgb(91, 91, 91);
   background-color: ivory;
}

header {
   text-align: center;
   padding: 0;
}

header img {
   width: 100%;
}

h1, h2 {
   text-shadow: 4px 6px 5px gray;
}

h2 {
   font-size: 1.3em;
}

nav ul {
   list-style: none;
   margin: 0;
   padding: 0;
}

nav li {
   display: block;
   float: left;
   width: 20%;
}

nav a {
   display: block;
   background-color: hsl(210, 25%, 35%);
   line-height: 2.8em;
   text-decoration: none;
   text-align: center;
   color: hsl(210, 30%, 92%);
}

nav a:hover {
   background-color: hsl(40, 70%, 50%);
   color: hsl(210, 25%, 15%);
}

main {
   padding: 20px;
   margin-top: 35px;
}

body > footer {
   background-color: hsl(210, 25%, 35%);
   color: rgba(220, 220, 220, 0.6);
   font-weight: bold;
   font-size: 0.9em;
   line-height: 3em;
   text-align: center;
   margin-top: 10px;
   padding: 10px;
   clear: both;
}

ul {
   list-style-type: square;
}

/* Table styles (always apply) */
table {
   width: 100%;
   border-collapse: collapse;
   margin: 20px 0;
}

table caption {
   font-size: 1.2em;
   font-weight: bold;
   margin-bottom: 10px;
   color: hsl(210, 25%, 25%);
   text-align: left;
}

thead {
   background-color: hsl(210, 25%, 35%);
   color: hsl(45, 80%, 75%);
}

thead th {
   padding: 12px 15px;
   text-align: left;
   border: 2px solid hsl(210, 25%, 25%);
   font-size: 1em;
}

tbody tr {
   background-color: ivory;
}

tbody tr:nth-child(even) {
   background-color: hsl(210, 20%, 94%);
}

tbody td {
   padding: 10px 15px;
   border: 1px solid hsl(210, 20%, 75%);
}

tfoot {
   background-color: hsl(210, 25%, 35%);
   color: hsl(45, 80%, 75%);
}

tfoot td {
   padding: 10px 15px;
   border: 2px solid hsl(210, 25%, 25%);
   font-style: italic;
   font-size: 0.9em;
}

/* Gallery styles (always apply) */
.gallery {
   display: flex;
   flex-wrap: wrap;
   gap: 10px;
   margin: 20px 0;
}

.gallery img {
   object-fit: cover;
   float: none;
   width: auto;
   padding: 0;
}

/* =============================================
   FORM PSEUDO-CLASS STYLES (always apply)
   ============================================= */

input:focus, select:focus, textarea:focus {
   background-color: rgb(255, 255, 204);
   outline: 2px solid hsl(210, 25%, 35%);
}

input:valid, select:valid, textarea:valid {
   border: 2px solid green;
   background-color: rgb(240, 255, 240);
}

input:invalid, select:invalid, textarea:invalid {
   border: 2px solid red;
   background-color: rgb(255, 240, 240);
}

/* =============================================
   DESKTOP STYLES (min-width: 769px)
   ============================================= */

@media only screen and (min-width: 769px) {

   html {
      background-image: url("https://www.toptal.com/designers/subtlepatterns/uploads/double-bubble-outline.png");
      background-repeat: repeat;
      background-position: center center;
      background-color: hsl(210, 20%, 70%);
   }

   body {
      width: 90%;
      margin-left: auto;
      margin-right: auto;
   }

   main > img {
      width: 15%;
      padding: 15px;
      float: right;
   }

   .gallery img {
      width: calc(25% - 10px);
      height: 200px;
   }

   /* Form styles - desktop */
   form {
      width: 90%;
   }

   fieldset {
      width: 90%;
      padding: 5px;
      margin-right: 10px;
      margin-bottom: 10px;
   }

   fieldset input, fieldset select {
      display: block;
      position: relative;
      left: 30%;
      padding: 5px;
      height: auto;
      width: 60%;
   }

   fieldset label {
      display: block;
      position: absolute;
      padding: 5px;
      width: 30%;
   }

   fieldset input[type="radio"] {
      display: inline;
      position: inherit;
      left: 0;
      width: auto;
   }

   fieldset label.radio {
      display: inline;
      position: inherit;
   }

   fieldset input[type="submit"], fieldset input[type="reset"] {
      display: block;
      float: left;
      left: 0;
      text-align: center;
      width: 40%;
      padding: 10px;
      margin-left: 5%;
      margin-right: 5%;
      margin-bottom: 10px;
   }

   body > footer {
      clear: both;
   }

}

/* =============================================
   MOBILE STYLES (max-width: 768px)
   ============================================= */

@media only screen and (max-width: 768px) {

   body {
      width: 100%;
      margin: 0;
   }

   nav li {
      float: none;
      font-size: x-large;
      width: 100%;
   }

   nav a {
      border-bottom: 1px solid black;
   }

   main > img {
      width: 90%;
      float: none;
   }

   .gallery img {
      width: calc(50% - 10px);
      height: 160px;
   }

   /* Responsive table for mobile */
   table, thead, tbody, tfoot, th, td, tr {
      display: block;
   }

   thead tr {
      position: absolute;
      top: -9999px;
      left: -9999px;
   }

   tbody tr {
      border: 2px solid hsl(210, 25%, 55%);
      margin-bottom: 12px;
   }

   tbody td {
      border: none;
      border-bottom: 1px solid hsl(210, 20%, 82%);
      position: relative;
      padding-left: 50%;
   }

   tbody td::before {
      position: absolute;
      top: 10px;
      left: 10px;
      width: 45%;
      white-space: nowrap;
      font-weight: bold;
      color: hsl(210, 25%, 35%);
   }

   tbody td:nth-of-type(1)::before { content: "Name"; }
   tbody td:nth-of-type(2)::before { content: "Relationship"; }
   tbody td:nth-of-type(3)::before { content: "Birthday"; }
   tbody td:nth-of-type(4)::before { content: "Interesting Fact"; }

   tfoot td {
      border: none;
      border-top: 2px solid hsl(210, 25%, 25%);
   }

   /* Form styles - mobile */
   form {
      width: 100%;
      font-size: large;
   }

   fieldset {
      width: 100%;
      padding: 5px;
      margin: 0;
   }

   fieldset input, fieldset select {
      position: inherit;
      display: block;
      height: 50px;
      padding: 5px;
      width: 90%;
   }

   fieldset label {
      position: inherit;
      display: block;
      height: 50px;
      width: 90%;
   }

   fieldset input[type="submit"], fieldset input[type="reset"] {
      float: none;
      width: 90%;
      margin: 10px;
      font-size: 1.2em;
   }

}

/* 1-column gallery for very small screens */
@media only screen and (max-width: 480px) {

   .gallery img {
      width: 100%;
      height: 200px;
   }

}
