/* Normalization styles ===================================================== */

*, 
::before,
::after {
  box-sizing: border-box; 
  margin: 0;
  padding: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

p {
  line-height: 1.5; /* (a) */
  /* (a) Accessibility guideline per MDN: https://developer.mozilla.org/en-US/docs/Web/CSS/line-height */
}

/* Main styling starts here ================================================= */

html {
  font-size: 16px;
  font-family: "Roboto", sans-serif, var(--fallback-font-stack);

  --fallback-font-stack: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; 
  --primary-gap-size: 15px;
  --bigger-gap-size: 25px;
  --header-and-footer-size: 3rem;
  --icon-size: calc(var(--header-and-footer-size) / 2);
  --major-btn-height: 36px;
  --major-btn-font-size: 0.8rem;

  --palette-dominant: hsl(266, 46%, 41%);
  --palette-dominant-dark: hsl(266, 80%, 41%);
  --palette-accent: #939393;
  --palette-dark-gray: #636363;
  --palette-light-gray: #E2E8F0;
  --palette-transparent-white: rgba(255, 255, 255, 0.6);
}

body {
  /* Utilize flex due to dynamic amount of content in table */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.major-btn {
  cursor: pointer;
  border: none;
  height: var(--major-btn-height);
  border-radius: calc(var(--major-btn-height) / 2);
  font-size: var(--major-btn-font-size);
  box-shadow: 3px 3px 6px var(--palette-light-gray);
  font-weight: bold;
  font-family: inherit;
}

.major-btn:hover {
  filter: saturate(150%);
}

/* ========================================================================== */

header {
  padding: var(--primary-gap-size);
  color: white;
  background-color: var(--palette-dominant);
  font-weight: bold;
  box-shadow: 0px 2px 11px -3px var(--palette-dark-gray);
}

header ul {
  list-style-type: none;
  display: grid;
  grid-template-columns: 1fr 150px 150px;
}

header li {
  height: var(--header-and-footer-size);
}

header a {
  height: 100%;
  display: grid;
  width: min-content;
  grid-template-columns: repeat(2, min-content);
  gap: var(--primary-gap-size);
  align-items: center;

  color: inherit;
}

header img {
  height: 75%;
}

/* ========================================================================== */

main {
  flex: 1;

  display: grid;
  grid-template-rows: min-content min-content min-content;
  gap: var(--bigger-gap-size);

  padding: var(--bigger-gap-size);
}

#greeting {
  color: var(--palette-dark-gray);
}

#main-buttons-container {
  display: grid;
  grid-template-columns: repeat(2, min-content);
  gap: var(--bigger-gap-size);
}

#main-buttons-container button {
  width: 150px;
  background-color: var(--palette-dominant);
  color: white;
}

/* ========================================================================== */


table {
  width: 80%;
  justify-self: center;
  
  table-layout: fixed;
  
  border-collapse: collapse;
  border: 2px solid black;
  font-size: 1rem;
  letter-spacing: 1px;
}

col:nth-child(1) {
  width: 35%; 
}
col:nth-child(2) {
  width: 20%;
}
col:nth-child(3) {
  width: 15%;
}
col:nth-child(4),
col:nth-child(5) {
  width: 7%;
}

td, th {
 border: 1px solid black;
 padding: 10px 20px;
}

td {
  /* hyphens: auto; */ /* Does not seem to work */
  word-wrap: break-word;
}

tr {
  height: 3rem;
}

tr:nth-child(even) td {
  background-color: rgb(250, 250, 250);
}

tr:nth-child(odd) td {
  background-color: rgb(245, 245, 245);
}

caption {
  padding: 10px;
  color: var(--palette-dark-gray);
}

/* Style specific columns */
[headers="col-title"], 
[headers="col-author"], 
[headers="col-genre"] {
  text-transform: capitalize;
}

[headers="col-pages"],
[headers="col-read"],
[headers="col-actions"] {
  text-align: center;
}

[headers="col-read"] {
  font-size: 1.5rem; 
}

/* Scrapped feature */
col:nth-child(6),
#col-actions,
[headers="col-actions"] {
  /* display: none; */
}

[headers="col-actions"] div {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  /* Note: flex is applied to this container div instead of td since applying
  to td seems to yield a strange extra border. */
  /* Note: flex was chosen for responsive layout on larger zooms and adding a
  responsive margin between the buttons. (A static left/right margin without 
  flex breaks on a higher zoom. */
}

[headers="col-actions"] button {
  width: 60px;
  font-family: inherit;
  padding: 4px;
  font-size: 0.8rem;
}

/* ========================================================================== */

footer {
  padding: var(--primary-gap-size);
  display: flex;
  justify-content: center;

  background-color: var(--palette-dominant);
  color: white;
}

/* ========================================================================== */

dialog {
  margin: auto;
  padding: calc(var(--bigger-gap-size) * 2);
  border: none;
  border-radius: 20px;
  box-shadow: 0px 2px 11px -3px var(--palette-dark-gray);
}

dialog p:first-of-type {
  margin-bottom: var(--bigger-gap-size);
}

dialog button {
  width: 50%;
  justify-self: center;
  color: white;
}

#confirm-add-book {
  grid-column: 1 / -1;
  background-color: #41BA8D;
  margin-top: 50px;
}

#cancel-add-book {
  grid-column: 1 / -1;
  background-color: #231F20;
}

/* ========================================================================== */

form { 
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: var(--primary-gap-size);
}

label {
  justify-self: end;
  font-weight: bold;
}

input:not([type="checkbox"]) {
  justify-self: start;

  width: 100%;
  height: 2rem;
  padding: 8px 17px;
  border-radius: calc(2rem / 2);
  font-size: 1rem;
  border: none;
  font-family: inherit;
  background-color: var(--palette-light-gray);
}

input[type="checkbox"] {
  justify-self: start;
}

input:not([type="checkbox"]):focus {
  outline: 2px solid #F88E20;
  outline-offset: 4px;
}
