/*
1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4)
2. Allow adding a border to an element by just adding a border-width. (https://github.com/tailwindcss/tailwindcss/pull/116)
*/
*,
::before,
::after {
  box-sizing: border-box;
  border-width: 0;
  border-style: solid;
  border-color: #e5e7eb;
}

/*
1. Use a consistent sensible line-height in all browsers.
2. Prevent adjustments of font size after orientation changes in iOS.
3. Use a more readable tab size.
4. Use the user's configured `sans` font-family by default.
*/
html {
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -moz-tab-size: 4;
  -o-tab-size: 4;
  tab-size: 4;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
}

/*
1. Remove the margin in all browsers.
2. Inherit line-height from `html` so users can set them as a class directly on the `html` element.
*/
body {
  margin: 0;
  line-height: inherit;
  line-height: inherit;
  background-image: url("images/yoga-bg.png");
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
}

/*
1. Add the correct height in Firefox.
2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)
3. Ensure horizontal rules are visible by default.
*/
hr {
  height: 0;
  color: inherit;
  border-top-width: 1px;
}

/*
Add the correct text decoration in Chrome, Edge, and Safari.
*/
abbr:where([title]) {
  -webkit-text-decoration: underline dotted;
  text-decoration: underline dotted;
}

/*
Remove the default font size and weight for headings.
*/
h1,
h2,
h3,
h4,
h5,
h6 {
  font-size: inherit;
  font-weight: inherit;
}
/*
Reset links to optimize for opt-in styling instead of opt-out.
*/
a {
  color: inherit;
  text-decoration: inherit;
}

/*
Add the correct font weight in Edge and Safari.
*/
b,
strong {
  font-weight: bolder;
}

/*
1. Use the user's configured `mono` font family by default.
2. Correct the odd `em` font sizing in all browsers.
*/
code,
kbd,
samp,
pre {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; /* 1 */
  font-size: 1em;
}

/*
Add the correct font size in all browsers.
*/
small {
  font-size: 80%;
}

/*
Prevent `sub` and `sup` elements from affecting the line height in all browsers.
*/
sub,
sup {
  font-size: 75%;
  line-height: 0;
  position: relative;
  vertical-align: baseline;
}

sub {
  bottom: -0.25em;
}

sup {
  top: -0.5em;
}

/*
1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297)
2. Correct table border color inheritance in all Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)
3. Remove gaps between table borders by default.
*/
table {
  text-indent: 0;
  border-color: inherit;
  border-collapse: collapse;
}

/*
1. Change the font styles in all browsers.
2. Remove the margin in Firefox and Safari.
3. Remove default padding in all browsers.
*/
button,
input,
optgroup,
select,
textarea {
  font-family: inherit;
  font-size: 100%;
  line-height: inherit;
  color: inherit;
  margin: 0;
  padding: 0;
}

/*
Remove the inheritance of text transform in Edge and Firefox.
*/
button,
select {
  text-transform: none;
}

/*
1. Correct the inability to style clickable types in iOS and Safari.
2. Remove default button styles.
*/
button,
[type="button"],
[type="reset"],
[type="submit"] {
  appearance: button;
  -webkit-appearance: button;
  background-color: transparent;
  background-image: none;
}

/*
Use the modern Firefox focus style for all focusable elements.
*/
:-moz-focusring {
  outline: auto;
}

/*
Remove the additional `:invalid` styles in Firefox. (https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737)
*/
:-moz-ui-invalid {
  box-shadow: none;
}

/*
Add the correct vertical alignment in Chrome and Firefox.
*/
progress {
  vertical-align: baseline;
}

/*
Correct the cursor style of increment and decrement buttons in Safari.
*/
::-webkit-inner-spin-button,
::-webkit-outer-spin-button {
  height: auto;
}

/*
1. Correct the odd appearance in Chrome and Safari.
2. Correct the outline style in Safari.
*/
[type="search"] {
  appearance: textfield;
  -webkit-appearance: textfield;
  outline-offset: -2px;
}

/*
Remove the inner padding in Chrome and Safari on macOS.
*/
::-webkit-search-decoration {
  -webkit-appearance: none;
}

/*
1. Correct the inability to style clickable types in iOS and Safari.
2. Change font properties to `inherit` in Safari.
*/
::-webkit-file-upload-button {
  -webkit-appearance: button;
  font: inherit;
}

/*
Add the correct display in Chrome and Safari.
*/
summary {
  display: list-item;
}

/*
Removes the default spacing and border for appropriate elements.
*/
blockquote,
dl,
dd,
h1,
h2,
h3,
h4,
h5,
h6,
hr,
figure,
p,
pre {
  margin: 0;
}

fieldset {
  margin: 0;
  padding: 0;
}

legend {
  padding: 0;
}

ol,
ul,
menu {
  list-style: none;
  margin: 0;
  padding: 0;
}

/*
Prevent resizing textareas horizontally by default.
*/
textarea {
  resize: vertical;
}

/*
1. Reset the default placeholder opacity in Firefox. (https://github.com/tailwindlabs/tailwindcss/issues/3300)
2. Set the default placeholder color to the user's configured gray 400 color.
*/
input::-moz-placeholder,
textarea::-moz-placeholder {
  opacity: 1;
  color: #9ca3af;
}

input:-ms-input-placeholder,
textarea:-ms-input-placeholder {
  opacity: 1;
  color: #9ca3af;
}

input::placeholder,
textarea::placeholder {
  opacity: 1;
  color: #9ca3af;
}

/*
Set the default cursor for buttons.
*/
button,
[role="button"] {
  cursor: pointer;
}

/*
Make sure disabled buttons don't get the pointer cursor.
*/
:disabled {
  cursor: default;
}

/*
Make replaced elements `display: block` by default. (https://github.com/mozdevs/cssremedy/issues/14)
*/
img,
svg,
video,
canvas,
audio,
iframe,
embed,
object {
  display: block;
}

/*
Constrain images and videos to the parent width and preserve their intrinsic aspect ratio. (https://github.com/mozdevs/cssremedy/issues/14)
*/
img,
video {
  max-width: 100%;
  height: auto;
}

/*
Ensure the default browser behavior of the `hidden` attribute.
*/
[hidden] {
  display: none;
}

/* 
General styles for the widget
*/
#widget {
  position: absolute;
  inset: 50% auto auto 50%;
  border: 1px solid rgb(204, 204, 204);
  background: rgb(255, 255, 255);
  overflow: hidden;
  border-radius: 32px;
  outline: none;
  padding: 0px;
  margin-right: -50%;
  transform: translate(-50%, -50%);
}

#widget-container {
  width: 430px;
  min-height: 640px;
  max-height: 640px;
  display: flex;
  flex-direction: column;
  padding: 32px;
  background: white;
  font-family: sans-serif;
}

/* Tabs container */
#tab-header {
  width: 100%;
  display: flex;
  flex-direction: row;
  padding: 8px;
  gap: 8px;
  background-color: #f0f1f2;
  border-radius: 8px;
}

/* Each tab button */
.tab-btn {
  box-shadow: 0 0 #0000, 0 0 #0000, 0 0 #0000;
  color: #848791;
  font-weight: 500;
  font-size: 14px;
  padding: 4px 12px;
  background-color: #f0f1f2;
  border-radius: 8px;
  width: 100%;
}

/* Active tab */
.tab-btn.active {
  box-shadow: 0 0 #0000, 0 0 #0000, 0 1px 2px 0 rgb(0 0 0 / 0.05);
  color: #333;
  background-color: white;
}

/* Tab content wrapper */
#tab-contents {
  width: 320px;
  /* same width as timer widget */
}

/* Hide inactive tabs */
.tab-content {
  display: none;
}

/* Show active tab content */
.tab-content[style*="display: block"] {
  display: block;
}

#timer-container {
  width: 100%;
  text-align: center;
}

#timer-widget {
  width: 100%;
  height: 100%;
  max-height: 240px;
  box-shadow: 0 0 #0000, 0 0 #0000, 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  /* background: #fefefe; */
  background: #f0f1f2;
  border: 1px solid #f0f1f2;
  border-radius: 8px;
  justify-content: space-between;
  padding: 12px;
  font-weight: 500;
  color: #333;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 200px;
  cursor: pointer;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  margin-top: 28px;
}

#timer-widget-title {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  width: 100%;
}

#timer-widget-title button {
  width: 40px;
  height: 40px;
}

#timer-widget-title p {
  font-size: 1.5em;
}

#timer-widget-time {
  font-size: 1.2em;
  border: 1px solid #f0f1f2;
  padding: 4px 16px;
  background: #fefefe;
  border-radius: 9999px;
  color: #333;
  font-weight: 500;
}

h2 {
  margin: 0 0 15px;
  color: #333;
}

#timer-type {
  font-size: 1.5em;
  font-weight: bold;
}

label {
  display: block;
  margin: 10px 0 5px;
  font-weight: 600;
}

.time-inputs {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.time-group {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.unit-label {
  font-size: 0.75em;
  color: #666;
  margin-top: 4px;
}

.inline-input {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 2em;
  width: 2ch;
  text-align: center;
  /* font-weight: bold; */
  color: #333;
}

.inline-input:focus {
  outline: none;
  border-bottom: 2px solid #5c9ded;
}

.time-input-wrapper {
  display: flex;
  align-items: center;
}

.colon {
  font-size: 2em;
  margin: 0 6px;
  user-select: none;
}

.control {
  width: 40px;
  height: 40px;
  font-size: 1.5em;
  display: grid;
  place-items: center;
  border-radius: 100%;
  background-color: #f1f1f1;
  color: black;
  border-color: rgb(0 0 0 / 0.05);
  text-align: center;
  cursor: pointer;
}

.control:hover {
  background: #ebeaea;
}

.control:disabled {
  background: #fafaf9;
  cursor: not-allowed;
  color: #ccc;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 64px;
}

.setting-row > .control {
  display: flex;
  align-items: center;
  justify-content: center;
}

.setting-label {
  text-transform: uppercase;
  font-weight: bold;
  margin-bottom: 4px;
  font-size: 0.9em;
}

.setting-label.sets {
  color: #666; /* grey */
}

.setting-label.prepare {
  color: #b8860b; /* golden yellow */
}

.setting-label.flow {
  color: #2e7d32; /* green */
}

.setting-label.rest {
  color: #5c9ded; /* blue */
}

.setting-label.relaxation {
  color: #9c27b0; /* purple */
}

#timer-display {
  font-size: 2.5em;
  margin: 20px 0;
  color: #222;
}

#timer-container label {
  margin-top: 12px;
}

#start-btn {
  padding: 10px;
  border: none;
  background-color: #5c9ded;
  color: white;
  font-weight: bold;
  font-size: 1.2em;
  border-radius: 100%;
  cursor: pointer;
  transition: background-color 0.3s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 50px;
  height: 50px;
}

#start-btn:hover {
  background-color: #4a8ad4;
}

.widget {
  background: #fff;
  padding: 20px;
  border-radius: 16px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  max-width: 500px;
  margin: 0 auto;
}

.yoga-list {
  list-style-type: none;
  padding: 0;
}

.yoga-list li {
  margin-bottom: 16px;
  line-height: 1.6;
}

#timer-popup {
  position: absolute;
  inset: 0;
  background: #ffffff;
  display: none;
  flex-direction: column;
  justify-content: space-between;
  align-items: stretch;
  z-index: 9999;
  padding: 32px;
  gap: 28px;
}

/* #progress-container {
  background: #f0f1f2;
  width: 100%;
  height: 16px;
  border-radius: 8px;
  overflow: hidden;
}

#progress-bar {
  height: 100%;
  background: #5c9ded;
  width: 100%;
  transition: width 1s linear;
} */

#progress-container {
  position: relative;
  /* width: 200px;
  height: 200px; */
  margin: 0 auto;
  width: 100%;
  /* max-width: 300px; */
  aspect-ratio: 1;
}

#progress-bar {
  width: 100%;
  height: 100%;
  display: block;
  transform: rotate(270deg);
}

#progress-bar__bg,
#progress-bar__circle {
  fill: transparent;
  r: 45;
  cx: 50;
  cy: 50;
}

#progress-bar__bg {
  stroke: #f0f1f2;
}

#progress-bar__circle {
  stroke: #5c9ded;
  stroke-linecap: round;
  stroke-dasharray: 565.48; /* this will be dynamically set in JS too */
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear;
  transform-origin: center;
}

#countdown-timer {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 6em;
  font-weight: bold;
  line-height: 1em;
}

.popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#total-time-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.2;
}

#total-time-label {
  font-size: 0.75em;
  color: #999;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
}

#total-time-remaining {
  font-weight: bold;
  font-size: 1.2em;
}

.popup-main {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#phase-label {
  font-size: 1.2em;
  margin-bottom: 10px;
}

.popup-controls {
  display: flex;
  justify-content: space-around;
  gap: 20px;
}

.popup-controls button {
  flex: 1;
  padding: 12px;
  font-size: 1.2em;
  border: none;
  border-radius: 8px;
  background-color: #5c9ded;
  color: white;
  font-weight: bold;
}

.popup-controls button:hover {
  background-color: #4a8ad4;
}

#success-popup {
  position: absolute;
  inset: 0;
  background: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 32px;
  text-align: center;
  z-index: 9999;
}

.success-message {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.success-emoji {
  font-size: 6rem;
  line-height: 1;
  margin-bottom: 12px;
}

.success-message h2 {
  font-size: 2em;
  color: #2e7d32;
  margin-bottom: 12px;
}

.success-message p {
  font-size: 1.1em;
  color: #444;
}

.success-actions {
  display: flex;
  justify-content: space-around;
  gap: 20px;
  width: 100%;
}

.success-actions button {
  flex: 1;
  padding: 12px;
  font-size: 1.2em;
  border: none;
  border-radius: 8px;
  background-color: #5c9ded;
  color: white;
  font-weight: bold;
}

.success-actions button:hover {
  background-color: #4a8ad4;
}

/* === Popup Animation Classes === */
.popup-fade {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

.popup-fade.show {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.popup-fade.hide {
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
}
